Skip to content

Commit

Permalink
Merge pull request #11 from adamreichold/default-ddsketch
Browse files Browse the repository at this point in the history
Lift Default impl for Config to one for DDSketch.
  • Loading branch information
mheffner authored Feb 4, 2024
2 parents 36a455a + 306d007 commit e5bb952
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/ddsketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl Store {
}

pub fn count(&self) -> u64 {
self.count as u64
self.count
}

pub fn merge(&mut self, other: &Store) {
Expand Down Expand Up @@ -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]
}

Expand Down

0 comments on commit e5bb952

Please sign in to comment.