2021-03-23 15:25:46 +01:00
|
|
|
use roaring::RoaringBitmap;
|
|
|
|
|
|
|
|
use crate::search::query_tree::Operation;
|
|
|
|
|
2021-04-28 18:01:23 +02:00
|
|
|
use super::{Criterion, CriterionResult, CriterionParameters};
|
2021-03-23 15:25:46 +01:00
|
|
|
|
|
|
|
pub struct Initial {
|
|
|
|
answer: Option<CriterionResult>
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Initial {
|
|
|
|
pub fn new(query_tree: Option<Operation>, mut candidates: Option<RoaringBitmap>) -> Initial {
|
|
|
|
let answer = CriterionResult {
|
|
|
|
query_tree,
|
|
|
|
candidates: candidates.clone(),
|
|
|
|
bucket_candidates: candidates.take().unwrap_or_default(),
|
|
|
|
};
|
|
|
|
Initial { answer: Some(answer) }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Criterion for Initial {
|
|
|
|
#[logging_timer::time("Initial::{}")]
|
2021-04-28 18:01:23 +02:00
|
|
|
fn next(&mut self, _: &mut CriterionParameters) -> anyhow::Result<Option<CriterionResult>> {
|
2021-03-23 15:25:46 +01:00
|
|
|
Ok(self.answer.take())
|
|
|
|
}
|
|
|
|
}
|