Skip to content

Commit

Permalink
chore: random - dependabot upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
pmcgleenon committed Feb 6, 2025
1 parent a144986 commit a1b45a4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/heavykeeper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl<T: Ord + Clone + Hash + Debug> TopK<T> {
buckets,
priority_queue,
hasher,
random: SmallRng::from_entropy(),
random: SmallRng::from_os_rng(),
}
}

Expand Down Expand Up @@ -118,7 +118,7 @@ impl<T: Ord + Clone + Hash + Debug> TopK<T> {

for i in 0..self.depth {
let combined = (item_fingerprint, i);
let bucket_idx = self.hasher.hash_one(&combined) % self.width as u64;
let bucket_idx = self.hasher.hash_one(combined) % self.width as u64;
let bucket_idx = bucket_idx as usize;
let bucket = &mut self.buckets[i][bucket_idx];

Expand All @@ -138,7 +138,7 @@ impl<T: Ord + Clone + Hash + Debug> TopK<T> {
self.decay_thresholds.last().cloned().unwrap_or_default()
};
// Apply bitwise decay based on the decay threshold
let rand = self.random.gen::<u64>();
let rand = self.random.random::<u64>();
if rand < decay_threshold {
bucket.count = bucket.count.saturating_sub(1);
}
Expand Down Expand Up @@ -665,4 +665,4 @@ mod tests {
// This item was never added
assert_eq!(topk.count(&"item4".as_bytes()), 5);
}
}
}

0 comments on commit a1b45a4

Please sign in to comment.