mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 20:15:07 +08:00
Make set algorithm return None when nothing can be returned
This commit is contained in:
parent
b3e2280bb9
commit
17c8c6f945
@ -71,7 +71,18 @@ impl<'t> Criterion for Attribute<'t> {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
set_compute_candidates(self.ctx, flattened_query_tree, candidates, wdcache)?
|
let found_candidates = set_compute_candidates(self.ctx, flattened_query_tree, candidates, wdcache)?;
|
||||||
|
|
||||||
|
match found_candidates {
|
||||||
|
Some(candidates) => candidates,
|
||||||
|
None => {
|
||||||
|
return Ok(Some(CriterionResult {
|
||||||
|
query_tree: self.query_tree.take(),
|
||||||
|
candidates: self.candidates.take(),
|
||||||
|
bucket_candidates: take(&mut self.bucket_candidates),
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
candidates.difference_with(&found_candidates);
|
candidates.difference_with(&found_candidates);
|
||||||
@ -414,11 +425,11 @@ fn set_compute_candidates<'t>(
|
|||||||
branches: &Vec<Vec<Vec<Query>>>,
|
branches: &Vec<Vec<Vec<Query>>>,
|
||||||
allowed_candidates: &RoaringBitmap,
|
allowed_candidates: &RoaringBitmap,
|
||||||
wdcache: &mut WordDerivationsCache,
|
wdcache: &mut WordDerivationsCache,
|
||||||
) -> anyhow::Result<RoaringBitmap>
|
) -> anyhow::Result<Option<RoaringBitmap>>
|
||||||
{
|
{
|
||||||
let mut branches_heap = initialize_query_level_iterators(ctx, branches, wdcache)?;
|
let mut branches_heap = initialize_query_level_iterators(ctx, branches, wdcache)?;
|
||||||
let lowest_level = TreeLevel::min_value();
|
let lowest_level = TreeLevel::min_value();
|
||||||
let mut final_candidates = RoaringBitmap::new();
|
let mut final_candidates = None;
|
||||||
|
|
||||||
while let Some(mut branch) = branches_heap.peek_mut() {
|
while let Some(mut branch) = branches_heap.peek_mut() {
|
||||||
let is_lowest_level = branch.tree_level == lowest_level;
|
let is_lowest_level = branch.tree_level == lowest_level;
|
||||||
@ -427,7 +438,7 @@ fn set_compute_candidates<'t>(
|
|||||||
candidates.intersect_with(&allowed_candidates);
|
candidates.intersect_with(&allowed_candidates);
|
||||||
if candidates.len() > 0 && is_lowest_level {
|
if candidates.len() > 0 && is_lowest_level {
|
||||||
// we have candidates, but we can't dig deeper, return candidates.
|
// we have candidates, but we can't dig deeper, return candidates.
|
||||||
final_candidates = std::mem::take(candidates);
|
final_candidates = Some(std::mem::take(candidates));
|
||||||
break;
|
break;
|
||||||
} else if candidates.len() > 0 {
|
} else if candidates.len() > 0 {
|
||||||
// we have candidates, lets dig deeper in levels.
|
// we have candidates, lets dig deeper in levels.
|
||||||
|
Loading…
Reference in New Issue
Block a user