From 306d0072b49a71f9a03d60ae0362fed0d253a484 Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Sat, 3 Feb 2024 23:08:41 +0100 Subject: [PATCH] Lift Default impl for Config to one for DDSketch. --- src/ddsketch.rs | 6 ++++++ src/store.rs | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ddsketch.rs b/src/ddsketch.rs index a408533..8133aa8 100644 --- a/src/ddsketch.rs +++ b/src/ddsketch.rs @@ -47,6 +47,12 @@ pub struct DDSketch { zero_count: u64, } +impl Default for DDSketch { + fn default() -> Self { + Self::new(Default::default()) + } +} + // XXX: functions should return Option<> in the case of empty impl DDSketch { /// Construct a `DDSketch`. Requires a `Config` specifying the parameters of the sketch diff --git a/src/store.rs b/src/store.rs index 8fe2b6b..66217f8 100644 --- a/src/store.rs +++ b/src/store.rs @@ -174,7 +174,7 @@ impl Store { } pub fn count(&self) -> u64 { - self.count as u64 + self.count } pub fn merge(&mut self, other: &Store) { @@ -203,7 +203,7 @@ impl Store { collapse_end_index = collapse_start_index; } - for key in (collapse_end_index as i32 + other.offset)..(other.max_key + 1) { + for key in (collapse_end_index + other.offset)..(other.max_key + 1) { self.bins[(key - self.offset) as usize] += other.bins[(key - other.offset) as usize] }