Modify the compute_query_term_subset_docids function to accept the universe

This commit is contained in:
Clément Renault 2024-06-21 11:43:04 +02:00
parent 2099b4f0dd
commit 50a7393c55
No known key found for this signature in database
GPG Key ID: F250A4C4E3AE5F5F
6 changed files with 11 additions and 14 deletions

View File

@ -302,7 +302,7 @@ impl QueryGraph {
for (_, node) in self.nodes.iter() {
match &node.data {
QueryNodeData::Term(t) => {
let docids = compute_query_term_subset_docids(ctx, &t.term_subset)?;
let docids = compute_query_term_subset_docids(ctx, None, &t.term_subset)?;
for id in t.term_ids.clone() {
term_docids
.entry(id)

View File

@ -59,7 +59,7 @@ impl RankingRuleGraphTrait for ExactnessGraph {
}
ExactnessCondition::Any(dest_node) => {
let docids =
universe & compute_query_term_subset_docids(ctx, &dest_node.term_subset)?;
compute_query_term_subset_docids(ctx, Some(universe), &dest_node.term_subset)?;
(docids, dest_node.clone())
}
};

View File

@ -22,10 +22,8 @@ pub fn compute_docids(
(left_term, right_term, *cost)
}
ProximityCondition::Term { term } => {
let mut docids = compute_query_term_subset_docids(ctx, &term.term_subset)?;
docids &= universe;
return Ok(ComputedCondition {
docids,
docids: compute_query_term_subset_docids(ctx, Some(universe), &term.term_subset)?,
universe_len: universe.len(),
start_term_subset: None,
end_term_subset: term.clone(),

View File

@ -27,8 +27,7 @@ impl RankingRuleGraphTrait for TypoGraph {
) -> Result<ComputedCondition> {
let TypoCondition { term, .. } = condition;
// maybe compute_query_term_subset_docids should accept a universe as argument
let mut docids = compute_query_term_subset_docids(ctx, &term.term_subset)?;
docids &= universe;
let docids = compute_query_term_subset_docids(ctx, Some(universe), &term.term_subset)?;
Ok(ComputedCondition {
docids,

View File

@ -26,8 +26,7 @@ impl RankingRuleGraphTrait for WordsGraph {
) -> Result<ComputedCondition> {
let WordsCondition { term, .. } = condition;
// maybe compute_query_term_subset_docids should accept a universe as argument
let mut docids = compute_query_term_subset_docids(ctx, &term.term_subset)?;
docids &= universe;
let docids = compute_query_term_subset_docids(ctx, Some(universe), &term.term_subset)?;
Ok(ComputedCondition {
docids,

View File

@ -31,6 +31,7 @@ impl<'ctx> SearchContext<'ctx> {
}
pub fn compute_query_term_subset_docids(
ctx: &mut SearchContext<'_>,
universe: Option<&RoaringBitmap>,
term: &QueryTermSubset,
) -> Result<RoaringBitmap> {
let mut docids = RoaringBitmap::new();
@ -49,7 +50,10 @@ pub fn compute_query_term_subset_docids(
}
}
Ok(docids)
match universe {
Some(universe) => Ok(docids & universe),
None => Ok(docids),
}
}
pub fn compute_query_term_subset_docids_within_field_id(
@ -147,10 +151,7 @@ pub fn compute_query_graph_docids(
term_subset,
positions: _,
term_ids: _,
}) => {
let node_docids = compute_query_term_subset_docids(ctx, term_subset)?;
predecessors_docids & node_docids
}
}) => compute_query_term_subset_docids(ctx, Some(&predecessors_docids), term_subset)?,
QueryNodeData::Deleted => {
panic!()
}