From 2340dca6288b9f1505096c5d4b1e5a73270af58e Mon Sep 17 00:00:00 2001 From: PSeitz-dd Date: Fri, 19 Sep 2025 15:55:04 +0200 Subject: [PATCH] fix compiler warnings (#2699) * fix compiler warnings * fix import --- .../src/column_index/optional_index/mod.rs | 36 ++----------------- query-grammar/src/query_grammar.rs | 2 +- src/aggregation/bucket/histogram/histogram.rs | 2 +- src/collector/facet_collector.rs | 1 - src/directory/mmap_directory.rs | 6 ++-- src/index/inverted_index_reader.rs | 2 +- src/indexer/index_writer.rs | 2 +- src/postings/serializer.rs | 4 +-- src/query/bm25.rs | 8 ----- src/query/boolean_query/block_wand.rs | 1 - .../range_query/range_query_fastfield.rs | 6 ++-- src/tokenizer/ascii_folding_filter.rs | 1 - sstable/src/dictionary.rs | 6 ++-- 13 files changed, 16 insertions(+), 61 deletions(-) diff --git a/columnar/src/column_index/optional_index/mod.rs b/columnar/src/column_index/optional_index/mod.rs index 0bcf9bad4..e238dce9b 100644 --- a/columnar/src/column_index/optional_index/mod.rs +++ b/columnar/src/column_index/optional_index/mod.rs @@ -1,4 +1,4 @@ -use std::io::{self, Write}; +use std::io; use std::sync::Arc; mod set; @@ -11,7 +11,7 @@ use set_block::{ }; use crate::iterable::Iterable; -use crate::{DocId, InvalidData, RowId}; +use crate::{DocId, RowId}; /// The threshold for for number of elements after which we switch to dense block encoding. /// @@ -335,38 +335,6 @@ enum Block<'a> { Sparse(SparseBlock<'a>), } -#[derive(Debug, Copy, Clone)] -enum OptionalIndexCodec { - Dense = 0, - Sparse = 1, -} - -impl OptionalIndexCodec { - fn to_code(self) -> u8 { - self as u8 - } - - fn try_from_code(code: u8) -> Result { - match code { - 0 => Ok(Self::Dense), - 1 => Ok(Self::Sparse), - _ => Err(InvalidData), - } - } -} - -impl BinarySerializable for OptionalIndexCodec { - fn serialize(&self, writer: &mut W) -> io::Result<()> { - writer.write_all(&[self.to_code()]) - } - - fn deserialize(reader: &mut R) -> io::Result { - let optional_codec_code = u8::deserialize(reader)?; - let optional_codec = Self::try_from_code(optional_codec_code)?; - Ok(optional_codec) - } -} - fn serialize_optional_index_block(block_els: &[u16], out: &mut impl io::Write) -> io::Result<()> { let is_sparse = is_sparse(block_els.len() as u32); if is_sparse { diff --git a/query-grammar/src/query_grammar.rs b/query-grammar/src/query_grammar.rs index 1960f219a..daf44e83c 100644 --- a/query-grammar/src/query_grammar.rs +++ b/query-grammar/src/query_grammar.rs @@ -68,7 +68,7 @@ fn interpret_escape(source: &str) -> String { /// Consume a word outside of any context. // TODO should support escape sequences -fn word(inp: &str) -> IResult<&str, Cow> { +fn word(inp: &str) -> IResult<&str, Cow<'_, str>> { map_res( recognize(tuple(( alt(( diff --git a/src/aggregation/bucket/histogram/histogram.rs b/src/aggregation/bucket/histogram/histogram.rs index b690b0064..4fe720201 100644 --- a/src/aggregation/bucket/histogram/histogram.rs +++ b/src/aggregation/bucket/histogram/histogram.rs @@ -301,7 +301,7 @@ impl SegmentAggregationCollector for SegmentHistogramCollector { let bounds = self.bounds; let interval = self.interval; let offset = self.offset; - let get_bucket_pos = |val| (get_bucket_pos_f64(val, interval, offset) as i64); + let get_bucket_pos = |val| get_bucket_pos_f64(val, interval, offset) as i64; bucket_agg_accessor .column_block_accessor diff --git a/src/collector/facet_collector.rs b/src/collector/facet_collector.rs index 183c245ca..a94ec03e8 100644 --- a/src/collector/facet_collector.rs +++ b/src/collector/facet_collector.rs @@ -484,7 +484,6 @@ impl FacetCounts { #[cfg(test)] mod tests { use std::collections::BTreeSet; - use std::iter; use columnar::Dictionary; use rand::distributions::Uniform; diff --git a/src/directory/mmap_directory.rs b/src/directory/mmap_directory.rs index 61e2b6035..f4785ef72 100644 --- a/src/directory/mmap_directory.rs +++ b/src/directory/mmap_directory.rs @@ -484,10 +484,8 @@ impl Directory for MmapDirectory { .map_err(LockError::wrap_io_error)?; if lock.is_blocking { file.lock_exclusive().map_err(LockError::wrap_io_error)?; - } else { - if !file.try_lock_exclusive().map_err(|_| LockError::LockBusy)? { - return Err(LockError::LockBusy); - } + } else if !file.try_lock_exclusive().map_err(|_| LockError::LockBusy)? { + return Err(LockError::LockBusy); } // dropping the file handle will release the lock. Ok(DirectoryLock::from(Box::new(ReleaseLockFile { diff --git a/src/index/inverted_index_reader.rs b/src/index/inverted_index_reader.rs index be29c06df..7314f8741 100644 --- a/src/index/inverted_index_reader.rs +++ b/src/index/inverted_index_reader.rs @@ -146,7 +146,7 @@ impl InvertedIndexReader { positions_size: ByteCount::default(), num_terms: 0u64, }; - field_space.record(&term_info); + field_space.record(term_info); // We include the json type and the json end of path to make sure the prefix check // is meaningful. diff --git a/src/indexer/index_writer.rs b/src/indexer/index_writer.rs index 2e8905050..7f993027e 100644 --- a/src/indexer/index_writer.rs +++ b/src/indexer/index_writer.rs @@ -615,7 +615,7 @@ impl IndexWriter { /// It is also possible to add a payload to the `commit` /// using this API. /// See [`PreparedCommit::set_payload()`]. - pub fn prepare_commit(&mut self) -> crate::Result> { + pub fn prepare_commit(&mut self) -> crate::Result> { // Here, because we join all of the worker threads, // all of the segment update for this commit have been // sent. diff --git a/src/postings/serializer.rs b/src/postings/serializer.rs index 91b8ec4ca..c0ee8483c 100644 --- a/src/postings/serializer.rs +++ b/src/postings/serializer.rs @@ -75,7 +75,7 @@ impl InvertedIndexSerializer { field: Field, total_num_tokens: u64, fieldnorm_reader: Option, - ) -> io::Result { + ) -> io::Result> { let field_entry: &FieldEntry = self.schema.get_field_entry(field); let term_dictionary_write = self.terms_write.for_field(field); let postings_write = self.postings_write.for_field(field); @@ -126,7 +126,7 @@ impl<'a> FieldSerializer<'a> { let term_dictionary_builder = TermDictionaryBuilder::create(term_dictionary_write)?; let average_fieldnorm = fieldnorm_reader .as_ref() - .map(|ff_reader| (total_num_tokens as Score / ff_reader.num_docs() as Score)) + .map(|ff_reader| total_num_tokens as Score / ff_reader.num_docs() as Score) .unwrap_or(0.0); let postings_serializer = PostingsSerializer::new( postings_write, diff --git a/src/query/bm25.rs b/src/query/bm25.rs index 532660574..34ad974d4 100644 --- a/src/query/bm25.rs +++ b/src/query/bm25.rs @@ -1,5 +1,3 @@ -use serde::{Deserialize, Serialize}; - use crate::fieldnorm::FieldNormReader; use crate::query::Explanation; use crate::schema::Field; @@ -68,12 +66,6 @@ fn compute_tf_cache(average_fieldnorm: Score) -> [Score; 256] { cache } -#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] -pub struct Bm25Params { - pub idf: Score, - pub avg_fieldnorm: Score, -} - /// A struct used for computing BM25 scores. #[derive(Clone)] pub struct Bm25Weight { diff --git a/src/query/boolean_query/block_wand.rs b/src/query/boolean_query/block_wand.rs index d2803c82d..85a16df94 100644 --- a/src/query/boolean_query/block_wand.rs +++ b/src/query/boolean_query/block_wand.rs @@ -302,7 +302,6 @@ fn is_sorted>(mut it: I) -> bool { mod tests { use std::cmp::Ordering; use std::collections::BinaryHeap; - use std::iter; use proptest::prelude::*; diff --git a/src/query/range_query/range_query_fastfield.rs b/src/query/range_query/range_query_fastfield.rs index 1392d4d5b..b17694cfa 100644 --- a/src/query/range_query/range_query_fastfield.rs +++ b/src/query/range_query/range_query_fastfield.rs @@ -258,7 +258,7 @@ fn search_on_json_numerical_field( let bounds = match typ.numerical_type().unwrap() { NumericalType::I64 => { - let bounds = bounds.map_bound(|term| (term.as_i64().unwrap())); + let bounds = bounds.map_bound(|term| term.as_i64().unwrap()); match actual_column_type { NumericalType::I64 => bounds.map_bound(|&term| term.to_u64()), NumericalType::U64 => { @@ -282,7 +282,7 @@ fn search_on_json_numerical_field( } } NumericalType::U64 => { - let bounds = bounds.map_bound(|term| (term.as_u64().unwrap())); + let bounds = bounds.map_bound(|term| term.as_u64().unwrap()); match actual_column_type { NumericalType::U64 => bounds.map_bound(|&term| term.to_u64()), NumericalType::I64 => { @@ -306,7 +306,7 @@ fn search_on_json_numerical_field( } } NumericalType::F64 => { - let bounds = bounds.map_bound(|term| (term.as_f64().unwrap())); + let bounds = bounds.map_bound(|term| term.as_f64().unwrap()); match actual_column_type { NumericalType::U64 => transform_from_f64_bounds::(&bounds), NumericalType::I64 => transform_from_f64_bounds::(&bounds), diff --git a/src/tokenizer/ascii_folding_filter.rs b/src/tokenizer/ascii_folding_filter.rs index 9a7ba8316..9e6ac411c 100644 --- a/src/tokenizer/ascii_folding_filter.rs +++ b/src/tokenizer/ascii_folding_filter.rs @@ -1561,7 +1561,6 @@ fn to_ascii(text: &str, output: &mut String) { #[cfg(test)] mod tests { - use std::iter; use super::to_ascii; use crate::tokenizer::{AsciiFoldingFilter, RawTokenizer, SimpleTokenizer, TextAnalyzer}; diff --git a/sstable/src/dictionary.rs b/sstable/src/dictionary.rs index 4b4dd0275..be123b5fa 100644 --- a/sstable/src/dictionary.rs +++ b/sstable/src/dictionary.rs @@ -609,12 +609,12 @@ impl Dictionary { /// Returns a range builder, to stream all of the terms /// within an interval. - pub fn range(&self) -> StreamerBuilder { + pub fn range(&self) -> StreamerBuilder<'_, TSSTable> { StreamerBuilder::new(self, AlwaysMatch) } /// Returns a range builder filtered with a prefix. - pub fn prefix_range>(&self, prefix: K) -> StreamerBuilder { + pub fn prefix_range>(&self, prefix: K) -> StreamerBuilder<'_, TSSTable> { let lower_bound = prefix.as_ref(); let mut upper_bound = lower_bound.to_vec(); for idx in (0..upper_bound.len()).rev() { @@ -633,7 +633,7 @@ impl Dictionary { } /// A stream of all the sorted terms. - pub fn stream(&self) -> io::Result> { + pub fn stream(&self) -> io::Result> { self.range().into_stream() }