Skip to content

Commit 46c6562

Browse files
Cargo fmt
1 parent ef0696c commit 46c6562

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

crates/udd-sketch/src/lib.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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 as u32)
348+
.expect("max buckets should be greater than zero"),
348349
num_values: 0,
349350
values_sum: 0.0,
350351
}
@@ -361,8 +362,10 @@ 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).expect("compactions cannot be higher than 65"),
365-
max_buckets: NonZeroU32::new(metadata.max_buckets).expect("max buckets should be greater than zero"),
365+
compactions: u8::try_from(metadata.compactions)
366+
.expect("compactions cannot be higher than 65"),
367+
max_buckets: NonZeroU32::new(metadata.max_buckets)
368+
.expect("max buckets should be greater than zero"),
366369
num_values: metadata.values,
367370
values_sum: metadata.sum,
368371
};
@@ -864,13 +867,13 @@ mod tests {
864867

865868
for i in 0..100 {
866869
assert!(((sketch.estimate_quantile((i as f64 + 1.0) / 100.0) / bounds[i]) - 1.0).abs() < sketch.max_error() * bounds[i].abs(),
867-
"Failed to correct match {} quantile with seed {}. Received: {}, Expected: {}, Error: {}, Expected error bound: {}",
868-
(i as f64 + 1.0) / 100.0,
869-
seed,
870-
sketch.estimate_quantile((i as f64 + 1.0) / 100.0),
871-
bounds[i],
872-
((sketch.estimate_quantile((i as f64 + 1.0) / 100.0) / bounds[i]) - 1.0).abs() / bounds[i].abs(),
873-
sketch.max_error());
870+
"Failed to correct match {} quantile with seed {}. Received: {}, Expected: {}, Error: {}, Expected error bound: {}",
871+
(i as f64 + 1.0) / 100.0,
872+
seed,
873+
sketch.estimate_quantile((i as f64 + 1.0) / 100.0),
874+
bounds[i],
875+
((sketch.estimate_quantile((i as f64 + 1.0) / 100.0) / bounds[i]) - 1.0).abs() / bounds[i].abs(),
876+
sketch.max_error());
874877
}
875878
}
876879

extension/src/uddsketch.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ impl From<SerializedUddSketch> for UddSketchInternal {
152152
&UDDSketchMetadata {
153153
max_buckets: sketch.max_buckets,
154154
current_error: sketch.alpha,
155-
compactions: u8::try_from(sketch.compactions).expect("compactions cannot be higher than 65"),
155+
compactions: u8::try_from(sketch.compactions)
156+
.expect("compactions cannot be higher than 65"),
156157
values: sketch.count,
157158
sum: sketch.sum,
158159
buckets: sketch.num_buckets,
@@ -312,7 +313,8 @@ impl<'input> UddSketch<'input> {
312313
UDDSketchMetadata {
313314
max_buckets: self.max_buckets,
314315
current_error: self.alpha,
315-
compactions: u8::try_from(self.compactions).expect("compactions cannot be higher than 65"),
316+
compactions: u8::try_from(self.compactions)
317+
.expect("compactions cannot be higher than 65"),
316318
values: self.count,
317319
sum: self.sum,
318320
buckets: self.num_buckets,

0 commit comments

Comments
 (0)