// #[cfg(test)] pub mod detailed; use roaring::RoaringBitmap; use super::interner::{Interned, MappedInterner}; use super::query_graph::QueryNode; use super::ranking_rule_graph::{ DeadEndsCache, ProximityCondition, ProximityGraph, RankingRuleGraph, TypoCondition, TypoGraph, }; use super::ranking_rules::BoxRankingRule; use super::{RankingRule, RankingRuleQueryTrait}; /// Trait for structure logging the execution of a search query. pub trait SearchLogger { /// Logs the initial query fn initial_query(&mut self, query: &Q); /// Logs the query that was used to compute the set of all candidates fn query_for_universe(&mut self, query: &Q); /// Logs the value of the initial set of all candidates fn initial_universe(&mut self, universe: &RoaringBitmap); /// Logs the ranking rules used to perform the search query fn ranking_rules(&mut self, rr: &[BoxRankingRule]); /// Logs the start of a ranking rule's iteration. fn start_iteration_ranking_rule( &mut self, ranking_rule_idx: usize, ranking_rule: &dyn RankingRule, query: &Q, universe: &RoaringBitmap, ); /// Logs the end of the computation of a ranking rule bucket fn next_bucket_ranking_rule( &mut self, ranking_rule_idx: usize, ranking_rule: &dyn RankingRule, universe: &RoaringBitmap, candidates: &RoaringBitmap, ); /// Logs the skipping of a ranking rule bucket fn skip_bucket_ranking_rule( &mut self, ranking_rule_idx: usize, ranking_rule: &dyn RankingRule, candidates: &RoaringBitmap, ); /// Logs the end of a ranking rule's iteration. fn end_iteration_ranking_rule( &mut self, ranking_rule_idx: usize, ranking_rule: &dyn RankingRule, universe: &RoaringBitmap, ); /// Logs the addition of document ids to the final results fn add_to_results(&mut self, docids: &[u32]); /// Logs the internal state of the words ranking rule fn log_words_state(&mut self, query_graph: &Q); /// Logs the internal state of the proximity ranking rule fn log_proximity_state( &mut self, query_graph: &RankingRuleGraph, paths: &[Vec>], dead_ends_cache: &DeadEndsCache, universe: &RoaringBitmap, distances: &MappedInterner>, cost: u64, ); /// Logs the internal state of the typo ranking rule fn log_typo_state( &mut self, query_graph: &RankingRuleGraph, paths: &[Vec>], dead_ends_cache: &DeadEndsCache, universe: &RoaringBitmap, distances: &MappedInterner>, cost: u64, ); } /// A dummy [`SearchLogger`] which does nothing. pub struct DefaultSearchLogger; impl SearchLogger for DefaultSearchLogger { fn initial_query(&mut self, _query: &Q) {} fn query_for_universe(&mut self, _query: &Q) {} fn initial_universe(&mut self, _universe: &RoaringBitmap) {} fn ranking_rules(&mut self, _rr: &[BoxRankingRule]) {} fn start_iteration_ranking_rule( &mut self, _ranking_rule_idx: usize, _ranking_rule: &dyn RankingRule, _query: &Q, _universe: &RoaringBitmap, ) { } fn next_bucket_ranking_rule( &mut self, _ranking_rule_idx: usize, _ranking_rule: &dyn RankingRule, _universe: &RoaringBitmap, _candidates: &RoaringBitmap, ) { } fn skip_bucket_ranking_rule( &mut self, _ranking_rule_idx: usize, _ranking_rule: &dyn RankingRule, _candidates: &RoaringBitmap, ) { } fn end_iteration_ranking_rule( &mut self, _ranking_rule_idx: usize, _ranking_rule: &dyn RankingRule, _universe: &RoaringBitmap, ) { } fn add_to_results(&mut self, _docids: &[u32]) {} fn log_words_state(&mut self, _query_graph: &Q) {} fn log_proximity_state( &mut self, _query_graph: &RankingRuleGraph, _paths_map: &[Vec>], _dead_ends_cache: &DeadEndsCache, _universe: &RoaringBitmap, _distances: &MappedInterner>, _cost: u64, ) { } fn log_typo_state( &mut self, _query_graph: &RankingRuleGraph, _paths: &[Vec>], _dead_ends_cache: &DeadEndsCache, _universe: &RoaringBitmap, _distances: &MappedInterner>, _cost: u64, ) { } }