mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-05-24 12:10:41 +00:00
Fix clippy warnings: deprecated gen_range, manual div_ceil, legacy import (#2860)
- Replace deprecated rand::Rng::gen_range with random_range in benchmarks - Use usize::div_ceil instead of manual (len + size - 1) / size - Remove unused legacy std::i64 import - Replace 'if let Some(_)' with '.is_some()'
This commit is contained in:
committed by
GitHub
parent
993ef97814
commit
a9535156b1
@@ -45,7 +45,7 @@ fn build_shared_indices(num_docs: usize, distribution: &str) -> BenchIndex {
|
||||
match distribution {
|
||||
"dense_random" => {
|
||||
for _doc_id in 0..num_docs {
|
||||
let suffix = rng.gen_range(0u64..1000u64);
|
||||
let suffix = rng.random_range(0u64..1000u64);
|
||||
let str_val = format!("str_{:03}", suffix);
|
||||
|
||||
writer
|
||||
@@ -71,7 +71,7 @@ fn build_shared_indices(num_docs: usize, distribution: &str) -> BenchIndex {
|
||||
}
|
||||
"sparse_random" => {
|
||||
for _doc_id in 0..num_docs {
|
||||
let suffix = rng.gen_range(0u64..1000000u64);
|
||||
let suffix = rng.random_range(0u64..1000000u64);
|
||||
let str_val = format!("str_{:07}", suffix);
|
||||
|
||||
writer
|
||||
|
||||
@@ -54,8 +54,6 @@ fn month_bucket_using_time_crate(timestamp_ns: i64) -> Result<i64, time::Error>
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::i64;
|
||||
|
||||
use time::format_description::well_known::Iso8601;
|
||||
use time::UtcDateTime;
|
||||
|
||||
|
||||
@@ -533,7 +533,7 @@ mod tests {
|
||||
let expected_buckets_vec = expected_buckets.as_array().unwrap();
|
||||
|
||||
for page_size in 1..=expected_buckets_vec.len() {
|
||||
let page_count = (expected_buckets_vec.len() + page_size - 1) / page_size;
|
||||
let page_count = expected_buckets_vec.len().div_ceil(page_size);
|
||||
let mut after_key = None;
|
||||
for page_idx in 0..page_count {
|
||||
let mut agg_req_json = json!({
|
||||
@@ -565,7 +565,7 @@ mod tests {
|
||||
"expected after_key on all but last page"
|
||||
);
|
||||
after_key = Some(res["my_composite"]["after_key"].clone());
|
||||
} else if let Some(_) = res["my_composite"].get("after_key") {
|
||||
} else if res["my_composite"].get("after_key").is_some() {
|
||||
// currently we sometime have an after_key on the last page,
|
||||
// check that the next "page" is empty
|
||||
let agg_req_json = json!({
|
||||
|
||||
Reference in New Issue
Block a user