MultiOps trait for OR operations

This commit is contained in:
Clément Renault 2024-06-04 15:01:26 -04:00
parent cb765ad249
commit 531e3d7d6a
No known key found for this signature in database
GPG Key ID: F250A4C4E3AE5F5F

View File

@ -4,7 +4,7 @@ use std::ops::Bound::{self, Excluded, Included};
use either::Either; use either::Either;
pub use filter_parser::{Condition, Error as FPError, FilterCondition, Token}; pub use filter_parser::{Condition, Error as FPError, FilterCondition, Token};
use roaring::RoaringBitmap; use roaring::{MultiOps, RoaringBitmap};
use serde_json::Value; use serde_json::Value;
use super::facet_range_search; use super::facet_range_search;
@ -382,14 +382,10 @@ impl<'a> Filter<'a> {
}))? }))?
} }
} }
FilterCondition::Or(subfilters) => { FilterCondition::Or(subfilters) => subfilters
let mut bitmap = RoaringBitmap::new(); .iter()
for f in subfilters { .map(|f| Self::inner_evaluate(&(f.clone()).into(), rtxn, index, filterable_fields))
bitmap |= .union(),
Self::inner_evaluate(&(f.clone()).into(), rtxn, index, filterable_fields)?;
}
Ok(bitmap)
}
FilterCondition::And(subfilters) => { FilterCondition::And(subfilters) => {
let mut subfilters_iter = subfilters.iter(); let mut subfilters_iter = subfilters.iter();
if let Some(first_subfilter) = subfilters_iter.next() { if let Some(first_subfilter) = subfilters_iter.next() {