mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 06:44:27 +01:00
Rename facet distribution to be explicit on the order to find them
This commit is contained in:
parent
34a07110de
commit
84f8938f33
@ -136,7 +136,7 @@ impl<'a> FacetDistribution<'a> {
|
|||||||
candidates: &RoaringBitmap,
|
candidates: &RoaringBitmap,
|
||||||
distribution: &mut BTreeMap<String, u64>,
|
distribution: &mut BTreeMap<String, u64>,
|
||||||
) -> heed::Result<()> {
|
) -> heed::Result<()> {
|
||||||
facet_distribution_iter::iterate_over_facet_distribution(
|
facet_distribution_iter::lexicographically_iterate_over_facet_distribution(
|
||||||
self.rtxn,
|
self.rtxn,
|
||||||
self.index
|
self.index
|
||||||
.facet_id_f64_docids
|
.facet_id_f64_docids
|
||||||
@ -161,7 +161,7 @@ impl<'a> FacetDistribution<'a> {
|
|||||||
candidates: &RoaringBitmap,
|
candidates: &RoaringBitmap,
|
||||||
distribution: &mut BTreeMap<String, u64>,
|
distribution: &mut BTreeMap<String, u64>,
|
||||||
) -> heed::Result<()> {
|
) -> heed::Result<()> {
|
||||||
facet_distribution_iter::iterate_over_facet_distribution(
|
facet_distribution_iter::lexicographically_iterate_over_facet_distribution(
|
||||||
self.rtxn,
|
self.rtxn,
|
||||||
self.index
|
self.index
|
||||||
.facet_id_string_docids
|
.facet_id_string_docids
|
||||||
|
@ -19,7 +19,7 @@ use crate::DocumentId;
|
|||||||
///
|
///
|
||||||
/// The return value of the closure is a `ControlFlow<()>` which indicates whether we should
|
/// The return value of the closure is a `ControlFlow<()>` which indicates whether we should
|
||||||
/// keep iterating over the different facet values or stop.
|
/// keep iterating over the different facet values or stop.
|
||||||
pub fn iterate_over_facet_distribution<'t, CB>(
|
pub fn lexicographically_iterate_over_facet_distribution<'t, CB>(
|
||||||
rtxn: &'t heed::RoTxn<'t>,
|
rtxn: &'t heed::RoTxn<'t>,
|
||||||
db: heed::Database<FacetGroupKeyCodec<ByteSliceRefCodec>, FacetGroupValueCodec>,
|
db: heed::Database<FacetGroupKeyCodec<ByteSliceRefCodec>, FacetGroupValueCodec>,
|
||||||
field_id: u16,
|
field_id: u16,
|
||||||
@ -29,7 +29,7 @@ pub fn iterate_over_facet_distribution<'t, CB>(
|
|||||||
where
|
where
|
||||||
CB: FnMut(&'t [u8], u64, DocumentId) -> Result<ControlFlow<()>>,
|
CB: FnMut(&'t [u8], u64, DocumentId) -> Result<ControlFlow<()>>,
|
||||||
{
|
{
|
||||||
let mut fd = FacetDistribution { rtxn, db, field_id, callback };
|
let mut fd = LexicographicFacetDistribution { rtxn, db, field_id, callback };
|
||||||
let highest_level = get_highest_level(
|
let highest_level = get_highest_level(
|
||||||
rtxn,
|
rtxn,
|
||||||
db.remap_key_type::<FacetGroupKeyCodec<ByteSliceRefCodec>>(),
|
db.remap_key_type::<FacetGroupKeyCodec<ByteSliceRefCodec>>(),
|
||||||
@ -44,7 +44,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FacetDistribution<'t, CB>
|
struct LexicographicFacetDistribution<'t, CB>
|
||||||
where
|
where
|
||||||
CB: FnMut(&'t [u8], u64, DocumentId) -> Result<ControlFlow<()>>,
|
CB: FnMut(&'t [u8], u64, DocumentId) -> Result<ControlFlow<()>>,
|
||||||
{
|
{
|
||||||
@ -54,7 +54,7 @@ where
|
|||||||
callback: CB,
|
callback: CB,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'t, CB> FacetDistribution<'t, CB>
|
impl<'t, CB> LexicographicFacetDistribution<'t, CB>
|
||||||
where
|
where
|
||||||
CB: FnMut(&'t [u8], u64, DocumentId) -> Result<ControlFlow<()>>,
|
CB: FnMut(&'t [u8], u64, DocumentId) -> Result<ControlFlow<()>>,
|
||||||
{
|
{
|
||||||
@ -86,6 +86,7 @@ where
|
|||||||
}
|
}
|
||||||
Ok(ControlFlow::Continue(()))
|
Ok(ControlFlow::Continue(()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn iterate(
|
fn iterate(
|
||||||
&mut self,
|
&mut self,
|
||||||
candidates: &RoaringBitmap,
|
candidates: &RoaringBitmap,
|
||||||
@ -116,7 +117,7 @@ where
|
|||||||
value.size as usize,
|
value.size as usize,
|
||||||
)?;
|
)?;
|
||||||
match cf {
|
match cf {
|
||||||
ControlFlow::Continue(_) => {}
|
ControlFlow::Continue(_) => (),
|
||||||
ControlFlow::Break(_) => return Ok(ControlFlow::Break(())),
|
ControlFlow::Break(_) => return Ok(ControlFlow::Break(())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,7 +133,7 @@ mod tests {
|
|||||||
use heed::BytesDecode;
|
use heed::BytesDecode;
|
||||||
use roaring::RoaringBitmap;
|
use roaring::RoaringBitmap;
|
||||||
|
|
||||||
use super::iterate_over_facet_distribution;
|
use super::lexicographically_iterate_over_facet_distribution;
|
||||||
use crate::heed_codec::facet::OrderedF64Codec;
|
use crate::heed_codec::facet::OrderedF64Codec;
|
||||||
use crate::milli_snap;
|
use crate::milli_snap;
|
||||||
use crate::search::facet::tests::{get_random_looking_index, get_simple_index};
|
use crate::search::facet::tests::{get_random_looking_index, get_simple_index};
|
||||||
@ -144,7 +145,7 @@ mod tests {
|
|||||||
let txn = index.env.read_txn().unwrap();
|
let txn = index.env.read_txn().unwrap();
|
||||||
let candidates = (0..=255).collect::<RoaringBitmap>();
|
let candidates = (0..=255).collect::<RoaringBitmap>();
|
||||||
let mut results = String::new();
|
let mut results = String::new();
|
||||||
iterate_over_facet_distribution(
|
lexicographically_iterate_over_facet_distribution(
|
||||||
&txn,
|
&txn,
|
||||||
index.content,
|
index.content,
|
||||||
0,
|
0,
|
||||||
@ -161,6 +162,7 @@ mod tests {
|
|||||||
txn.commit().unwrap();
|
txn.commit().unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn filter_distribution_all_stop_early() {
|
fn filter_distribution_all_stop_early() {
|
||||||
let indexes = [get_simple_index(), get_random_looking_index()];
|
let indexes = [get_simple_index(), get_random_looking_index()];
|
||||||
@ -169,7 +171,7 @@ mod tests {
|
|||||||
let candidates = (0..=255).collect::<RoaringBitmap>();
|
let candidates = (0..=255).collect::<RoaringBitmap>();
|
||||||
let mut results = String::new();
|
let mut results = String::new();
|
||||||
let mut nbr_facets = 0;
|
let mut nbr_facets = 0;
|
||||||
iterate_over_facet_distribution(
|
lexicographically_iterate_over_facet_distribution(
|
||||||
&txn,
|
&txn,
|
||||||
index.content,
|
index.content,
|
||||||
0,
|
0,
|
||||||
|
Loading…
Reference in New Issue
Block a user