mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-01-09 21:14:30 +01:00
Remove unused FacetFieldIdOperation
This commit is contained in:
parent
4d2433de12
commit
3648abbfd5
@ -474,21 +474,4 @@ impl FacetsUpdateIncrementalInner {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FacetFieldIdChange {
|
pub struct FacetFieldIdChange {
|
||||||
pub facet_value: Box<[u8]>,
|
pub facet_value: Box<[u8]>,
|
||||||
pub operation: FacetFieldIdOperation,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
|
||||||
pub enum FacetFieldIdOperation {
|
|
||||||
/// The docids have been modified for an existing facet value
|
|
||||||
///
|
|
||||||
/// The modification must be propagated to upper levels, without changing the structure of the tree
|
|
||||||
InPlace,
|
|
||||||
/// A new value has been inserted
|
|
||||||
///
|
|
||||||
/// The modification must be propagated to upper levels, splitting nodes and adding new levels as necessary.
|
|
||||||
Insert,
|
|
||||||
/// An existing value has been deleted
|
|
||||||
///
|
|
||||||
/// The modification must be propagated to upper levels, merging nodes and removing levels as necessary.
|
|
||||||
Remove,
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ use super::extract::{
|
|||||||
merge_caches_sorted, transpose_and_freeze_caches, BalancedCaches, DelAddRoaringBitmap,
|
merge_caches_sorted, transpose_and_freeze_caches, BalancedCaches, DelAddRoaringBitmap,
|
||||||
FacetKind, GeoExtractorData,
|
FacetKind, GeoExtractorData,
|
||||||
};
|
};
|
||||||
use crate::update::facet::new_incremental::{FacetFieldIdChange, FacetFieldIdOperation};
|
use crate::update::facet::new_incremental::FacetFieldIdChange;
|
||||||
use crate::{CboRoaringBitmapCodec, FieldId, GeoPoint, Index, InternalError, Result};
|
use crate::{CboRoaringBitmapCodec, FieldId, GeoPoint, Index, InternalError, Result};
|
||||||
|
|
||||||
#[tracing::instrument(level = "trace", skip_all, target = "indexing::merge")]
|
#[tracing::instrument(level = "trace", skip_all, target = "indexing::merge")]
|
||||||
@ -118,17 +118,12 @@ pub fn merge_and_send_facet_docids<'extractor>(
|
|||||||
let current = database.get_cbo_roaring_bytes_value(&rtxn, key)?;
|
let current = database.get_cbo_roaring_bytes_value(&rtxn, key)?;
|
||||||
match merge_cbo_bitmaps(current, del, add)? {
|
match merge_cbo_bitmaps(current, del, add)? {
|
||||||
Operation::Write(bitmap) => {
|
Operation::Write(bitmap) => {
|
||||||
let operation = if current.is_some() {
|
facet_field_ids_delta.register_from_key(key);
|
||||||
FacetFieldIdOperation::InPlace
|
|
||||||
} else {
|
|
||||||
FacetFieldIdOperation::Insert
|
|
||||||
};
|
|
||||||
facet_field_ids_delta.register_from_key(key, operation);
|
|
||||||
docids_sender.write(key, &bitmap)?;
|
docids_sender.write(key, &bitmap)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Operation::Delete => {
|
Operation::Delete => {
|
||||||
facet_field_ids_delta.register_from_key(key, FacetFieldIdOperation::Remove);
|
facet_field_ids_delta.register_from_key(key);
|
||||||
docids_sender.delete(key)?;
|
docids_sender.delete(key)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -177,14 +172,14 @@ pub enum FacetFieldIdDelta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl FacetFieldIdDelta {
|
impl FacetFieldIdDelta {
|
||||||
fn push(&mut self, facet_value: &[u8], operation: FacetFieldIdOperation, max_count: usize) {
|
fn push(&mut self, facet_value: &[u8], max_count: usize) {
|
||||||
*self = match std::mem::replace(self, FacetFieldIdDelta::Bulk) {
|
*self = match std::mem::replace(self, FacetFieldIdDelta::Bulk) {
|
||||||
FacetFieldIdDelta::Bulk => FacetFieldIdDelta::Bulk,
|
FacetFieldIdDelta::Bulk => FacetFieldIdDelta::Bulk,
|
||||||
FacetFieldIdDelta::Incremental(mut v) => {
|
FacetFieldIdDelta::Incremental(mut v) => {
|
||||||
if v.len() >= max_count {
|
if v.len() >= max_count {
|
||||||
FacetFieldIdDelta::Bulk
|
FacetFieldIdDelta::Bulk
|
||||||
} else {
|
} else {
|
||||||
v.push(FacetFieldIdChange { facet_value: facet_value.into(), operation });
|
v.push(FacetFieldIdChange { facet_value: facet_value.into() });
|
||||||
FacetFieldIdDelta::Incremental(v)
|
FacetFieldIdDelta::Incremental(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -231,38 +226,28 @@ impl FacetFieldIdsDelta {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_facet_string_id(
|
fn register_facet_string_id(&mut self, field_id: FieldId, facet_value: &[u8]) {
|
||||||
&mut self,
|
|
||||||
field_id: FieldId,
|
|
||||||
facet_value: &[u8],
|
|
||||||
operation: FacetFieldIdOperation,
|
|
||||||
) {
|
|
||||||
self.modified_facet_string_ids
|
self.modified_facet_string_ids
|
||||||
.entry(field_id)
|
.entry(field_id)
|
||||||
.or_insert(FacetFieldIdDelta::Incremental(Default::default()))
|
.or_insert(FacetFieldIdDelta::Incremental(Default::default()))
|
||||||
.push(facet_value, operation, self.max_string_count);
|
.push(facet_value, self.max_string_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_facet_number_id(
|
fn register_facet_number_id(&mut self, field_id: FieldId, facet_value: &[u8]) {
|
||||||
&mut self,
|
|
||||||
field_id: FieldId,
|
|
||||||
facet_value: &[u8],
|
|
||||||
operation: FacetFieldIdOperation,
|
|
||||||
) {
|
|
||||||
self.modified_facet_number_ids
|
self.modified_facet_number_ids
|
||||||
.entry(field_id)
|
.entry(field_id)
|
||||||
.or_insert(FacetFieldIdDelta::Incremental(Default::default()))
|
.or_insert(FacetFieldIdDelta::Incremental(Default::default()))
|
||||||
.push(facet_value, operation, self.max_number_count);
|
.push(facet_value, self.max_number_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_from_key(&mut self, key: &[u8], operation: FacetFieldIdOperation) {
|
fn register_from_key(&mut self, key: &[u8]) {
|
||||||
let (facet_kind, field_id, facet_value) = self.extract_key_data(key);
|
let (facet_kind, field_id, facet_value) = self.extract_key_data(key);
|
||||||
match (facet_kind, facet_value) {
|
match (facet_kind, facet_value) {
|
||||||
(FacetKind::Number, Some(facet_value)) => {
|
(FacetKind::Number, Some(facet_value)) => {
|
||||||
self.register_facet_number_id(field_id, facet_value, operation)
|
self.register_facet_number_id(field_id, facet_value)
|
||||||
}
|
}
|
||||||
(FacetKind::String, Some(facet_value)) => {
|
(FacetKind::String, Some(facet_value)) => {
|
||||||
self.register_facet_string_id(field_id, facet_value, operation)
|
self.register_facet_string_id(field_id, facet_value)
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user