diff --git a/milli/src/search/new/ranking_rule_graph/mod.rs b/milli/src/search/new/ranking_rule_graph/mod.rs index fb9a82d68..7c40008c8 100644 --- a/milli/src/search/new/ranking_rule_graph/mod.rs +++ b/milli/src/search/new/ranking_rule_graph/mod.rs @@ -17,32 +17,42 @@ mod typo; use std::hash::Hash; +pub use cheapest_paths::PathVisitor; pub use condition_docids_cache::ConditionDocIdsCache; pub use dead_ends_cache::DeadEndsCache; -use fxhash::FxHashSet; pub use proximity::{ProximityCondition, ProximityGraph}; use roaring::RoaringBitmap; pub use typo::{TypoCondition, TypoGraph}; use super::interner::{DedupInterner, FixedSizeInterner, Interned, MappedInterner}; use super::logger::SearchLogger; -use super::query_term::Phrase; +use super::query_term::LocatedQueryTermSubset; use super::small_bitmap::SmallBitmap; use super::{QueryGraph, QueryNode, SearchContext}; use crate::Result; +pub struct ComputedCondition { + pub docids: RoaringBitmap, + pub universe_len: u64, + pub start_term_subset: Option, + pub end_term_subset: LocatedQueryTermSubset, +} + /// An edge in the ranking rule graph. /// /// It contains: /// 1. The source and destination nodes /// 2. The cost of traversing this edge /// 3. The condition associated with it +/// 4. The list of nodes that have to be skipped +/// if this edge is traversed. #[derive(Clone)] pub struct Edge { pub source_node: Interned, pub dest_node: Interned, - pub cost: u8, + pub cost: u32, pub condition: Option>, + pub nodes_to_skip: SmallBitmap, } impl Hash for Edge { @@ -83,23 +93,23 @@ pub trait RankingRuleGraphTrait: Sized { ctx: &mut SearchContext, condition: &Self::Condition, universe: &RoaringBitmap, - ) -> Result<(RoaringBitmap, FxHashSet>, FxHashSet>)>; + ) -> Result; /// Return the costs and conditions of the edges going from the source node to the destination node fn build_edges( ctx: &mut SearchContext, conditions_interner: &mut DedupInterner, - source_node: &QueryNode, - dest_node: &QueryNode, - ) -> Result>)>>; + source_node: Option<&LocatedQueryTermSubset>, + dest_node: &LocatedQueryTermSubset, + ) -> Result)>>; fn log_state( graph: &RankingRuleGraph, paths: &[Vec>], dead_ends_cache: &DeadEndsCache, universe: &RoaringBitmap, - distances: &MappedInterner>, - cost: u16, + costs: &MappedInterner>, + cost: u64, logger: &mut dyn SearchLogger, ); }