mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 20:15:07 +08:00
Skip iterating over documents when the faceted field list doesn't change
This commit is contained in:
parent
17c5ceeb9d
commit
d29d4f88da
@ -66,11 +66,6 @@ pub fn extract_fid_docid_facet_values<R: io::Read + io::Seek>(
|
|||||||
max_memory.map(|m| m / 2),
|
max_memory.map(|m| m / 2),
|
||||||
);
|
);
|
||||||
|
|
||||||
let old_faceted_fids: BTreeSet<_> =
|
|
||||||
settings_diff.old.faceted_fields_ids.iter().copied().collect();
|
|
||||||
let new_faceted_fids: BTreeSet<_> =
|
|
||||||
settings_diff.new.faceted_fields_ids.iter().copied().collect();
|
|
||||||
|
|
||||||
// The tuples represents the Del and Add side for a bitmap
|
// The tuples represents the Del and Add side for a bitmap
|
||||||
let mut facet_exists_docids = BTreeMap::<FieldId, (RoaringBitmap, RoaringBitmap)>::new();
|
let mut facet_exists_docids = BTreeMap::<FieldId, (RoaringBitmap, RoaringBitmap)>::new();
|
||||||
let mut facet_is_null_docids = BTreeMap::<FieldId, (RoaringBitmap, RoaringBitmap)>::new();
|
let mut facet_is_null_docids = BTreeMap::<FieldId, (RoaringBitmap, RoaringBitmap)>::new();
|
||||||
@ -80,6 +75,12 @@ pub fn extract_fid_docid_facet_values<R: io::Read + io::Seek>(
|
|||||||
let mut numbers_key_buffer = Vec::new();
|
let mut numbers_key_buffer = Vec::new();
|
||||||
let mut strings_key_buffer = Vec::new();
|
let mut strings_key_buffer = Vec::new();
|
||||||
|
|
||||||
|
let old_faceted_fids: BTreeSet<_> =
|
||||||
|
settings_diff.old.faceted_fields_ids.iter().copied().collect();
|
||||||
|
let new_faceted_fids: BTreeSet<_> =
|
||||||
|
settings_diff.new.faceted_fields_ids.iter().copied().collect();
|
||||||
|
|
||||||
|
if !settings_diff.settings_update_only || old_faceted_fids != new_faceted_fids {
|
||||||
let mut cursor = obkv_documents.into_cursor()?;
|
let mut cursor = obkv_documents.into_cursor()?;
|
||||||
while let Some((docid_bytes, value)) = cursor.move_on_next()? {
|
while let Some((docid_bytes, value)) = cursor.move_on_next()? {
|
||||||
let obkv = obkv::KvReader::new(value);
|
let obkv = obkv::KvReader::new(value);
|
||||||
@ -93,7 +94,9 @@ pub fn extract_fid_docid_facet_values<R: io::Read + io::Seek>(
|
|||||||
};
|
};
|
||||||
// iterate over the faceted fields instead of over the whole document.
|
// iterate over the faceted fields instead of over the whole document.
|
||||||
for eob in
|
for eob in
|
||||||
merge_join_by(old_faceted_fids.iter(), new_faceted_fids.iter(), |old, new| old.cmp(new))
|
merge_join_by(old_faceted_fids.iter(), new_faceted_fids.iter(), |old, new| {
|
||||||
|
old.cmp(new)
|
||||||
|
})
|
||||||
{
|
{
|
||||||
let (field_id, del_value, add_value) = match eob {
|
let (field_id, del_value, add_value) = match eob {
|
||||||
EitherOrBoth::Left(&field_id) => {
|
EitherOrBoth::Left(&field_id) => {
|
||||||
@ -253,6 +256,7 @@ pub fn extract_fid_docid_facet_values<R: io::Read + io::Seek>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut buffer = Vec::new();
|
let mut buffer = Vec::new();
|
||||||
let mut facet_exists_docids_writer = create_writer(
|
let mut facet_exists_docids_writer = create_writer(
|
||||||
|
Loading…
Reference in New Issue
Block a user