Compare commits

...

1 Commits

Author SHA1 Message Date
Paul Masurel
dc0aa3d734 Clippy and cleanups 2025-08-01 11:54:29 +09:00
17 changed files with 28 additions and 29 deletions

View File

@@ -1,3 +1,7 @@
// manual divceil actually generates code that is not optimal (to accept the full range of u32) and
// perf matters here.
#![allow(clippy::manual_div_ceil)]
use std::io; use std::io;
use std::ops::{Range, RangeInclusive}; use std::ops::{Range, RangeInclusive};

View File

@@ -140,10 +140,9 @@ impl BlockedBitpacker {
pub fn iter(&self) -> impl Iterator<Item = u64> + '_ { pub fn iter(&self) -> impl Iterator<Item = u64> + '_ {
// todo performance: we could decompress a whole block and cache it instead // todo performance: we could decompress a whole block and cache it instead
let bitpacked_elems = self.offset_and_bits.len() * BLOCK_SIZE; let bitpacked_elems = self.offset_and_bits.len() * BLOCK_SIZE;
let iter = (0..bitpacked_elems) (0..bitpacked_elems)
.map(move |idx| self.get(idx)) .map(move |idx| self.get(idx))
.chain(self.buffer.iter().cloned()); .chain(self.buffer.iter().cloned())
iter
} }
} }

View File

@@ -1,3 +1,5 @@
// #[allow(clippy::manual_div_ceil)]
mod bitpacker; mod bitpacker;
mod blocked_bitpacker; mod blocked_bitpacker;
mod filter_vec; mod filter_vec;

View File

@@ -1,3 +1,5 @@
#![allow(clippy::manual_div_ceil)]
mod column_type; mod column_type;
mod format_version; mod format_version;
mod merge; mod merge;

View File

@@ -17,7 +17,7 @@
//! column. //! column.
//! - [column_values]: Stores the values of a column in a dense format. //! - [column_values]: Stores the values of a column in a dense format.
#![cfg_attr(all(feature = "unstable", test), feature(test))] // #![cfg_attr(all(feature = "unstable", test), feature(test))]
#[cfg(test)] #[cfg(test)]
#[macro_use] #[macro_use]

View File

@@ -9,7 +9,7 @@ use crate::ByteCount;
pub struct TinySet(u64); pub struct TinySet(u64);
impl fmt::Debug for TinySet { impl fmt::Debug for TinySet {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.into_iter().collect::<Vec<u32>>().fmt(f) self.into_iter().collect::<Vec<u32>>().fmt(f)
} }
} }
@@ -182,6 +182,7 @@ pub struct BitSet {
max_value: u32, max_value: u32,
} }
#[inline(always)]
fn num_buckets(max_val: u32) -> u32 { fn num_buckets(max_val: u32) -> u32 {
(max_val + 63u32) / 64u32 (max_val + 63u32) / 64u32
} }

View File

@@ -1,4 +1,6 @@
#![allow(clippy::len_without_is_empty)] // manual divceil actually generates code that is not optimal (to accept the full range of u32) and
// perf matters here.
#![allow(clippy::len_without_is_empty, clippy::manual_div_ceil)]
use std::ops::Deref; use std::ops::Deref;

View File

@@ -305,15 +305,14 @@ fn term_group_infallible(inp: &str) -> JResult<&str, UserInputAst> {
let (inp, (field_name, _, _, _)) = let (inp, (field_name, _, _, _)) =
tuple((field_name, multispace0, char('('), multispace0))(inp).expect("precondition failed"); tuple((field_name, multispace0, char('('), multispace0))(inp).expect("precondition failed");
let res = delimited_infallible( delimited_infallible(
nothing, nothing,
map(ast_infallible, |(mut ast, errors)| { map(ast_infallible, |(mut ast, errors)| {
ast.set_default_field(field_name.to_string()); ast.set_default_field(field_name.to_string());
(ast, errors) (ast, errors)
}), }),
opt_i_err(char(')'), "expected ')'"), opt_i_err(char(')'), "expected ')'"),
)(inp); )(inp)
res
} }
fn exists(inp: &str) -> IResult<&str, UserInputLeaf> { fn exists(inp: &str) -> IResult<&str, UserInputLeaf> {

View File

@@ -484,7 +484,6 @@ impl FacetCounts {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::collections::BTreeSet; use std::collections::BTreeSet;
use std::iter;
use columnar::Dictionary; use columnar::Dictionary;
use rand::distributions::Uniform; use rand::distributions::Uniform;

View File

@@ -40,9 +40,6 @@ const COMPRESSION_BLOCK_SIZE: usize = BitPacker4x::BLOCK_LEN;
#[cfg(test)] #[cfg(test)]
pub(crate) mod tests { pub(crate) mod tests {
use std::iter;
use proptest::prelude::*; use proptest::prelude::*;
use proptest::sample::select; use proptest::sample::select;

View File

@@ -302,7 +302,6 @@ fn is_sorted<I: Iterator<Item = DocId>>(mut it: I) -> bool {
mod tests { mod tests {
use std::cmp::Ordering; use std::cmp::Ordering;
use std::collections::BinaryHeap; use std::collections::BinaryHeap;
use std::iter;
use proptest::prelude::*; use proptest::prelude::*;

View File

@@ -1561,8 +1561,6 @@ fn to_ascii(text: &str, output: &mut String) {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::iter;
use super::to_ascii; use super::to_ascii;
use crate::tokenizer::{AsciiFoldingFilter, RawTokenizer, SimpleTokenizer, TextAnalyzer}; use crate::tokenizer::{AsciiFoldingFilter, RawTokenizer, SimpleTokenizer, TextAnalyzer};

View File

@@ -308,10 +308,9 @@ impl<TSSTable: SSTable> Dictionary<TSSTable> {
} }
} }
_ => { _ => {
return Err(io::Error::new( return Err(io::Error::other(format!(
io::ErrorKind::Other, "Unsupported sstable version, expected one of [2, 3], found {version}"
format!("Unsupported sstable version, expected one of [2, 3], found {version}"), )));
));
} }
}; };
@@ -697,10 +696,9 @@ mod tests {
fn read_bytes(&self, range: Range<usize>) -> std::io::Result<OwnedBytes> { fn read_bytes(&self, range: Range<usize>) -> std::io::Result<OwnedBytes> {
let allowed_range = self.allowed_range.lock().unwrap(); let allowed_range = self.allowed_range.lock().unwrap();
if !allowed_range.contains(&range.start) || !allowed_range.contains(&(range.end - 1)) { if !allowed_range.contains(&range.start) || !allowed_range.contains(&(range.end - 1)) {
return Err(std::io::Error::new( return Err(std::io::Error::other(format!(
std::io::ErrorKind::Other, "invalid range, allowed {allowed_range:?}, requested {range:?}"
format!("invalid range, allowed {allowed_range:?}, requested {range:?}"), )));
));
} }
Ok(self.bytes.slice(range)) Ok(self.bytes.slice(range))

View File

@@ -1,3 +1,5 @@
#![allow(clippy::manual_div_ceil)]
//! `tantivy_sstable` is a crate that provides a sorted string table data structure. //! `tantivy_sstable` is a crate that provides a sorted string table data structure.
//! //!
//! It is used in `tantivy` to store the term dictionary. //! It is used in `tantivy` to store the term dictionary.

View File

@@ -394,7 +394,7 @@ impl SSTableIndexBuilder {
fn fst_error_to_io_error(error: tantivy_fst::Error) -> io::Error { fn fst_error_to_io_error(error: tantivy_fst::Error) -> io::Error {
match error { match error {
tantivy_fst::Error::Fst(fst_error) => io::Error::new(io::ErrorKind::Other, fst_error), tantivy_fst::Error::Fst(fst_error) => io::Error::other(fst_error),
tantivy_fst::Error::Io(ioerror) => ioerror, tantivy_fst::Error::Io(ioerror) => ioerror,
} }
} }

View File

@@ -10,8 +10,7 @@ pub fn fast_short_slice_copy(src: &[u8], dst: &mut [u8]) {
#[track_caller] #[track_caller]
fn len_mismatch_fail(dst_len: usize, src_len: usize) -> ! { fn len_mismatch_fail(dst_len: usize, src_len: usize) -> ! {
panic!( panic!(
"source slice length ({}) does not match destination slice length ({})", "source slice length ({src_len}) does not match destination slice length ({dst_len})",
src_len, dst_len,
); );
} }

View File

@@ -1,5 +1,3 @@
#![cfg_attr(all(feature = "unstable", test), feature(test))]
#[cfg(all(test, feature = "unstable"))] #[cfg(all(test, feature = "unstable"))]
extern crate test; extern crate test;