Skip to content

Commit 8d007c2

Browse files
Formatting, linting
1 parent 52149f0 commit 8d007c2

File tree

31 files changed

+85
-77
lines changed

31 files changed

+85
-77
lines changed

.cargo/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
config

crates/asap/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ fn binary_search(
100100
let mut min_obj = min_obj;
101101
let mut window_size = window_size;
102102
while head <= tail {
103-
let w = (head + tail + 1) / 2;
103+
let w = (head + tail).div_ceil(2);
104104
let smoothed = sma(data, w, 1);
105105
let metrics = Metrics::new(&smoothed);
106106
if metrics.kurtosis() >= original_kurt {
@@ -238,7 +238,7 @@ struct Metrics<'a> {
238238
m: f64,
239239
}
240240

241-
impl<'a> Metrics<'a> {
241+
impl Metrics<'_> {
242242
fn new(values: &[f64]) -> Metrics {
243243
Metrics {
244244
len: values.len() as u32,

crates/encodings/src/lib.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,21 @@ pub mod zigzag {
107107
}
108108

109109
pub mod prefix_varint {
110-
/// Similar to [LEB128](https://en.wikipedia.org/wiki/LEB128), but it moves
111-
/// all the tag bits to the LSBs of the first byte, which ends up looking
112-
/// like this (`x` is a value bit, the rest are tag bits):
113-
/// ```python,ignore,no_run
114-
/// xxxxxxx1 7 bits in 1 byte
115-
/// xxxxxx10 14 bits in 2 bytes
116-
/// xxxxx100 21 bits in 3 bytes
117-
/// xxxx1000 28 bits in 4 bytes
118-
/// xxx10000 35 bits in 5 bytes
119-
/// xx100000 42 bits in 6 bytes
120-
/// x1000000 49 bits in 7 bytes
121-
/// 10000000 56 bits in 8 bytes
122-
/// 00000000 64 bits in 9 bytes
123-
/// ```
124-
/// based on https://github.com/stoklund/varint
110+
//! Similar to [LEB128](https://en.wikipedia.org/wiki/LEB128), but it moves
111+
//! all the tag bits to the LSBs of the first byte, which ends up looking
112+
//! like this (`x` is a value bit, the rest are tag bits):
113+
//! ```python,ignore,no_run
114+
//! xxxxxxx1 7 bits in 1 byte
115+
//! xxxxxx10 14 bits in 2 bytes
116+
//! xxxxx100 21 bits in 3 bytes
117+
//! xxxx1000 28 bits in 4 bytes
118+
//! xxx10000 35 bits in 5 bytes
119+
//! xx100000 42 bits in 6 bytes
120+
//! x1000000 49 bits in 7 bytes
121+
//! 10000000 56 bits in 8 bytes
122+
//! 00000000 64 bits in 9 bytes
123+
//! ```
124+
//! based on https://github.com/stoklund/varint
125125
126126
pub fn size_vec<I: Iterator<Item = u64>>(bytes: &mut Vec<u8>, values: I) {
127127
let size: usize = values.map(|v| bytes_for_value(v) as usize).sum();

crates/flat_serialize/flat_serialize/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ pub enum Iter<'input, 'borrow, T: 'input> {
242242
Owned(std::vec::IntoIter<T>),
243243
}
244244

245-
impl<'input, 'borrow, T: 'input> Iterator for Iter<'input, 'borrow, T>
245+
impl<'input, T: 'input> Iterator for Iter<'input, '_, T>
246246
where
247247
T: FlatSerializable<'input> + Clone,
248248
{
@@ -288,7 +288,7 @@ where
288288
}
289289
}
290290

291-
impl<'input, 'borrow, T: 'input> Iter<'input, 'borrow, T>
291+
impl<'input, T: 'input> Iter<'input, '_, T>
292292
where
293293
T: FlatSerializable<'input> + Clone,
294294
{
@@ -492,7 +492,7 @@ where
492492
}
493493
}
494494

495-
impl<'de, 'i, T> serde::Deserialize<'de> for Slice<'i, T>
495+
impl<'de, T> serde::Deserialize<'de> for Slice<'_, T>
496496
where
497497
T: serde::Deserialize<'de>,
498498
{

crates/flat_serialize/flat_serialize_macro/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ pub fn flat_serializable_derive(input: TokenStream) -> TokenStream {
13921392
Ok(meta) => meta,
13931393
_ => return None,
13941394
};
1395-
let has_repr = meta.path().get_ident().map_or(false, |id| id == "repr");
1395+
let has_repr = meta.path().get_ident().is_some_and(|id| id == "repr");
13961396
if !has_repr {
13971397
return None;
13981398
}
@@ -1501,7 +1501,7 @@ pub fn flat_serializable_derive(input: TokenStream) -> TokenStream {
15011501
Ok(meta) => meta,
15021502
_ => return None,
15031503
};
1504-
let has_repr = meta.path().get_ident().map_or(false, |id| id == "repr");
1504+
let has_repr = meta.path().get_ident().is_some_and(|id| id == "repr");
15051505
if !has_repr {
15061506
return None;
15071507
}

crates/flat_serialize/flat_serialize_macro/src/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ fn validate_self_field(
329329

330330
struct ValidateLenFields<'a, 'b>(Option<TokenStream2>, &'b HashSet<&'a Ident>);
331331

332-
impl<'a, 'b, 'ast> Visit<'ast> for ValidateLenFields<'a, 'b> {
332+
impl<'ast> Visit<'ast> for ValidateLenFields<'_, '_> {
333333
fn visit_expr(&mut self, expr: &'ast syn::Expr) {
334334
if self.0.is_some() {
335335
return;

crates/hyperloglogplusplus/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl<'s, T, B> HyperLogLog<'s, T, B> {
123123
}
124124
}
125125

126-
impl<'s, T, B> HyperLogLog<'s, T, B>
126+
impl<T, B> HyperLogLog<'_, T, B>
127127
where
128128
T: Hash + ?Sized,
129129
B: BuildHasher,

crates/stats-agg/src/stats2d.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,11 +519,12 @@ impl<T: FloatLike> StatsSummary2D<T> {
519519
y: self.sy / self.n64(),
520520
})
521521
}
522+
522523
///returns the count of inputs as an i64
523524
///```
524525
/// use stats_agg::stats2d::StatsSummary2D;
525526
/// use stats_agg::XYPair;
526-
527+
///
527528
/// let p = StatsSummary2D::new_from_vec(vec![XYPair{y:2.0, x:1.0,}, XYPair{y:4.0, x:2.0,}, XYPair{y:6.0, x:3.0,}]).unwrap();
528529
/// let s = 3;
529530
/// assert_eq!(p.count(), s);

crates/udd-sketch/src/lib.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
55
use std::collections::hash_map::Entry;
66
use std::collections::HashMap;
77

8-
use crate::SketchHashKey::Zero;
8+
use crate::SketchHashKey::Invalid;
99
#[cfg(test)]
1010
use ordered_float::OrderedFloat;
1111
#[cfg(test)]
@@ -110,7 +110,7 @@ pub struct SketchHashIterator<'a> {
110110
next_key: SketchHashKey,
111111
}
112112

113-
impl<'a> Iterator for SketchHashIterator<'a> {
113+
impl Iterator for SketchHashIterator<'_> {
114114
type Item = (SketchHashKey, u64);
115115

116116
fn next(&mut self) -> Option<(SketchHashKey, u64)> {
@@ -284,7 +284,7 @@ impl SketchHashMap {
284284
entries[old_index] = current;
285285

286286
// We should only return the slice containing the aggregated values
287-
let iter = entries.into_iter().take(old_index + 1).peekable();
287+
let iter = entries.iter_mut().take(old_index + 1).peekable();
288288

289289
let mut iter = iter.peekable();
290290
self.head = iter.peek().map(|p| p.0).unwrap_or(Invalid);
@@ -304,7 +304,7 @@ impl SketchHashMap {
304304
#[inline]
305305
fn compact(&mut self) {
306306
match self.len() {
307-
0 => return,
307+
0 => (),
308308
// PERCENTILE_AGG_DEFAULT_SIZE defaults to 200, so
309309
// this entry covers that case.
310310
1..=200 => self.compact_using_stack::<200>(),
@@ -344,7 +344,8 @@ impl UDDSketch {
344344
alpha: initial_error,
345345
gamma: (1.0 + initial_error) / (1.0 - initial_error),
346346
compactions: 0,
347-
max_buckets: NonZeroU32::new(max_buckets as u32).expect("max buckets should be greater than zero"),
347+
max_buckets: NonZeroU32::new(max_buckets)
348+
.expect("max buckets should be greater than zero"),
348349
num_values: 0,
349350
values_sum: 0.0,
350351
}
@@ -361,8 +362,7 @@ impl UDDSketch {
361362
buckets: SketchHashMap::with_capacity(capacity),
362363
alpha: metadata.current_error,
363364
gamma: gamma(metadata.current_error),
364-
compactions: u8::try_from(metadata.compactions)
365-
.expect("compactions cannot be higher than 65"),
365+
compactions: metadata.compactions,
366366
max_buckets: NonZeroU32::new(metadata.max_buckets)
367367
.expect("max buckets should be greater than zero"),
368368
num_values: metadata.values,
@@ -376,7 +376,7 @@ impl UDDSketch {
376376

377377
// This assumes the keys are unique and sorted
378378
while let (Some(key), Some(count)) = (keys.next(), counts.next()) {
379-
let next = keys.peek().map(|k| *k).unwrap_or(Invalid);
379+
let next = keys.peek().copied().unwrap_or(Invalid);
380380
sketch
381381
.buckets
382382
.map
@@ -876,13 +876,13 @@ mod tests {
876876

877877
for i in 0..100 {
878878
assert!(((sketch.estimate_quantile((i as f64 + 1.0) / 100.0) / bounds[i]) - 1.0).abs() < sketch.max_error() * bounds[i].abs(),
879-
"Failed to correct match {} quantile with seed {}. Received: {}, Expected: {}, Error: {}, Expected error bound: {}",
880-
(i as f64 + 1.0) / 100.0,
881-
seed,
882-
sketch.estimate_quantile((i as f64 + 1.0) / 100.0),
883-
bounds[i],
884-
((sketch.estimate_quantile((i as f64 + 1.0) / 100.0) / bounds[i]) - 1.0).abs() / bounds[i].abs(),
885-
sketch.max_error());
879+
"Failed to correct match {} quantile with seed {}. Received: {}, Expected: {}, Error: {}, Expected error bound: {}",
880+
(i as f64 + 1.0) / 100.0,
881+
seed,
882+
sketch.estimate_quantile((i as f64 + 1.0) / 100.0),
883+
bounds[i],
884+
((sketch.estimate_quantile((i as f64 + 1.0) / 100.0) / bounds[i]) - 1.0).abs() / bounds[i].abs(),
885+
sketch.max_error());
886886
}
887887
}
888888

extension/src/asap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn asap_final_inner(
117117
})
118118
.collect();
119119

120-
let nulls_len = (points.len() + 7) / 8;
120+
let nulls_len = points.len().div_ceil(8);
121121

122122
Some(crate::build! {
123123
Timevector_TSTZ_F64 {
@@ -165,7 +165,7 @@ pub fn asap_on_timevector(
165165
})
166166
.collect();
167167

168-
let nulls_len = (points.len() + 7) / 8;
168+
let nulls_len = points.len().div_ceil(8);
169169

170170
Some(crate::build! {
171171
Timevector_TSTZ_F64 {

0 commit comments

Comments
 (0)