Add a lot of debug

This commit is contained in:
Kerollmops 2021-02-24 15:37:37 +01:00
parent ae4a237e58
commit 4510bbccca
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4
4 changed files with 15 additions and 1 deletions

View File

@ -2,6 +2,7 @@ use std::collections::HashMap;
use std::mem::take; use std::mem::take;
use roaring::RoaringBitmap; use roaring::RoaringBitmap;
use log::debug;
use crate::search::query_tree::{maximum_proximity, Operation, Query}; use crate::search::query_tree::{maximum_proximity, Operation, Query};
use super::{Candidates, Criterion, CriterionResult, Context, query_docids, query_pair_proximity_docids}; use super::{Candidates, Criterion, CriterionResult, Context, query_docids, query_pair_proximity_docids};
@ -55,6 +56,12 @@ impl<'t> Criterion for Proximity<'t> {
fn next(&mut self) -> anyhow::Result<Option<CriterionResult>> { fn next(&mut self) -> anyhow::Result<Option<CriterionResult>> {
use Candidates::{Allowed, Forbidden}; use Candidates::{Allowed, Forbidden};
loop { loop {
debug!("Proximity at iteration {} (max {:?}) ({:?})",
self.proximity,
self.query_tree.as_ref().map(|(mp, _)| mp),
self.candidates,
);
match (&mut self.query_tree, &mut self.candidates) { match (&mut self.query_tree, &mut self.candidates) {
(_, Allowed(candidates)) if candidates.is_empty() => { (_, Allowed(candidates)) if candidates.is_empty() => {
self.query_tree = None; self.query_tree = None;

View File

@ -2,6 +2,7 @@ use std::{borrow::Cow, collections::HashMap, mem::take};
use anyhow::bail; use anyhow::bail;
use roaring::RoaringBitmap; use roaring::RoaringBitmap;
use log::debug;
use crate::search::query_tree::{maximum_typo, Operation, Query, QueryKind}; use crate::search::query_tree::{maximum_typo, Operation, Query, QueryKind};
use crate::search::word_derivations; use crate::search::word_derivations;
@ -59,6 +60,8 @@ impl<'t> Criterion for Typo<'t> {
fn next(&mut self) -> anyhow::Result<Option<CriterionResult>> { fn next(&mut self) -> anyhow::Result<Option<CriterionResult>> {
use Candidates::{Allowed, Forbidden}; use Candidates::{Allowed, Forbidden};
loop { loop {
debug!("Typo at iteration {} ({:?})", self.number_typos, self.candidates);
match (&mut self.query_tree, &mut self.candidates) { match (&mut self.query_tree, &mut self.candidates) {
(_, Allowed(candidates)) if candidates.is_empty() => { (_, Allowed(candidates)) if candidates.is_empty() => {
self.query_tree = None; self.query_tree = None;

View File

@ -2,6 +2,7 @@ use std::collections::HashMap;
use std::mem::take; use std::mem::take;
use anyhow::bail; use anyhow::bail;
use log::debug;
use roaring::RoaringBitmap; use roaring::RoaringBitmap;
use crate::search::query_tree::Operation; use crate::search::query_tree::Operation;
@ -52,8 +53,9 @@ impl<'t> Words<'t> {
impl<'t> Criterion for Words<'t> { impl<'t> Criterion for Words<'t> {
fn next(&mut self) -> anyhow::Result<Option<CriterionResult>> { fn next(&mut self) -> anyhow::Result<Option<CriterionResult>> {
use Candidates::{Allowed, Forbidden}; use Candidates::{Allowed, Forbidden};
loop { loop {
debug!("Words at iteration {} ({:?})", self.query_trees.len(), self.candidates);
match (self.query_trees.pop(), &mut self.candidates) { match (self.query_trees.pop(), &mut self.candidates) {
(_, Allowed(candidates)) if candidates.is_empty() => { (_, Allowed(candidates)) if candidates.is_empty() => {
self.query_trees = Vec::new(); self.query_trees = Vec::new();

View File

@ -107,6 +107,8 @@ impl<'a> Search<'a> {
let mut initial_candidates = RoaringBitmap::new(); let mut initial_candidates = RoaringBitmap::new();
while let Some(CriterionResult { candidates, bucket_candidates, .. }) = criteria.next()? { while let Some(CriterionResult { candidates, bucket_candidates, .. }) = criteria.next()? {
debug!("Number of candidates found {}", candidates.len());
let mut len = candidates.len() as usize; let mut len = candidates.len() as usize;
let mut candidates = candidates.into_iter(); let mut candidates = candidates.into_iter();