Use MultiOps for resolve_query_graph

This commit is contained in:
Louis Dureuil 2023-05-02 18:54:09 +02:00
parent 75819bc940
commit fdc1763838
No known key found for this signature in database

View File

@ -3,7 +3,7 @@
use std::collections::VecDeque; use std::collections::VecDeque;
use fxhash::FxHashMap; use fxhash::FxHashMap;
use roaring::RoaringBitmap; use roaring::{MultiOps, RoaringBitmap};
use super::interner::Interned; use super::interner::Interned;
use super::query_graph::QueryNodeData; use super::query_graph::QueryNodeData;
@ -126,6 +126,7 @@ pub fn compute_query_term_subset_docids_within_position(
Ok(docids) Ok(docids)
} }
/// Returns the subset of the input universe that satisfies the contraints of the input query graph.
pub fn compute_query_graph_docids( pub fn compute_query_graph_docids(
ctx: &mut SearchContext, ctx: &mut SearchContext,
q: &QueryGraph, q: &QueryGraph,
@ -148,10 +149,8 @@ pub fn compute_query_graph_docids(
continue; continue;
} }
// Take union of all predecessors // Take union of all predecessors
let mut predecessors_docids = RoaringBitmap::new(); let predecessors_docids =
for p in predecessors.iter() { MultiOps::union(predecessors.iter().map(|p| path_nodes_docids.get(p)));
predecessors_docids |= path_nodes_docids.get(p);
}
let node_docids = match &node.data { let node_docids = match &node.data {
QueryNodeData::Term(LocatedQueryTermSubset { QueryNodeData::Term(LocatedQueryTermSubset {