From 6fa4da8ae7cf7df6f78d9f11411a6a81b6625bc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Thu, 20 Jun 2024 12:58:51 +0200 Subject: [PATCH] Improve facet distribution speed in count mode --- .../search/facet/facet_distribution_iter.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/milli/src/search/facet/facet_distribution_iter.rs b/milli/src/search/facet/facet_distribution_iter.rs index 26b4ae80e..1e6ea8d88 100644 --- a/milli/src/search/facet/facet_distribution_iter.rs +++ b/milli/src/search/facet/facet_distribution_iter.rs @@ -1,6 +1,5 @@ use std::cmp::Reverse; use std::collections::BinaryHeap; -use std::io::Cursor; use std::ops::ControlFlow; use heed::Result; @@ -75,11 +74,8 @@ where // Represents the list of keys that we must explore. let mut heap = BinaryHeap::new(); - let highest_level = get_highest_level( - rtxn, - db.remap_key_type::>(), - field_id, - )?; + let db = db.remap_data_type::(); + let highest_level = get_highest_level(rtxn, db, field_id)?; if let Some(first_bound) = get_first_facet_value::(rtxn, db, field_id)? { // We first fill the heap with values from the highest level @@ -92,7 +88,10 @@ where if key.field_id != field_id { break; } - let intersection = value.bitmap & candidates; + let intersection = CboRoaringBitmapCodec::intersection_with_serialized( + value.bitmap_bytes, + candidates, + )?; let count = intersection.len(); if count != 0 { heap.push(LevelEntry { @@ -121,7 +120,10 @@ where if key.field_id != field_id { break; } - let intersection = value.bitmap & candidates; + let intersection = CboRoaringBitmapCodec::intersection_with_serialized( + value.bitmap_bytes, + candidates, + )?; let count = intersection.len(); if count != 0 { heap.push(LevelEntry {