add exact_word_prefix to Context

This commit is contained in:
ad hoc 2022-03-25 16:27:48 +01:00
parent e8f06f6c06
commit 21ae4143b1
No known key found for this signature in database
GPG Key ID: 4F00A782990CC643

View File

@ -70,6 +70,7 @@ pub trait Context<'c> {
fn word_docids(&self, word: &str) -> heed::Result<Option<RoaringBitmap>>; fn word_docids(&self, word: &str) -> heed::Result<Option<RoaringBitmap>>;
fn exact_word_docids(&self, word: &str) -> heed::Result<Option<RoaringBitmap>>; fn exact_word_docids(&self, word: &str) -> heed::Result<Option<RoaringBitmap>>;
fn word_prefix_docids(&self, word: &str) -> heed::Result<Option<RoaringBitmap>>; fn word_prefix_docids(&self, word: &str) -> heed::Result<Option<RoaringBitmap>>;
fn exact_word_prefix_docids(&self, word: &str) -> heed::Result<Option<RoaringBitmap>>;
fn word_pair_proximity_docids( fn word_pair_proximity_docids(
&self, &self,
left: &str, left: &str,
@ -127,6 +128,10 @@ impl<'c> Context<'c> for CriteriaBuilder<'c> {
self.index.word_prefix_docids.get(self.rtxn, &word) self.index.word_prefix_docids.get(self.rtxn, &word)
} }
fn exact_word_prefix_docids(&self, word: &str) -> heed::Result<Option<RoaringBitmap>> {
self.index.exact_word_prefix_docids.get(self.rtxn, &word)
}
fn word_pair_proximity_docids( fn word_pair_proximity_docids(
&self, &self,
left: &str, left: &str,
@ -522,6 +527,7 @@ pub mod test {
word_docids: HashMap<String, RoaringBitmap>, word_docids: HashMap<String, RoaringBitmap>,
exact_word_docids: HashMap<String, RoaringBitmap>, exact_word_docids: HashMap<String, RoaringBitmap>,
word_prefix_docids: HashMap<String, RoaringBitmap>, word_prefix_docids: HashMap<String, RoaringBitmap>,
exact_word_prefix_docids: HashMap<String, RoaringBitmap>,
word_pair_proximity_docids: HashMap<(String, String, i32), RoaringBitmap>, word_pair_proximity_docids: HashMap<(String, String, i32), RoaringBitmap>,
word_prefix_pair_proximity_docids: HashMap<(String, String, i32), RoaringBitmap>, word_prefix_pair_proximity_docids: HashMap<(String, String, i32), RoaringBitmap>,
docid_words: HashMap<u32, Vec<String>>, docid_words: HashMap<u32, Vec<String>>,
@ -544,6 +550,10 @@ pub mod test {
Ok(self.word_prefix_docids.get(&word.to_string()).cloned()) Ok(self.word_prefix_docids.get(&word.to_string()).cloned())
} }
fn exact_word_prefix_docids(&self, word: &str) -> heed::Result<Option<RoaringBitmap>> {
Ok(self.exact_word_prefix_docids.get(&word.to_string()).cloned())
}
fn word_pair_proximity_docids( fn word_pair_proximity_docids(
&self, &self,
left: &str, left: &str,
@ -672,6 +682,8 @@ pub mod test {
s("20") => &word_docids[&s("2020")] | &word_docids[&s("2021")], s("20") => &word_docids[&s("2020")] | &word_docids[&s("2021")],
}; };
let exact_word_prefix_docids = HashMap::new();
let mut word_pair_proximity_docids = HashMap::new(); let mut word_pair_proximity_docids = HashMap::new();
let mut word_prefix_pair_proximity_docids = HashMap::new(); let mut word_prefix_pair_proximity_docids = HashMap::new();
for (lword, lcandidates) in &word_docids { for (lword, lcandidates) in &word_docids {
@ -729,6 +741,7 @@ pub mod test {
word_docids, word_docids,
exact_word_docids, exact_word_docids,
word_prefix_docids, word_prefix_docids,
exact_word_prefix_docids,
word_pair_proximity_docids, word_pair_proximity_docids,
word_prefix_pair_proximity_docids, word_prefix_pair_proximity_docids,
docid_words, docid_words,