2023-02-23 20:13:19 +08:00
|
|
|
#[cfg(test)]
|
2023-02-22 22:34:37 +08:00
|
|
|
pub mod detailed;
|
|
|
|
|
|
|
|
use roaring::RoaringBitmap;
|
|
|
|
|
2023-02-23 20:13:19 +08:00
|
|
|
use super::{
|
2023-02-27 22:04:40 +08:00
|
|
|
ranking_rule_graph::{
|
|
|
|
empty_paths_cache::EmptyPathsCache, paths_map::PathsMap, proximity::ProximityGraph,
|
2023-02-28 21:19:57 +08:00
|
|
|
typo::TypoGraph, RankingRuleGraph,
|
2023-02-27 22:04:40 +08:00
|
|
|
},
|
2023-02-28 18:49:24 +08:00
|
|
|
RankingRule, RankingRuleQueryTrait,
|
2023-02-23 20:13:19 +08:00
|
|
|
};
|
2023-02-22 22:34:37 +08:00
|
|
|
|
|
|
|
pub struct DefaultSearchLogger;
|
|
|
|
impl<Q: RankingRuleQueryTrait> SearchLogger<Q> for DefaultSearchLogger {
|
2023-02-28 18:49:24 +08:00
|
|
|
fn initial_query(&mut self, _query: &Q) {}
|
2023-02-22 22:34:37 +08:00
|
|
|
|
2023-02-28 18:49:24 +08:00
|
|
|
fn initial_universe(&mut self, _universe: &RoaringBitmap) {}
|
2023-02-22 22:34:37 +08:00
|
|
|
|
2023-02-28 19:42:29 +08:00
|
|
|
fn ranking_rules(&mut self, _rr: &[&mut dyn RankingRule<Q>]) {}
|
2023-02-22 22:34:37 +08:00
|
|
|
fn start_iteration_ranking_rule<'transaction>(
|
|
|
|
&mut self,
|
2023-02-28 18:49:24 +08:00
|
|
|
_ranking_rule_idx: usize,
|
|
|
|
_ranking_rule: &dyn RankingRule<'transaction, Q>,
|
|
|
|
_query: &Q,
|
|
|
|
_universe: &RoaringBitmap,
|
2023-02-22 22:34:37 +08:00
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
|
|
|
fn next_bucket_ranking_rule<'transaction>(
|
|
|
|
&mut self,
|
2023-02-28 18:49:24 +08:00
|
|
|
_ranking_rule_idx: usize,
|
|
|
|
_ranking_rule: &dyn RankingRule<'transaction, Q>,
|
|
|
|
_universe: &RoaringBitmap,
|
2023-02-22 22:34:37 +08:00
|
|
|
) {
|
|
|
|
}
|
2023-02-27 23:14:53 +08:00
|
|
|
fn skip_bucket_ranking_rule<'transaction>(
|
|
|
|
&mut self,
|
2023-02-28 18:49:24 +08:00
|
|
|
_ranking_rule_idx: usize,
|
|
|
|
_ranking_rule: &dyn RankingRule<'transaction, Q>,
|
|
|
|
_candidates: &RoaringBitmap,
|
2023-02-27 23:14:53 +08:00
|
|
|
) {
|
|
|
|
}
|
2023-02-22 22:34:37 +08:00
|
|
|
|
|
|
|
fn end_iteration_ranking_rule<'transaction>(
|
|
|
|
&mut self,
|
2023-02-28 18:49:24 +08:00
|
|
|
_ranking_rule_idx: usize,
|
|
|
|
_ranking_rule: &dyn RankingRule<'transaction, Q>,
|
|
|
|
_universe: &RoaringBitmap,
|
2023-02-22 22:34:37 +08:00
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
2023-02-28 18:49:24 +08:00
|
|
|
fn add_to_results(&mut self, _docids: &[u32]) {}
|
2023-02-22 22:34:37 +08:00
|
|
|
|
2023-02-28 18:49:24 +08:00
|
|
|
fn log_words_state(&mut self, _query_graph: &Q) {}
|
2023-02-23 20:13:19 +08:00
|
|
|
|
|
|
|
fn log_proximity_state(
|
|
|
|
&mut self,
|
2023-02-28 18:49:24 +08:00
|
|
|
_query_graph: &RankingRuleGraph<ProximityGraph>,
|
|
|
|
_paths_map: &PathsMap<u64>,
|
|
|
|
_empty_paths_cache: &EmptyPathsCache,
|
2023-02-23 20:13:19 +08:00
|
|
|
) {
|
|
|
|
}
|
2023-02-28 21:19:57 +08:00
|
|
|
|
|
|
|
fn log_typo_state(
|
|
|
|
&mut self,
|
|
|
|
query_graph: &RankingRuleGraph<TypoGraph>,
|
|
|
|
paths: &PathsMap<u64>,
|
|
|
|
empty_paths_cache: &EmptyPathsCache,
|
|
|
|
) {
|
|
|
|
}
|
2023-02-22 22:34:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
pub trait SearchLogger<Q: RankingRuleQueryTrait> {
|
|
|
|
fn initial_query(&mut self, query: &Q);
|
|
|
|
fn initial_universe(&mut self, universe: &RoaringBitmap);
|
|
|
|
|
2023-02-28 19:42:29 +08:00
|
|
|
fn ranking_rules(&mut self, rr: &[&mut dyn RankingRule<Q>]);
|
2023-02-22 22:34:37 +08:00
|
|
|
|
|
|
|
fn start_iteration_ranking_rule<'transaction>(
|
|
|
|
&mut self,
|
|
|
|
ranking_rule_idx: usize,
|
|
|
|
ranking_rule: &dyn RankingRule<'transaction, Q>,
|
|
|
|
query: &Q,
|
|
|
|
universe: &RoaringBitmap,
|
|
|
|
);
|
|
|
|
fn next_bucket_ranking_rule<'transaction>(
|
|
|
|
&mut self,
|
|
|
|
ranking_rule_idx: usize,
|
|
|
|
ranking_rule: &dyn RankingRule<'transaction, Q>,
|
|
|
|
universe: &RoaringBitmap,
|
|
|
|
);
|
2023-02-27 23:14:53 +08:00
|
|
|
fn skip_bucket_ranking_rule<'transaction>(
|
|
|
|
&mut self,
|
|
|
|
ranking_rule_idx: usize,
|
|
|
|
ranking_rule: &dyn RankingRule<'transaction, Q>,
|
|
|
|
candidates: &RoaringBitmap,
|
|
|
|
);
|
2023-02-22 22:34:37 +08:00
|
|
|
fn end_iteration_ranking_rule<'transaction>(
|
|
|
|
&mut self,
|
|
|
|
ranking_rule_idx: usize,
|
|
|
|
ranking_rule: &dyn RankingRule<'transaction, Q>,
|
|
|
|
universe: &RoaringBitmap,
|
|
|
|
);
|
2023-02-27 23:14:53 +08:00
|
|
|
fn add_to_results(&mut self, docids: &[u32]);
|
2023-02-22 22:34:37 +08:00
|
|
|
|
|
|
|
fn log_words_state(&mut self, query_graph: &Q);
|
2023-02-23 20:13:19 +08:00
|
|
|
|
|
|
|
fn log_proximity_state(
|
|
|
|
&mut self,
|
|
|
|
query_graph: &RankingRuleGraph<ProximityGraph>,
|
|
|
|
paths: &PathsMap<u64>,
|
2023-02-27 22:04:40 +08:00
|
|
|
empty_paths_cache: &EmptyPathsCache,
|
2023-02-23 20:13:19 +08:00
|
|
|
);
|
2023-02-28 21:19:57 +08:00
|
|
|
|
|
|
|
fn log_typo_state(
|
|
|
|
&mut self,
|
|
|
|
query_graph: &RankingRuleGraph<TypoGraph>,
|
|
|
|
paths: &PathsMap<u64>,
|
|
|
|
empty_paths_cache: &EmptyPathsCache,
|
|
|
|
);
|
2023-02-22 22:34:37 +08:00
|
|
|
}
|