mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-30 08:44:27 +01:00
Reduce the number of KV lookups to the sucessfulls only
This commit is contained in:
parent
e974e6b3c9
commit
3577de04b8
10
src/lib.rs
10
src/lib.rs
@ -102,11 +102,11 @@ impl Index {
|
|||||||
// TODO re-enable the prefixes system
|
// TODO re-enable the prefixes system
|
||||||
let mut stream = fst.search(&dfa).into_stream();
|
let mut stream = fst.search(&dfa).into_stream();
|
||||||
while let Some(word) = stream.next() {
|
while let Some(word) = stream.next() {
|
||||||
derived_words.push(word.to_vec());
|
|
||||||
let word = std::str::from_utf8(word)?;
|
let word = std::str::from_utf8(word)?;
|
||||||
if let Some(attrs) = self.postings_attrs.get(rtxn, word)? {
|
if let Some(attrs) = self.postings_attrs.get(rtxn, word)? {
|
||||||
let right = RoaringBitmap::deserialize_from(attrs)?;
|
let right = RoaringBitmap::deserialize_from(attrs)?;
|
||||||
union_positions.union_with(&right);
|
union_positions.union_with(&right);
|
||||||
|
derived_words.push((word.as_bytes().to_vec(), right));
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,7 +145,8 @@ impl Index {
|
|||||||
for (i, (derived_words, pos))in once(left).chain(once(right)).enumerate() {
|
for (i, (derived_words, pos))in once(left).chain(once(right)).enumerate() {
|
||||||
let mut union_docids = RoaringBitmap::default();
|
let mut union_docids = RoaringBitmap::default();
|
||||||
// TODO re-enable the prefixes system
|
// TODO re-enable the prefixes system
|
||||||
for word in derived_words.iter() {
|
for (word, attrs) in derived_words.iter() {
|
||||||
|
if attrs.contains(pos) {
|
||||||
if i == 0 { l_lookups += 1 } else { r_lookups += 1 }
|
if i == 0 { l_lookups += 1 } else { r_lookups += 1 }
|
||||||
let mut key = word.clone();
|
let mut key = word.clone();
|
||||||
key.extend_from_slice(&pos.to_be_bytes());
|
key.extend_from_slice(&pos.to_be_bytes());
|
||||||
@ -155,6 +156,7 @@ impl Index {
|
|||||||
union_docids.union_with(&right);
|
union_docids.union_with(&right);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
match &mut intersect_docids {
|
match &mut intersect_docids {
|
||||||
Some(left) => left.intersect_with(&union_docids),
|
Some(left) => left.intersect_with(&union_docids),
|
||||||
@ -189,7 +191,8 @@ impl Index {
|
|||||||
let before = Instant::now();
|
let before = Instant::now();
|
||||||
|
|
||||||
// TODO re-enable the prefixes system
|
// TODO re-enable the prefixes system
|
||||||
for word in derived_words.iter() {
|
for (word, attrs) in derived_words.iter() {
|
||||||
|
if attrs.contains(pos) {
|
||||||
let mut key = word.clone();
|
let mut key = word.clone();
|
||||||
key.extend_from_slice(&pos.to_be_bytes());
|
key.extend_from_slice(&pos.to_be_bytes());
|
||||||
if let Some(attrs) = self.postings_ids.get(rtxn, &key)? {
|
if let Some(attrs) = self.postings_ids.get(rtxn, &key)? {
|
||||||
@ -198,6 +201,7 @@ impl Index {
|
|||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let before_intersect = Instant::now();
|
let before_intersect = Instant::now();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user