Rename lifetime

This commit is contained in:
Loïc Lecrenier
2023-03-13 14:03:48 +01:00
parent 1c58cf8426
commit 14e8d0aaa2
18 changed files with 177 additions and 213 deletions

View File

@ -7,6 +7,12 @@ use crate::search::new::{QueryGraph, SearchContext};
use crate::Result;
impl<G: RankingRuleGraphTrait> RankingRuleGraph<G> {
// TODO: here, the docids of all the edges should already be computed!
// an edge condition would then be reduced to a (ptr to) a roaring bitmap?
// we could build fewer of them by directly comparing them with the universe
// (e.g. for each word pairs?) with `deserialize_within_universe` maybe
//
/// Build the ranking rule graph from the given query graph
pub fn build(ctx: &mut SearchContext, query_graph: QueryGraph) -> Result<Self> {
let QueryGraph { nodes: graph_nodes, edges: graph_edges, .. } = &query_graph;

View File

@ -24,9 +24,9 @@ impl<G: RankingRuleGraphTrait> EdgeConditionsCache<G> {
///
/// If the cache does not yet contain these docids, they are computed
/// and inserted in the cache.
pub fn get_edge_docids<'s, 'search>(
pub fn get_edge_docids<'s, 'ctx>(
&'s mut self,
ctx: &mut SearchContext<'search>,
ctx: &mut SearchContext<'ctx>,
// TODO: should be Interned<EdgeCondition>
interned_edge_condition: Interned<G::EdgeCondition>,
graph: &RankingRuleGraph<G>,

View File

@ -69,47 +69,6 @@ pub struct Edge<E> {
pub condition: EdgeCondition<E>,
}
// pub struct SubWordDerivations {
// words: FxHashSet<Interned<String>>,
// phrases: FxHashSet<Interned<Phrase>>,
// use_prefix_db: bool,
// }
// pub struct EdgeWordDerivations {
// // TODO: not Option, instead: Any | All | Subset(SubWordDerivations)
// from_words: Option<SubWordDerivations>, // ???
// to_words: Option<SubWordDerivations>, // + use prefix db?
// }
// fn aggregate_edge_word_derivations(
// graph: (),
// edges: Vec<usize>,
// ) -> BTreeMap<usize, SubWordDerivations> {
// todo!()
// }
// fn reduce_word_term_to_sub_word_derivations(
// term: &mut WordDerivations,
// derivations: &SubWordDerivations,
// ) {
// let mut new_one_typo = vec![];
// for w in term.one_typo {
// if derivations.words.contains(w) {
// new_one_typo.push(w);
// }
// }
// if term.use_prefix_db && !derivations.use_prefix_db {
// term.use_prefix_db = false;
// }
// // etc.
// }
// fn word_derivations_used_by_edge<G: RankingRuleGraphTrait>(
// edge: G::EdgeCondition,
// ) -> SubWordDerivations {
// todo!()
// }
/// A trait to be implemented by a marker type to build a graph-based ranking rule.
///
/// It mostly describes how to:
@ -132,8 +91,8 @@ pub trait RankingRuleGraphTrait: Sized {
/// Compute the document ids associated with the given edge condition,
/// restricted to the given universe.
fn resolve_edge_condition<'search>(
ctx: &mut SearchContext<'search>,
fn resolve_edge_condition<'ctx>(
ctx: &mut SearchContext<'ctx>,
edge_condition: &Self::EdgeCondition,
universe: &RoaringBitmap,
) -> Result<RoaringBitmap>;
@ -142,15 +101,15 @@ pub trait RankingRuleGraphTrait: Sized {
///
/// This call is followed by zero, one or more calls to [`build_step_visit_destination_node`](RankingRuleGraphTrait::build_step_visit_destination_node),
/// which builds the actual edges.
fn build_step_visit_source_node<'search>(
ctx: &mut SearchContext<'search>,
fn build_step_visit_source_node<'ctx>(
ctx: &mut SearchContext<'ctx>,
source_node: &QueryNode,
) -> Result<Option<Self::BuildVisitedFromNode>>;
/// Return the cost and condition of the edges going from the previously visited node
/// (with [`build_step_visit_source_node`](RankingRuleGraphTrait::build_step_visit_source_node)) to `dest_node`.
fn build_step_visit_destination_node<'from_data, 'search: 'from_data>(
ctx: &mut SearchContext<'search>,
fn build_step_visit_destination_node<'from_data, 'ctx: 'from_data>(
ctx: &mut SearchContext<'ctx>,
conditions_interner: &mut Interner<Self::EdgeCondition>,
dest_node: &QueryNode,
source_node_data: &'from_data Self::BuildVisitedFromNode,
@ -177,16 +136,16 @@ pub struct RankingRuleGraph<G: RankingRuleGraphTrait> {
pub edges_of_node: Vec<SmallBitmap>,
pub conditions_interner: Interner<G::EdgeCondition>,
}
// impl<G: RankingRuleGraphTrait> Clone for RankingRuleGraph<G> {
// fn clone(&self) -> Self {
// Self {
// query_graph: self.query_graph.clone(),
// edges_store: self.edges_store.clone(),
// edges_of_node: self.edges_of_node.clone(),
// conditions_interner: self.conditions_interner.clone(),
// }
// }
// }
impl<G: RankingRuleGraphTrait> Clone for RankingRuleGraph<G> {
fn clone(&self) -> Self {
Self {
query_graph: self.query_graph.clone(),
edges_store: self.edges_store.clone(),
edges_of_node: self.edges_of_node.clone(),
conditions_interner: self.conditions_interner.clone(),
}
}
}
impl<G: RankingRuleGraphTrait> RankingRuleGraph<G> {
/// Remove the given edge from the ranking rule graph
pub fn remove_ranking_rule_edge(&mut self, edge_index: u16) {

View File

@ -58,8 +58,8 @@ pub fn visit_from_node(
}))
}
pub fn visit_to_node<'search, 'from_data>(
ctx: &mut SearchContext<'search>,
pub fn visit_to_node<'ctx, 'from_data>(
ctx: &mut SearchContext<'ctx>,
conditions_interner: &mut Interner<ProximityEdge>,
to_node: &QueryNode,
from_node_data: &'from_data (WordDerivations, i8),

View File

@ -4,8 +4,8 @@ use super::{ProximityEdge, WordPair};
use crate::search::new::SearchContext;
use crate::{CboRoaringBitmapCodec, Result};
pub fn compute_docids<'search>(
ctx: &mut SearchContext<'search>,
pub fn compute_docids<'ctx>(
ctx: &mut SearchContext<'ctx>,
edge: &ProximityEdge,
universe: &RoaringBitmap,
) -> Result<RoaringBitmap> {

View File

@ -36,23 +36,23 @@ impl RankingRuleGraphTrait for ProximityGraph {
format!(", prox {proximity}, {} pairs", pairs.len())
}
fn resolve_edge_condition<'search>(
ctx: &mut SearchContext<'search>,
fn resolve_edge_condition<'ctx>(
ctx: &mut SearchContext<'ctx>,
edge: &Self::EdgeCondition,
universe: &RoaringBitmap,
) -> Result<roaring::RoaringBitmap> {
compute_docids::compute_docids(ctx, edge, universe)
}
fn build_step_visit_source_node<'search>(
ctx: &mut SearchContext<'search>,
fn build_step_visit_source_node<'ctx>(
ctx: &mut SearchContext<'ctx>,
from_node: &QueryNode,
) -> Result<Option<Self::BuildVisitedFromNode>> {
build::visit_from_node(ctx, from_node)
}
fn build_step_visit_destination_node<'from_data, 'search: 'from_data>(
ctx: &mut SearchContext<'search>,
fn build_step_visit_destination_node<'from_data, 'ctx: 'from_data>(
ctx: &mut SearchContext<'ctx>,
conditions_interner: &mut Interner<Self::EdgeCondition>,
to_node: &QueryNode,
from_node_data: &'from_data Self::BuildVisitedFromNode,

View File

@ -28,8 +28,8 @@ impl RankingRuleGraphTrait for TypoGraph {
}
}
fn resolve_edge_condition<'db_cache, 'search>(
ctx: &mut SearchContext<'search>,
fn resolve_edge_condition<'db_cache, 'ctx>(
ctx: &mut SearchContext<'ctx>,
edge: &Self::EdgeCondition,
universe: &RoaringBitmap,
) -> Result<RoaringBitmap> {
@ -69,15 +69,15 @@ impl RankingRuleGraphTrait for TypoGraph {
}
}
fn build_step_visit_source_node<'search>(
_ctx: &mut SearchContext<'search>,
fn build_step_visit_source_node<'ctx>(
_ctx: &mut SearchContext<'ctx>,
_from_node: &QueryNode,
) -> Result<Option<Self::BuildVisitedFromNode>> {
Ok(Some(()))
}
fn build_step_visit_destination_node<'from_data, 'search: 'from_data>(
ctx: &mut SearchContext<'search>,
fn build_step_visit_destination_node<'from_data, 'ctx: 'from_data>(
ctx: &mut SearchContext<'ctx>,
conditions_interner: &mut Interner<Self::EdgeCondition>,
to_node: &QueryNode,
_from_node_data: &'from_data Self::BuildVisitedFromNode,