remove option of bucket_candidates

This commit is contained in:
many 2021-02-25 16:54:41 +01:00 committed by Kerollmops
parent 5af63c74e0
commit 7ac09d7b7c
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -12,7 +12,7 @@ pub struct Proximity<'t> {
query_tree: Option<(usize, Operation)>, query_tree: Option<(usize, Operation)>,
proximity: u8, proximity: u8,
candidates: Candidates, candidates: Candidates,
bucket_candidates: Option<RoaringBitmap>, bucket_candidates: RoaringBitmap,
parent: Option<Box<dyn Criterion + 't>>, parent: Option<Box<dyn Criterion + 't>>,
candidates_cache: HashMap<(Operation, u8), Vec<(Query, Query, RoaringBitmap)>>, candidates_cache: HashMap<(Operation, u8), Vec<(Query, Query, RoaringBitmap)>>,
} }
@ -29,7 +29,7 @@ impl<'t> Proximity<'t> {
query_tree: query_tree.map(|op| (maximum_proximity(&op), op)), query_tree: query_tree.map(|op| (maximum_proximity(&op), op)),
proximity: 0, proximity: 0,
candidates: candidates.map_or_else(Candidates::default, Candidates::Allowed), candidates: candidates.map_or_else(Candidates::default, Candidates::Allowed),
bucket_candidates: None, bucket_candidates: RoaringBitmap::new(),
parent: None, parent: None,
candidates_cache: HashMap::new(), candidates_cache: HashMap::new(),
}) })
@ -45,7 +45,7 @@ impl<'t> Proximity<'t> {
query_tree: None, query_tree: None,
proximity: 0, proximity: 0,
candidates: Candidates::default(), candidates: Candidates::default(),
bucket_candidates: None, bucket_candidates: RoaringBitmap::new(),
parent: Some(parent), parent: Some(parent),
candidates_cache: HashMap::new(), candidates_cache: HashMap::new(),
}) })
@ -84,8 +84,8 @@ impl<'t> Criterion for Proximity<'t> {
self.proximity += 1; self.proximity += 1;
let bucket_candidates = match self.parent { let bucket_candidates = match self.parent {
Some(_) => self.bucket_candidates.take(), Some(_) => take(&mut self.bucket_candidates),
None => Some(new_candidates.clone()), None => new_candidates.clone(),
}; };
return Ok(Some(CriterionResult { return Ok(Some(CriterionResult {
@ -112,8 +112,8 @@ impl<'t> Criterion for Proximity<'t> {
self.proximity += 1; self.proximity += 1;
let bucket_candidates = match self.parent { let bucket_candidates = match self.parent {
Some(_) => self.bucket_candidates.take(), Some(_) => take(&mut self.bucket_candidates),
None => Some(new_candidates.clone()), None => new_candidates.clone(),
}; };
return Ok(Some(CriterionResult { return Ok(Some(CriterionResult {
@ -128,7 +128,7 @@ impl<'t> Criterion for Proximity<'t> {
return Ok(Some(CriterionResult { return Ok(Some(CriterionResult {
query_tree: None, query_tree: None,
candidates: candidates.clone(), candidates: candidates.clone(),
bucket_candidates: Some(candidates), bucket_candidates: candidates,
})); }));
}, },
(None, Forbidden(_)) => { (None, Forbidden(_)) => {