Just do a little clean-up

This commit is contained in:
Kerollmops 2020-06-04 19:13:28 +02:00
parent 71dc6a3828
commit 1f7035f18f
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -80,10 +80,11 @@ impl Index {
let before = Instant::now(); let before = Instant::now();
let mut union_result = RoaringBitmap::default(); let mut union_result = RoaringBitmap::default();
if word.len() <= 4 { let count = if word.len() <= 4 {
if let Some(ids) = self.prefix_postings_ids.get(rtxn, &word[..word.len().min(5)])? { if let Some(ids) = self.prefix_postings_ids.get(rtxn, &word[..word.len().min(5)])? {
union_result = RoaringBitmap::deserialize_from(ids)?; union_result = RoaringBitmap::deserialize_from(ids)?;
} }
1
} else { } else {
let mut count = 0; let mut count = 0;
let mut stream = fst.search(dfa).into_stream(); let mut stream = fst.search(dfa).into_stream();
@ -95,21 +96,21 @@ impl Index {
union_result.union_with(&right); union_result.union_with(&right);
} }
} }
eprint!("with {:?} words ", count); count
} };
eprintln!("union for {:?} took {:.02?}", word, before.elapsed()); eprintln!("with {:?} words union for {:?} gives {:?} took {:.02?}",
count, word, union_result.len(), before.elapsed());
intersect_result = match intersect_result.take() { match &mut intersect_result {
Some(mut left) => { Some(left) => {
let before = Instant::now(); let before = Instant::now();
let left_len = left.len(); let left_len = left.len();
left.intersect_with(&union_result); left.intersect_with(&union_result);
eprintln!("intersect between {:?} and {:?} gives {:?} took {:.02?}", eprintln!("intersect between {:?} and {:?} gives {:?} took {:.02?}",
left_len, union_result.len(), left.len(), before.elapsed()); left_len, union_result.len(), left.len(), before.elapsed());
Some(left)
}, },
None => Some(union_result), None => intersect_result = Some(union_result),
}; }
} }
eprintln!("{} candidates", intersect_result.as_ref().map_or(0, |r| r.len())); eprintln!("{} candidates", intersect_result.as_ref().map_or(0, |r| r.len()));