From 15e685a993330a8aba43923d81096fb3aef9feb4 Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Sun, 23 Jul 2023 10:00:30 +0200 Subject: [PATCH] Fix a few more upcoming Clippy lints --- src/aggregation/bucket/histogram/histogram.rs | 15 ++++++--------- src/aggregation/bucket/range.rs | 2 +- src/aggregation/intermediate_agg_result.rs | 2 +- src/aggregation/segment_agg_result.rs | 2 +- src/directory/directory.rs | 6 +++--- src/indexer/index_writer.rs | 6 +++--- src/indexer/merger.rs | 2 +- src/store/compressors.rs | 3 ++- 8 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/aggregation/bucket/histogram/histogram.rs b/src/aggregation/bucket/histogram/histogram.rs index 3ea8d52db6..128cea783d 100644 --- a/src/aggregation/bucket/histogram/histogram.rs +++ b/src/aggregation/bucket/histogram/histogram.rs @@ -453,15 +453,12 @@ fn intermediate_buckets_to_final_buckets_fill_gaps( let final_buckets: Vec = buckets .into_iter() - .merge_join_by( - fill_gaps_buckets.into_iter(), - |existing_bucket, fill_gaps_bucket| { - existing_bucket - .key - .partial_cmp(fill_gaps_bucket) - .unwrap_or(Ordering::Equal) - }, - ) + .merge_join_by(fill_gaps_buckets, |existing_bucket, fill_gaps_bucket| { + existing_bucket + .key + .partial_cmp(fill_gaps_bucket) + .unwrap_or(Ordering::Equal) + }) .map(|either| match either { // Ignore the generated bucket itertools::EitherOrBoth::Both(existing, _) => existing, diff --git a/src/aggregation/bucket/range.rs b/src/aggregation/bucket/range.rs index 58d35f3967..fda49141c1 100644 --- a/src/aggregation/bucket/range.rs +++ b/src/aggregation/bucket/range.rs @@ -262,7 +262,7 @@ impl SegmentRangeCollector { pub(crate) fn from_req_and_validate( req: &RangeAggregation, sub_aggregation: &mut AggregationsWithAccessor, - limits: &mut ResourceLimitGuard, + limits: &ResourceLimitGuard, field_type: ColumnType, accessor_idx: usize, ) -> crate::Result { diff --git a/src/aggregation/intermediate_agg_result.rs b/src/aggregation/intermediate_agg_result.rs index 195cd52338..4a20611545 100644 --- a/src/aggregation/intermediate_agg_result.rs +++ b/src/aggregation/intermediate_agg_result.rs @@ -463,7 +463,7 @@ impl IntermediateBucketResult { let buckets: Result, TantivyError> = buckets_left .drain(..) - .merge_join_by(buckets_right.into_iter(), |left, right| { + .merge_join_by(buckets_right, |left, right| { left.key.partial_cmp(&right.key).unwrap_or(Ordering::Equal) }) .map(|either| match either { diff --git a/src/aggregation/segment_agg_result.rs b/src/aggregation/segment_agg_result.rs index da03ccaaa4..f3cb1a60aa 100644 --- a/src/aggregation/segment_agg_result.rs +++ b/src/aggregation/segment_agg_result.rs @@ -104,7 +104,7 @@ pub(crate) fn build_single_agg_segment_collector( Range(range_req) => Ok(Box::new(SegmentRangeCollector::from_req_and_validate( range_req, &mut req.sub_aggregation, - &mut req.limits, + &req.limits, req.field_type, accessor_idx, )?)), diff --git a/src/directory/directory.rs b/src/directory/directory.rs index 62714883f1..16e0043d50 100644 --- a/src/directory/directory.rs +++ b/src/directory/directory.rs @@ -73,7 +73,7 @@ impl From for TryAcquireLockError { fn try_acquire_lock( filepath: &Path, - directory: &mut dyn Directory, + directory: &dyn Directory, ) -> Result { let mut write = directory.open_write(filepath).map_err(|e| match e { OpenWriteError::FileAlreadyExists(_) => TryAcquireLockError::FileExists, @@ -191,10 +191,10 @@ pub trait Directory: DirectoryClone + fmt::Debug + Send + Sync + 'static { /// /// The method is blocking or not depending on the [`Lock`] object. fn acquire_lock(&self, lock: &Lock) -> Result { - let mut box_directory = self.box_clone(); + let box_directory = self.box_clone(); let mut retry_policy = retry_policy(lock.is_blocking); loop { - match try_acquire_lock(&lock.filepath, &mut *box_directory) { + match try_acquire_lock(&lock.filepath, &*box_directory) { Ok(result) => { return Ok(result); } diff --git a/src/indexer/index_writer.rs b/src/indexer/index_writer.rs index c44ad39b69..1639fb5b79 100644 --- a/src/indexer/index_writer.rs +++ b/src/indexer/index_writer.rs @@ -167,7 +167,7 @@ fn index_documents( memory_budget: usize, segment: Segment, grouped_document_iterator: &mut dyn Iterator, - segment_updater: &mut SegmentUpdater, + segment_updater: &SegmentUpdater, mut delete_cursor: DeleteCursor, ) -> crate::Result<()> { let mut segment_writer = SegmentWriter::for_segment(memory_budget, segment.clone())?; @@ -392,7 +392,7 @@ impl IndexWriter { let document_receiver_clone = self.operation_receiver()?; let index_writer_bomb = self.index_writer_status.create_bomb(); - let mut segment_updater = self.segment_updater.clone(); + let segment_updater = self.segment_updater.clone(); let mut delete_cursor = self.delete_queue.cursor(); @@ -428,7 +428,7 @@ impl IndexWriter { mem_budget, index.new_segment(), &mut document_iterator, - &mut segment_updater, + &segment_updater, delete_cursor.clone(), )?; } diff --git a/src/indexer/merger.rs b/src/indexer/merger.rs index 7ed5e42d9c..d9144c4a3f 100644 --- a/src/indexer/merger.rs +++ b/src/indexer/merger.rs @@ -178,7 +178,7 @@ impl IndexMerger { alive_bitset_opt: Vec>, ) -> crate::Result { let mut readers = vec![]; - for (segment, new_alive_bitset_opt) in segments.iter().zip(alive_bitset_opt.into_iter()) { + for (segment, new_alive_bitset_opt) in segments.iter().zip(alive_bitset_opt) { if segment.meta().num_docs() > 0 { let reader = SegmentReader::open_with_custom_alive_set(segment, new_alive_bitset_opt)?; diff --git a/src/store/compressors.rs b/src/store/compressors.rs index a15c83af79..89205c99d0 100644 --- a/src/store/compressors.rs +++ b/src/store/compressors.rs @@ -89,6 +89,7 @@ pub struct ZstdCompressor { pub compression_level: Option, } +#[cfg(feature = "zstd-compression")] impl ZstdCompressor { fn deser_from_str(val: &str) -> Result { if !val.starts_with("zstd") { @@ -173,7 +174,7 @@ impl Compressor { } } -#[cfg(test)] +#[cfg(all(feature = "zstd-compression", test))] mod tests { use super::*;