meilisearch/milli/src/search/new/logger/mod.rs

117 lines
3.4 KiB
Rust
Raw Normal View History

2023-03-18 22:04:34 +08:00
// #[cfg(test)]
2023-02-22 22:34:37 +08:00
pub mod detailed;
2023-04-06 22:24:44 +08:00
use std::any::Any;
2023-02-22 22:34:37 +08:00
use roaring::RoaringBitmap;
2023-04-06 22:24:44 +08:00
use super::graph_based_ranking_rule::Typo;
2023-03-28 18:39:42 +08:00
use super::ranking_rules::BoxRankingRule;
2023-04-06 22:24:44 +08:00
use super::sort::Sort;
use super::words::Words;
2023-03-08 16:55:53 +08:00
use super::{RankingRule, RankingRuleQueryTrait};
2023-02-22 22:34:37 +08:00
2023-03-08 20:26:29 +08:00
/// Trait for structure logging the execution of a search query.
pub trait SearchLogger<Q: RankingRuleQueryTrait> {
/// Logs the initial query
fn initial_query(&mut self, query: &Q);
/// Logs the value of the initial set of all candidates
fn initial_universe(&mut self, universe: &RoaringBitmap);
2023-04-06 22:24:44 +08:00
/// Logs the query that was used to compute the set of all candidates
fn query_for_initial_universe(&mut self, query: &Q);
2023-03-08 20:26:29 +08:00
/// Logs the ranking rules used to perform the search query
2023-03-28 18:39:42 +08:00
fn ranking_rules(&mut self, rr: &[BoxRankingRule<Q>]);
2023-03-08 20:26:29 +08:00
/// Logs the start of a ranking rule's iteration.
2023-03-23 16:15:57 +08:00
fn start_iteration_ranking_rule(
2023-03-08 20:26:29 +08:00
&mut self,
ranking_rule_idx: usize,
2023-03-23 16:15:57 +08:00
ranking_rule: &dyn RankingRule<Q>,
2023-03-08 20:26:29 +08:00
query: &Q,
universe: &RoaringBitmap,
);
/// Logs the end of the computation of a ranking rule bucket
2023-03-23 16:15:57 +08:00
fn next_bucket_ranking_rule(
2023-03-08 20:26:29 +08:00
&mut self,
ranking_rule_idx: usize,
2023-03-23 16:15:57 +08:00
ranking_rule: &dyn RankingRule<Q>,
2023-03-08 20:26:29 +08:00
universe: &RoaringBitmap,
candidates: &RoaringBitmap,
);
/// Logs the skipping of a ranking rule bucket
2023-03-23 16:15:57 +08:00
fn skip_bucket_ranking_rule(
2023-03-08 20:26:29 +08:00
&mut self,
ranking_rule_idx: usize,
2023-03-23 16:15:57 +08:00
ranking_rule: &dyn RankingRule<Q>,
2023-03-08 20:26:29 +08:00
candidates: &RoaringBitmap,
);
/// Logs the end of a ranking rule's iteration.
2023-03-23 16:15:57 +08:00
fn end_iteration_ranking_rule(
2023-03-08 20:26:29 +08:00
&mut self,
ranking_rule_idx: usize,
2023-03-23 16:15:57 +08:00
ranking_rule: &dyn RankingRule<Q>,
2023-03-08 20:26:29 +08:00
universe: &RoaringBitmap,
);
/// Logs the addition of document ids to the final results
fn add_to_results(&mut self, docids: &[u32]);
2023-04-06 22:24:44 +08:00
/// Logs the internal state of the ranking rule
fn log_ranking_rule_state<'ctx>(&mut self, rr: &(dyn Any + 'ctx)) {
if let Some(_words) = rr.downcast_ref::<Words>() {
} else if let Some(_sort) = rr.downcast_ref::<Sort<'ctx, Q>>() {
} else if let Some(_typo) = rr.downcast_ref::<Typo>() {
}
}
2023-03-08 20:26:29 +08:00
}
/// A dummy [`SearchLogger`] which does nothing.
2023-02-22 22:34:37 +08:00
pub struct DefaultSearchLogger;
2023-03-08 20:26:29 +08:00
2023-02-22 22:34:37 +08:00
impl<Q: RankingRuleQueryTrait> SearchLogger<Q> for DefaultSearchLogger {
fn initial_query(&mut self, _query: &Q) {}
2023-04-06 22:24:44 +08:00
fn query_for_initial_universe(&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-03-28 18:39:42 +08:00
fn ranking_rules(&mut self, _rr: &[BoxRankingRule<Q>]) {}
2023-03-23 16:15:57 +08:00
fn start_iteration_ranking_rule(
2023-02-22 22:34:37 +08:00
&mut self,
2023-02-28 18:49:24 +08:00
_ranking_rule_idx: usize,
2023-03-23 16:15:57 +08:00
_ranking_rule: &dyn RankingRule<Q>,
2023-02-28 18:49:24 +08:00
_query: &Q,
_universe: &RoaringBitmap,
2023-02-22 22:34:37 +08:00
) {
}
2023-03-23 16:15:57 +08:00
fn next_bucket_ranking_rule(
2023-02-22 22:34:37 +08:00
&mut self,
2023-02-28 18:49:24 +08:00
_ranking_rule_idx: usize,
2023-03-23 16:15:57 +08:00
_ranking_rule: &dyn RankingRule<Q>,
2023-02-28 18:49:24 +08:00
_universe: &RoaringBitmap,
_candidates: &RoaringBitmap,
2023-02-22 22:34:37 +08:00
) {
}
2023-03-23 16:15:57 +08:00
fn skip_bucket_ranking_rule(
&mut self,
2023-02-28 18:49:24 +08:00
_ranking_rule_idx: usize,
2023-03-23 16:15:57 +08:00
_ranking_rule: &dyn RankingRule<Q>,
2023-02-28 18:49:24 +08:00
_candidates: &RoaringBitmap,
) {
}
2023-02-22 22:34:37 +08:00
2023-03-23 16:15:57 +08:00
fn end_iteration_ranking_rule(
2023-02-22 22:34:37 +08:00
&mut self,
2023-02-28 18:49:24 +08:00
_ranking_rule_idx: usize,
2023-03-23 16:15:57 +08:00
_ranking_rule: &dyn RankingRule<Q>,
2023-02-28 18:49:24 +08:00
_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
}