diff --git a/milli/src/search/facet/facet_distribution_iter.rs b/milli/src/search/facet/facet_distribution_iter.rs index a8aa1a006..26b4ae80e 100644 --- a/milli/src/search/facet/facet_distribution_iter.rs +++ b/milli/src/search/facet/facet_distribution_iter.rs @@ -1,14 +1,17 @@ use std::cmp::Reverse; use std::collections::BinaryHeap; +use std::io::Cursor; use std::ops::ControlFlow; use heed::Result; use roaring::RoaringBitmap; use super::{get_first_facet_value, get_highest_level}; -use crate::heed_codec::facet::{FacetGroupKey, FacetGroupKeyCodec, FacetGroupValueCodec}; +use crate::heed_codec::facet::{ + FacetGroupKey, FacetGroupKeyCodec, FacetGroupLazyValueCodec, FacetGroupValueCodec, +}; use crate::heed_codec::BytesRefCodec; -use crate::DocumentId; +use crate::{CboRoaringBitmapCodec, DocumentId}; /// Call the given closure on the facet distribution of the candidate documents. /// @@ -31,12 +34,9 @@ pub fn lexicographically_iterate_over_facet_distribution<'t, CB>( where CB: FnMut(&'t [u8], u64, DocumentId) -> Result>, { + let db = db.remap_data_type::(); let mut fd = LexicographicFacetDistribution { rtxn, db, field_id, callback }; - let highest_level = get_highest_level( - rtxn, - db.remap_key_type::>(), - field_id, - )?; + let highest_level = get_highest_level(rtxn, db, field_id)?; if let Some(first_bound) = get_first_facet_value::(rtxn, db, field_id)? { fd.iterate(candidates, highest_level, first_bound, usize::MAX)?; @@ -146,7 +146,7 @@ where CB: FnMut(&'t [u8], u64, DocumentId) -> Result>, { rtxn: &'t heed::RoTxn<'t>, - db: heed::Database, FacetGroupValueCodec>, + db: heed::Database, FacetGroupLazyValueCodec>, field_id: u16, callback: CB, } @@ -171,7 +171,10 @@ where if key.field_id != self.field_id { return Ok(ControlFlow::Break(())); } - let docids_in_common = value.bitmap & candidates; + let docids_in_common = CboRoaringBitmapCodec::intersection_with_serialized( + value.bitmap_bytes, + candidates, + )?; if !docids_in_common.is_empty() { let any_docid_in_common = docids_in_common.min().unwrap(); match (self.callback)(key.left_bound, docids_in_common.len(), any_docid_in_common)? @@ -205,7 +208,10 @@ where if key.field_id != self.field_id { return Ok(ControlFlow::Break(())); } - let docids_in_common = value.bitmap & candidates; + let docids_in_common = CboRoaringBitmapCodec::intersection_with_serialized( + value.bitmap_bytes, + candidates, + )?; if !docids_in_common.is_empty() { let cf = self.iterate( &docids_in_common,