Remove excluded document in criteria iterations

- pass excluded document to criteria to remove them in higher levels of the bucket-sort
- merge already returned document with excluded documents to avoid duplicas

Related to #125 and #112
Fix #170
This commit is contained in:
many
2021-04-28 18:01:23 +02:00
parent 374c2782ad
commit ee09e50e7f
9 changed files with 149 additions and 62 deletions

View File

@ -25,7 +25,7 @@ mod words;
pub mod r#final;
pub trait Criterion {
fn next(&mut self, wdcache: &mut WordDerivationsCache) -> anyhow::Result<Option<CriterionResult>>;
fn next(&mut self, params: &mut CriterionParameters) -> anyhow::Result<Option<CriterionResult>>;
}
/// The result of a call to the parent criterion.
@ -40,6 +40,12 @@ pub struct CriterionResult {
bucket_candidates: RoaringBitmap,
}
#[derive(Debug, PartialEq)]
pub struct CriterionParameters<'a> {
wdcache: &'a mut WordDerivationsCache,
excluded_candidates: &'a RoaringBitmap,
}
/// Either a set of candidates that defines the candidates
/// that are allowed to be returned,
/// or the candidates that must never be returned.