Remove unused FacetFieldIdOperation

This commit is contained in:
Louis Dureuil 2025-01-07 15:26:09 +01:00
parent 4d2433de12
commit 3648abbfd5
No known key found for this signature in database
2 changed files with 12 additions and 44 deletions

View File

@ -474,21 +474,4 @@ impl FacetsUpdateIncrementalInner {
#[derive(Debug)]
pub struct FacetFieldIdChange {
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,
}

View File

@ -12,7 +12,7 @@ use super::extract::{
merge_caches_sorted, transpose_and_freeze_caches, BalancedCaches, DelAddRoaringBitmap,
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};
#[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)?;
match merge_cbo_bitmaps(current, del, add)? {
Operation::Write(bitmap) => {
let operation = if current.is_some() {
FacetFieldIdOperation::InPlace
} else {
FacetFieldIdOperation::Insert
};
facet_field_ids_delta.register_from_key(key, operation);
facet_field_ids_delta.register_from_key(key);
docids_sender.write(key, &bitmap)?;
Ok(())
}
Operation::Delete => {
facet_field_ids_delta.register_from_key(key, FacetFieldIdOperation::Remove);
facet_field_ids_delta.register_from_key(key);
docids_sender.delete(key)?;
Ok(())
}
@ -177,14 +172,14 @@ pub enum 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) {
FacetFieldIdDelta::Bulk => FacetFieldIdDelta::Bulk,
FacetFieldIdDelta::Incremental(mut v) => {
if v.len() >= max_count {
FacetFieldIdDelta::Bulk
} else {
v.push(FacetFieldIdChange { facet_value: facet_value.into(), operation });
v.push(FacetFieldIdChange { facet_value: facet_value.into() });
FacetFieldIdDelta::Incremental(v)
}
}
@ -231,38 +226,28 @@ impl FacetFieldIdsDelta {
}
}
fn register_facet_string_id(
&mut self,
field_id: FieldId,
facet_value: &[u8],
operation: FacetFieldIdOperation,
) {
fn register_facet_string_id(&mut self, field_id: FieldId, facet_value: &[u8]) {
self.modified_facet_string_ids
.entry(field_id)
.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(
&mut self,
field_id: FieldId,
facet_value: &[u8],
operation: FacetFieldIdOperation,
) {
fn register_facet_number_id(&mut self, field_id: FieldId, facet_value: &[u8]) {
self.modified_facet_number_ids
.entry(field_id)
.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);
match (facet_kind, 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)) => {
self.register_facet_string_id(field_id, facet_value, operation)
self.register_facet_string_id(field_id, facet_value)
}
_ => (),
}