From 4c5249962263ba8010dc92ee8333d45a0d424e28 Mon Sep 17 00:00:00 2001 From: PSeitz Date: Fri, 29 Nov 2024 16:08:21 +0800 Subject: [PATCH] clippy (#2549) --- columnar/src/column_index/merge/shuffled.rs | 4 ++-- columnar/src/column_index/merge/stacked.rs | 2 +- columnar/src/column_index/optional_index/mod.rs | 10 +++++----- .../src/column_index/optional_index/set_block/dense.rs | 5 ++--- .../column_index/optional_index/set_block/sparse.rs | 4 ++-- columnar/src/column_index/serialize.rs | 2 +- columnar/src/column_values/merge.rs | 2 +- .../src/column_values/u64_based/blockwise_linear.rs | 2 +- columnar/src/columnar/merge/merge_dict_column.rs | 4 ++-- columnar/src/columnar/merge/term_merger.rs | 4 ++-- columnar/src/columnar/writer/serializer.rs | 4 ++-- columnar/src/iterable.rs | 2 +- common/src/writer.rs | 2 +- sstable/src/streamer.rs | 4 ++-- stacker/src/expull.rs | 2 +- tokenizer-api/src/lib.rs | 4 ++-- 16 files changed, 28 insertions(+), 29 deletions(-) diff --git a/columnar/src/column_index/merge/shuffled.rs b/columnar/src/column_index/merge/shuffled.rs index 9a985b4b9..b46669985 100644 --- a/columnar/src/column_index/merge/shuffled.rs +++ b/columnar/src/column_index/merge/shuffled.rs @@ -58,7 +58,7 @@ struct ShuffledIndex<'a> { merge_order: &'a ShuffleMergeOrder, } -impl<'a> Iterable for ShuffledIndex<'a> { +impl Iterable for ShuffledIndex<'_> { fn boxed_iter(&self) -> Box + '_> { Box::new( self.merge_order @@ -127,7 +127,7 @@ fn integrate_num_vals(num_vals: impl Iterator) -> impl Iterator Iterable for ShuffledMultivaluedIndex<'a> { +impl Iterable for ShuffledMultivaluedIndex<'_> { fn boxed_iter(&self) -> Box + '_> { let num_vals_per_row = iter_num_values(self.column_indexes, self.merge_order); Box::new(integrate_num_vals(num_vals_per_row)) diff --git a/columnar/src/column_index/merge/stacked.rs b/columnar/src/column_index/merge/stacked.rs index 9c0890abe..4a1a70375 100644 --- a/columnar/src/column_index/merge/stacked.rs +++ b/columnar/src/column_index/merge/stacked.rs @@ -123,7 +123,7 @@ fn get_num_values_iterator<'a>( } } -impl<'a> Iterable for StackedStartOffsets<'a> { +impl Iterable for StackedStartOffsets<'_> { fn boxed_iter(&self) -> Box + '_> { let num_values_it = (0..self.column_indexes.len()).flat_map(|columnar_id| { let num_docs = self.stack_merge_order.columnar_range(columnar_id).len() as u32; diff --git a/columnar/src/column_index/optional_index/mod.rs b/columnar/src/column_index/optional_index/mod.rs index 3960ffbec..f3ab523e2 100644 --- a/columnar/src/column_index/optional_index/mod.rs +++ b/columnar/src/column_index/optional_index/mod.rs @@ -86,7 +86,7 @@ pub struct OptionalIndex { block_metas: Arc<[BlockMeta]>, } -impl<'a> Iterable for &'a OptionalIndex { +impl Iterable for &OptionalIndex { fn boxed_iter(&self) -> Box + '_> { Box::new(self.iter_rows()) } @@ -123,7 +123,7 @@ enum BlockSelectCursor<'a> { Sparse( as Set>::SelectCursor<'a>), } -impl<'a> BlockSelectCursor<'a> { +impl BlockSelectCursor<'_> { fn select(&mut self, rank: u16) -> u16 { match self { BlockSelectCursor::Dense(dense_select_cursor) => dense_select_cursor.select(rank), @@ -141,7 +141,7 @@ pub struct OptionalIndexSelectCursor<'a> { num_null_rows_before_block: RowId, } -impl<'a> OptionalIndexSelectCursor<'a> { +impl OptionalIndexSelectCursor<'_> { fn search_and_load_block(&mut self, rank: RowId) { if rank < self.current_block_end_rank { // we are already in the right block @@ -165,7 +165,7 @@ impl<'a> OptionalIndexSelectCursor<'a> { } } -impl<'a> SelectCursor for OptionalIndexSelectCursor<'a> { +impl SelectCursor for OptionalIndexSelectCursor<'_> { fn select(&mut self, rank: RowId) -> RowId { self.search_and_load_block(rank); let index_in_block = (rank - self.num_null_rows_before_block) as u16; @@ -505,7 +505,7 @@ fn deserialize_optional_index_block_metadatas( non_null_rows_before_block += num_non_null_rows; } block_metas.resize( - ((num_rows + ELEMENTS_PER_BLOCK - 1) / ELEMENTS_PER_BLOCK) as usize, + num_rows.div_ceil(ELEMENTS_PER_BLOCK) as usize, BlockMeta { non_null_rows_before_block, start_byte_offset, diff --git a/columnar/src/column_index/optional_index/set_block/dense.rs b/columnar/src/column_index/optional_index/set_block/dense.rs index 8b249c0d5..33e030d26 100644 --- a/columnar/src/column_index/optional_index/set_block/dense.rs +++ b/columnar/src/column_index/optional_index/set_block/dense.rs @@ -23,7 +23,6 @@ fn set_bit_at(input: &mut u64, n: u16) { /// /// When translating a dense index to the original index, we can use the offset to find the correct /// block. Direct computation is not possible, but we can employ a linear or binary search. - const ELEMENTS_PER_MINI_BLOCK: u16 = 64; const MINI_BLOCK_BITVEC_NUM_BYTES: usize = 8; const MINI_BLOCK_OFFSET_NUM_BYTES: usize = 2; @@ -109,7 +108,7 @@ pub struct DenseBlockSelectCursor<'a> { dense_block: DenseBlock<'a>, } -impl<'a> SelectCursor for DenseBlockSelectCursor<'a> { +impl SelectCursor for DenseBlockSelectCursor<'_> { #[inline] fn select(&mut self, rank: u16) -> u16 { self.block_id = self @@ -175,7 +174,7 @@ impl<'a> Set for DenseBlock<'a> { } } -impl<'a> DenseBlock<'a> { +impl DenseBlock<'_> { #[inline] fn mini_block(&self, mini_block_id: u16) -> DenseMiniBlock { let data_start_pos = mini_block_id as usize * MINI_BLOCK_NUM_BYTES; diff --git a/columnar/src/column_index/optional_index/set_block/sparse.rs b/columnar/src/column_index/optional_index/set_block/sparse.rs index 9413d9bd2..6fc0e3469 100644 --- a/columnar/src/column_index/optional_index/set_block/sparse.rs +++ b/columnar/src/column_index/optional_index/set_block/sparse.rs @@ -31,7 +31,7 @@ impl<'a> SelectCursor for SparseBlock<'a> { } } -impl<'a> Set for SparseBlock<'a> { +impl Set for SparseBlock<'_> { type SelectCursor<'b> = Self where Self: 'b; @@ -69,7 +69,7 @@ fn get_u16(data: &[u8], byte_position: usize) -> u16 { u16::from_le_bytes(bytes) } -impl<'a> SparseBlock<'a> { +impl SparseBlock<'_> { #[inline(always)] fn value_at_idx(&self, data: &[u8], idx: u16) -> u16 { let start_offset: usize = idx as usize * 2; diff --git a/columnar/src/column_index/serialize.rs b/columnar/src/column_index/serialize.rs index 107faf0dd..673c3459b 100644 --- a/columnar/src/column_index/serialize.rs +++ b/columnar/src/column_index/serialize.rs @@ -31,7 +31,7 @@ pub enum SerializableColumnIndex<'a> { Multivalued(SerializableMultivalueIndex<'a>), } -impl<'a> SerializableColumnIndex<'a> { +impl SerializableColumnIndex<'_> { pub fn get_cardinality(&self) -> Cardinality { match self { SerializableColumnIndex::Full => Cardinality::Full, diff --git a/columnar/src/column_values/merge.rs b/columnar/src/column_values/merge.rs index a3b2df18a..2f9536c2e 100644 --- a/columnar/src/column_values/merge.rs +++ b/columnar/src/column_values/merge.rs @@ -10,7 +10,7 @@ pub(crate) struct MergedColumnValues<'a, T> { pub(crate) merge_row_order: &'a MergeRowOrder, } -impl<'a, T: Copy + PartialOrd + Debug + 'static> Iterable for MergedColumnValues<'a, T> { +impl Iterable for MergedColumnValues<'_, T> { fn boxed_iter(&self) -> Box + '_> { match self.merge_row_order { MergeRowOrder::Stack(_) => Box::new( diff --git a/columnar/src/column_values/u64_based/blockwise_linear.rs b/columnar/src/column_values/u64_based/blockwise_linear.rs index 2abf8205b..eb9191aa8 100644 --- a/columnar/src/column_values/u64_based/blockwise_linear.rs +++ b/columnar/src/column_values/u64_based/blockwise_linear.rs @@ -39,7 +39,7 @@ impl BinarySerializable for Block { } fn compute_num_blocks(num_vals: u32) -> u32 { - (num_vals + BLOCK_SIZE - 1) / BLOCK_SIZE + num_vals.div_ceil(BLOCK_SIZE) } pub struct BlockwiseLinearEstimator { diff --git a/columnar/src/columnar/merge/merge_dict_column.rs b/columnar/src/columnar/merge/merge_dict_column.rs index 9a4db384c..e2247a156 100644 --- a/columnar/src/columnar/merge/merge_dict_column.rs +++ b/columnar/src/columnar/merge/merge_dict_column.rs @@ -39,7 +39,7 @@ struct RemappedTermOrdinalsValues<'a> { merge_row_order: &'a MergeRowOrder, } -impl<'a> Iterable for RemappedTermOrdinalsValues<'a> { +impl Iterable for RemappedTermOrdinalsValues<'_> { fn boxed_iter(&self) -> Box + '_> { match self.merge_row_order { MergeRowOrder::Stack(_) => self.boxed_iter_stacked(), @@ -50,7 +50,7 @@ impl<'a> Iterable for RemappedTermOrdinalsValues<'a> { } } -impl<'a> RemappedTermOrdinalsValues<'a> { +impl RemappedTermOrdinalsValues<'_> { fn boxed_iter_stacked(&self) -> Box + '_> { let iter = self .bytes_columns diff --git a/columnar/src/columnar/merge/term_merger.rs b/columnar/src/columnar/merge/term_merger.rs index 77b40964e..d3e219ea6 100644 --- a/columnar/src/columnar/merge/term_merger.rs +++ b/columnar/src/columnar/merge/term_merger.rs @@ -10,13 +10,13 @@ pub struct HeapItem<'a> { pub segment_ord: usize, } -impl<'a> PartialEq for HeapItem<'a> { +impl PartialEq for HeapItem<'_> { fn eq(&self, other: &Self) -> bool { self.segment_ord == other.segment_ord } } -impl<'a> Eq for HeapItem<'a> {} +impl Eq for HeapItem<'_> {} impl<'a> PartialOrd for HeapItem<'a> { fn partial_cmp(&self, other: &HeapItem<'a>) -> Option { diff --git a/columnar/src/columnar/writer/serializer.rs b/columnar/src/columnar/writer/serializer.rs index 0e5a1e2b2..818acfe69 100644 --- a/columnar/src/columnar/writer/serializer.rs +++ b/columnar/src/columnar/writer/serializer.rs @@ -67,7 +67,7 @@ pub struct ColumnSerializer<'a, W: io::Write> { start_offset: u64, } -impl<'a, W: io::Write> ColumnSerializer<'a, W> { +impl ColumnSerializer<'_, W> { pub fn finalize(self) -> io::Result<()> { let end_offset: u64 = self.columnar_serializer.wrt.written_bytes(); let byte_range = self.start_offset..end_offset; @@ -80,7 +80,7 @@ impl<'a, W: io::Write> ColumnSerializer<'a, W> { } } -impl<'a, W: io::Write> io::Write for ColumnSerializer<'a, W> { +impl io::Write for ColumnSerializer<'_, W> { fn write(&mut self, buf: &[u8]) -> io::Result { self.columnar_serializer.wrt.write(buf) } diff --git a/columnar/src/iterable.rs b/columnar/src/iterable.rs index f59d37325..e6bfea34c 100644 --- a/columnar/src/iterable.rs +++ b/columnar/src/iterable.rs @@ -7,7 +7,7 @@ pub trait Iterable { fn boxed_iter(&self) -> Box + '_>; } -impl<'a, T: Copy> Iterable for &'a [T] { +impl Iterable for &[T] { fn boxed_iter(&self) -> Box + '_> { Box::new(self.iter().copied()) } diff --git a/common/src/writer.rs b/common/src/writer.rs index 88457687f..926b62c74 100644 --- a/common/src/writer.rs +++ b/common/src/writer.rs @@ -87,7 +87,7 @@ impl TerminatingWrite for BufWriter { } } -impl<'a> TerminatingWrite for &'a mut Vec { +impl TerminatingWrite for &mut Vec { fn terminate_ref(&mut self, _a: AntiCallToken) -> io::Result<()> { self.flush() } diff --git a/sstable/src/streamer.rs b/sstable/src/streamer.rs index 66e31ace1..7ae4bab14 100644 --- a/sstable/src/streamer.rs +++ b/sstable/src/streamer.rs @@ -161,7 +161,7 @@ where _lifetime: std::marker::PhantomData<&'a ()>, } -impl<'a, TSSTable> Streamer<'a, TSSTable, AlwaysMatch> +impl Streamer<'_, TSSTable, AlwaysMatch> where TSSTable: SSTable { pub fn empty() -> Self { @@ -178,7 +178,7 @@ where TSSTable: SSTable } } -impl<'a, TSSTable, A> Streamer<'a, TSSTable, A> +impl Streamer<'_, TSSTable, A> where A: Automaton, A::State: Clone, diff --git a/stacker/src/expull.rs b/stacker/src/expull.rs index 4c400b415..58128d680 100644 --- a/stacker/src/expull.rs +++ b/stacker/src/expull.rs @@ -74,7 +74,7 @@ fn ensure_capacity<'a>( eull.remaining_cap = allocate as u16; } -impl<'a> ExpUnrolledLinkedListWriter<'a> { +impl ExpUnrolledLinkedListWriter<'_> { #[inline] pub fn write_u32_vint(&mut self, val: u32) { let mut buf = [0u8; 8]; diff --git a/tokenizer-api/src/lib.rs b/tokenizer-api/src/lib.rs index 2ba38d82a..dcc3648a2 100644 --- a/tokenizer-api/src/lib.rs +++ b/tokenizer-api/src/lib.rs @@ -63,7 +63,7 @@ pub trait Tokenizer: 'static + Clone + Send + Sync { /// Simple wrapper of `Box`. pub struct BoxTokenStream<'a>(Box); -impl<'a> TokenStream for BoxTokenStream<'a> { +impl TokenStream for BoxTokenStream<'_> { fn advance(&mut self) -> bool { self.0.advance() } @@ -90,7 +90,7 @@ impl<'a> Deref for BoxTokenStream<'a> { &*self.0 } } -impl<'a> DerefMut for BoxTokenStream<'a> { +impl DerefMut for BoxTokenStream<'_> { fn deref_mut(&mut self) -> &mut Self::Target { &mut *self.0 }