review fixes

This commit is contained in:
Marin Postma
2021-04-14 12:18:13 +02:00
parent 2f73fa55ae
commit 75464a1baa
10 changed files with 50 additions and 101 deletions

View File

@ -5,7 +5,7 @@ use log::debug;
use roaring::RoaringBitmap;
use crate::search::query_tree::Operation;
use super::{resolve_query_tree, Criterion, CriterionResult, Context, CriterionContext};
use super::{resolve_query_tree, Criterion, CriterionResult, Context, WordDerivationsCache};
pub struct Words<'t> {
ctx: &'t dyn Context,
@ -47,8 +47,7 @@ impl<'t> Words<'t> {
impl<'t> Criterion for Words<'t> {
#[logging_timer::time("Words::{}")]
fn next(&mut self, context: CriterionContext) -> anyhow::Result<Option<CriterionResult>> {
let CriterionContext { word_cache, exclude } = context;
fn next(&mut self, wdcache: &mut WordDerivationsCache) -> anyhow::Result<Option<CriterionResult>> {
loop {
debug!("Words at iteration {} ({:?})", self.query_trees.len(), self.candidates);
@ -62,7 +61,7 @@ impl<'t> Criterion for Words<'t> {
}));
},
(Some(qt), Some(candidates)) => {
let mut found_candidates = resolve_query_tree(self.ctx, &qt, &mut self.candidates_cache, word_cache)?;
let mut found_candidates = resolve_query_tree(self.ctx, &qt, &mut self.candidates_cache, wdcache)?;
found_candidates.intersect_with(&candidates);
candidates.difference_with(&found_candidates);
@ -100,7 +99,7 @@ impl<'t> Criterion for Words<'t> {
(None, None) => {
match self.parent.as_mut() {
Some(parent) => {
match parent.next(CriterionContext { word_cache, exclude })? {
match parent.next(wdcache)? {
Some(CriterionResult { query_tree, candidates, bucket_candidates }) => {
self.query_trees = query_tree.map(explode_query_tree).unwrap_or_default();
self.candidates = candidates;