mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-31 10:50:03 +00:00
Replace EdgeCondition with an Option<..> + other code cleanup
This commit is contained in:
@ -7,7 +7,6 @@ use crate::search::new::interner::{DedupInterner, Interned};
|
||||
use crate::search::new::query_graph::QueryNodeData;
|
||||
use crate::search::new::query_term::{LocatedQueryTerm, Phrase, QueryTerm};
|
||||
use crate::search::new::ranking_rule_graph::proximity::WordPair;
|
||||
use crate::search::new::ranking_rule_graph::EdgeCondition;
|
||||
use crate::search::new::{QueryNode, SearchContext};
|
||||
use crate::Result;
|
||||
use heed::RoTxn;
|
||||
@ -40,7 +39,7 @@ pub fn build_edges<'ctx>(
|
||||
conditions_interner: &mut DedupInterner<ProximityCondition>,
|
||||
from_node: &QueryNode,
|
||||
to_node: &QueryNode,
|
||||
) -> Result<Vec<(u8, EdgeCondition<ProximityCondition>)>> {
|
||||
) -> Result<Vec<(u8, Option<Interned<ProximityCondition>>)>> {
|
||||
let SearchContext {
|
||||
index,
|
||||
txn,
|
||||
@ -52,7 +51,7 @@ pub fn build_edges<'ctx>(
|
||||
} = ctx;
|
||||
|
||||
let right_term = match &to_node.data {
|
||||
QueryNodeData::End => return Ok(vec![(0, EdgeCondition::Unconditional)]),
|
||||
QueryNodeData::End => return Ok(vec![(0, None)]),
|
||||
QueryNodeData::Deleted | QueryNodeData::Start => return Ok(vec![]),
|
||||
QueryNodeData::Term(term) => term,
|
||||
};
|
||||
@ -70,7 +69,7 @@ pub fn build_edges<'ctx>(
|
||||
QueryNodeData::Start => {
|
||||
return Ok(vec![(
|
||||
(right_ngram_length - 1) as u8,
|
||||
EdgeCondition::Conditional(
|
||||
Some(
|
||||
conditions_interner
|
||||
.insert(ProximityCondition::Term { term: *right_term_interned }),
|
||||
),
|
||||
@ -88,7 +87,7 @@ pub fn build_edges<'ctx>(
|
||||
// but `sun` and `are` have no proximity condition between them
|
||||
return Ok(vec![(
|
||||
(right_ngram_length - 1) as u8,
|
||||
EdgeCondition::Conditional(
|
||||
Some(
|
||||
conditions_interner.insert(ProximityCondition::Term { term: *right_term_interned }),
|
||||
),
|
||||
)]);
|
||||
@ -140,7 +139,7 @@ pub fn build_edges<'ctx>(
|
||||
.map(|(cost, word_pairs)| {
|
||||
(
|
||||
cost,
|
||||
EdgeCondition::Conditional(
|
||||
Some(
|
||||
conditions_interner
|
||||
.insert(ProximityCondition::Pairs { pairs: word_pairs.into_boxed_slice() }),
|
||||
),
|
||||
@ -149,9 +148,7 @@ pub fn build_edges<'ctx>(
|
||||
.collect::<Vec<_>>();
|
||||
new_edges.push((
|
||||
8 + (right_ngram_length - 1) as u8,
|
||||
EdgeCondition::Conditional(
|
||||
conditions_interner.insert(ProximityCondition::Term { term: *right_term_interned }),
|
||||
),
|
||||
Some(conditions_interner.insert(ProximityCondition::Term { term: *right_term_interned })),
|
||||
));
|
||||
Ok(new_edges)
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ use std::iter::FromIterator;
|
||||
|
||||
use roaring::RoaringBitmap;
|
||||
|
||||
use super::empty_paths_cache::DeadEndPathCache;
|
||||
use super::{EdgeCondition, RankingRuleGraph, RankingRuleGraphTrait};
|
||||
use super::dead_end_path_cache::DeadEndPathCache;
|
||||
use super::{RankingRuleGraph, RankingRuleGraphTrait};
|
||||
use crate::search::new::interner::{DedupInterner, Interned, MappedInterner};
|
||||
use crate::search::new::logger::SearchLogger;
|
||||
use crate::search::new::query_term::{Phrase, QueryTerm};
|
||||
@ -60,20 +60,20 @@ impl RankingRuleGraphTrait for ProximityGraph {
|
||||
conditions_interner: &mut DedupInterner<Self::EdgeCondition>,
|
||||
source_node: &QueryNode,
|
||||
dest_node: &QueryNode,
|
||||
) -> Result<Vec<(u8, EdgeCondition<Self::EdgeCondition>)>> {
|
||||
) -> Result<Vec<(u8, Option<Interned<Self::EdgeCondition>>)>> {
|
||||
build::build_edges(ctx, conditions_interner, source_node, dest_node)
|
||||
}
|
||||
|
||||
fn log_state(
|
||||
graph: &RankingRuleGraph<Self>,
|
||||
paths: &[Vec<Interned<ProximityCondition>>],
|
||||
empty_paths_cache: &DeadEndPathCache<Self>,
|
||||
dead_end_path_cache: &DeadEndPathCache<Self>,
|
||||
universe: &RoaringBitmap,
|
||||
distances: &MappedInterner<Vec<(u16, SmallBitmap<ProximityCondition>)>, QueryNode>,
|
||||
cost: u16,
|
||||
logger: &mut dyn SearchLogger<QueryGraph>,
|
||||
) {
|
||||
logger.log_proximity_state(graph, paths, empty_paths_cache, universe, distances, cost);
|
||||
logger.log_proximity_state(graph, paths, dead_end_path_cache, universe, distances, cost);
|
||||
}
|
||||
|
||||
fn label_for_edge_condition<'ctx>(
|
||||
|
Reference in New Issue
Block a user