MeiliSearch/milli/src/search/criteria/initial.rs

28 lines
753 B
Rust
Raw Normal View History

2021-03-23 15:25:46 +01:00
use roaring::RoaringBitmap;
use crate::search::query_tree::Operation;
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::{}")]
fn next(&mut self, _: &mut CriterionParameters) -> anyhow::Result<Option<CriterionResult>> {
2021-03-23 15:25:46 +01:00
Ok(self.answer.take())
}
}