From 3648abbfd566d18271c958881a5a464bb1ec73be Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Tue, 7 Jan 2025 15:26:09 +0100 Subject: [PATCH] Remove unused `FacetFieldIdOperation` --- .../milli/src/update/facet/new_incremental.rs | 17 -------- crates/milli/src/update/new/merger.rs | 39 ++++++------------- 2 files changed, 12 insertions(+), 44 deletions(-) diff --git a/crates/milli/src/update/facet/new_incremental.rs b/crates/milli/src/update/facet/new_incremental.rs index 6d5525fec..f132ebf19 100644 --- a/crates/milli/src/update/facet/new_incremental.rs +++ b/crates/milli/src/update/facet/new_incremental.rs @@ -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, } diff --git a/crates/milli/src/update/new/merger.rs b/crates/milli/src/update/new/merger.rs index 6f3fd35cb..090add6bd 100644 --- a/crates/milli/src/update/new/merger.rs +++ b/crates/milli/src/update/new/merger.rs @@ -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) } _ => (), }