diff --git a/columnar/benches/bench_access.rs b/columnar/benches/bench_access.rs index 397a35af0..e82e8cd78 100644 --- a/columnar/benches/bench_access.rs +++ b/columnar/benches/bench_access.rs @@ -43,26 +43,5 @@ fn bench_group(mut runner: InputGroup) { } black_box(sum); }); - runner.register("access_first_vals", |column| { - let mut sum = 0; - const BLOCK_SIZE: usize = 32; - let mut docs = vec![0; BLOCK_SIZE]; - let mut buffer = vec![None; BLOCK_SIZE]; - for i in (0..NUM_DOCS).step_by(BLOCK_SIZE) { - // fill docs - #[allow(clippy::needless_range_loop)] - for idx in 0..BLOCK_SIZE { - docs[idx] = idx as u32 + i; - } - - column.first_vals(&docs, &mut buffer); - for val in buffer.iter() { - let Some(val) = val else { continue }; - sum += *val; - } - } - - black_box(sum); - }); runner.run(); } diff --git a/columnar/src/column/mod.rs b/columnar/src/column/mod.rs index 306213826..c66ff31b9 100644 --- a/columnar/src/column/mod.rs +++ b/columnar/src/column/mod.rs @@ -14,7 +14,7 @@ pub use serialize::{ serialize_column_mappable_to_u128, }; -use crate::column_index::{ColumnIndex, Set}; +use crate::column_index::ColumnIndex; use crate::column_values::monotonic_mapping::StrictlyMonotonicMappingToInternal; use crate::column_values::{ColumnValues, monotonic_map_column}; use crate::{Cardinality, DocId, EmptyColumnValues, MonotonicallyMappableToU64, RowId}; @@ -89,31 +89,6 @@ impl Column { self.values_for_doc(row_id).next() } - /// Load the first value for each docid in the provided slice. - #[inline] - pub fn first_vals(&self, docids: &[DocId], output: &mut [Option]) { - match &self.index { - ColumnIndex::Empty { .. } => {} - ColumnIndex::Full => self.values.get_vals_opt(docids, output), - ColumnIndex::Optional(optional_index) => { - for (i, docid) in docids.iter().enumerate() { - output[i] = optional_index - .rank_if_exists(*docid) - .map(|rowid| self.values.get_val(rowid)); - } - } - ColumnIndex::Multivalued(multivalued_index) => { - for (i, docid) in docids.iter().enumerate() { - let range = multivalued_index.range(*docid); - let is_empty = range.start == range.end; - if !is_empty { - output[i] = Some(self.values.get_val(range.start)); - } - } - } - } - } - /// Translates a block of docids to row_ids. /// /// returns the row_ids and the matching docids on the same index @@ -131,6 +106,8 @@ impl Column { self.index.docids_to_rowids(doc_ids, doc_ids_out, row_ids) } + /// Get an iterator over the values for the provided docid. + #[inline] pub fn values_for_doc(&self, doc_id: DocId) -> impl Iterator + '_ { self.index .value_row_ids(doc_id) @@ -158,15 +135,6 @@ impl Column { .select_batch_in_place(selected_docid_range.start, doc_ids); } - /// Fills the output vector with the (possibly multiple values that are associated_with - /// `row_id`. - /// - /// This method clears the `output` vector. - pub fn fill_vals(&self, row_id: RowId, output: &mut Vec) { - output.clear(); - output.extend(self.values_for_doc(row_id)); - } - pub fn first_or_default_col(self, default_value: T) -> Arc> { Arc::new(FirstValueWithDefault { column: self, diff --git a/src/fastfield/mod.rs b/src/fastfield/mod.rs index 6db5ec6d9..db1ce0d77 100644 --- a/src/fastfield/mod.rs +++ b/src/fastfield/mod.rs @@ -726,22 +726,24 @@ mod tests { .column_opt::("multi_date") .unwrap() .unwrap(); - let mut dates = Vec::new(); { + let mut dates = Vec::new(); assert_eq!(date_fast_field.get_val(0).into_timestamp_nanos(), 1i64); - dates_fast_field.fill_vals(0u32, &mut dates); + dates.extend(dates_fast_field.values_for_doc(0)); assert_eq!(dates.len(), 2); assert_eq!(dates[0].into_timestamp_nanos(), 2i64); assert_eq!(dates[1].into_timestamp_nanos(), 3i64); } { + let mut dates = Vec::new(); assert_eq!(date_fast_field.get_val(1).into_timestamp_nanos(), 4i64); - dates_fast_field.fill_vals(1u32, &mut dates); + dates.extend(dates_fast_field.values_for_doc(1)); assert!(dates.is_empty()); } { + let mut dates = Vec::new(); assert_eq!(date_fast_field.get_val(2).into_timestamp_nanos(), 0i64); - dates_fast_field.fill_vals(2u32, &mut dates); + dates.extend(dates_fast_field.values_for_doc(2)); assert_eq!(dates.len(), 2); assert_eq!(dates[0].into_timestamp_nanos(), 5i64); assert_eq!(dates[1].into_timestamp_nanos(), 6i64);