Skip to content
Open
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.6.1](https://github.com/pmcgleenon/heavykeeper-rs/compare/v0.6.0...v0.6.1) - 2025-09-02

### Other

- added Sync to rng
- Merge pull request #52 from pmcgleenon/dependabot/cargo/criterion-0.7.0

## [0.6.0](https://github.com/pmcgleenon/heavykeeper-rs/compare/v0.5.1...v0.6.0) - 2025-07-27

### Other
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "heavykeeper"
version = "0.6.0"
version = "0.6.1"
edition = "2021"
authors = [ "Patrick McGleenon"]
description = "HeavyKeeper is for finding Top-K elephant flows with high precision and low memory footprint."
Expand Down
16 changes: 13 additions & 3 deletions src/heavykeeper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub struct TopK<T: Ord + Clone + Hash + Debug> {
buckets: Vec<Vec<Bucket>>,
priority_queue: TopKQueue<T>,
hasher: RandomState,
random: Box<dyn RngCore + Send>,
random: Box<dyn RngCore + Send + Sync>,
}

pub struct Builder<T> {
Expand All @@ -85,7 +85,7 @@ pub struct Builder<T> {
decay: Option<f64>,
seed: Option<u64>,
hasher: Option<RandomState>,
rng: Option<Box<dyn RngCore + Send>>,
rng: Option<Box<dyn RngCore + Send + Sync>>,
_phantom: std::marker::PhantomData<T>,
}

Expand Down Expand Up @@ -133,6 +133,7 @@ impl<T: Ord + Clone + Hash + Debug> TopK<T> {
)
}

<<<<<<< HEAD
fn with_components(
k: usize,
width: usize,
Expand All @@ -141,6 +142,9 @@ impl<T: Ord + Clone + Hash + Debug> TopK<T> {
hasher: RandomState,
rng: Box<dyn RngCore + Send>,
) -> Self {
=======
fn with_components(k: usize, width: usize, depth: usize, decay: f64, hasher: RandomState, rng: Box<dyn RngCore + Send + Sync>) -> Self {
>>>>>>> origin/main
// Pre-allocate with capacity to avoid resizing
let mut buckets = Vec::with_capacity(depth);
for _ in 0..depth {
Expand Down Expand Up @@ -430,6 +434,12 @@ impl<T: Ord + Clone + Hash + Debug> Default for Builder<T> {
}
}

impl<T: Ord + Clone + Hash + Debug> Default for Builder<T> {
fn default() -> Self {
Self::new()
}
}

impl<T: Ord + Clone + Hash + Debug> Builder<T> {
pub fn new() -> Self {
Self {
Expand Down Expand Up @@ -474,7 +484,7 @@ impl<T: Ord + Clone + Hash + Debug> Builder<T> {
self
}

pub fn rng<R: RngCore + Send + 'static>(mut self, rng: R) -> Self {
pub fn rng<R: RngCore + Send + Sync + 'static>(mut self, rng: R) -> Self {
self.rng = Some(Box::new(rng));
self
}
Expand Down