Module: count_min
Contents
StructsCountMinSketch- A space-efficient probabilistic data structure for frequency estimation.
resq_dsa::count_min::CountMinSketch
Struct A space-efficient probabilistic data structure for frequency estimation. The Count-Min sketch can estimate the frequency of events with guaranteed error bounds. It may overcount but never undercounts (like Bloom filters, this is a property of the algorithm).Algorithm
Usesdepth independent FNV-1a hash functions (seeded variants) to map
elements to positions in width columns. The estimated count is the
minimum across all hash table rows.
Error Bounds
- Error is at most
epsilon * total_countwith probability1 - delta - Smaller epsilon/delta values require more memory
Use Cases
- Tracking event frequencies
- Network traffic analysis
- Distributed counting without central aggregation
Examples
fn new(epsilon: f64, delta: f64) -> Self- Creates a new Count-Min sketch with the given error parameters.fn from_raw_params(width: usize, depth: usize) -> Self- Creates a new Count-Min sketch from pre-computed dimensions.fn increment<impl AsRef<[u8]>>(self: & mut Self, key: impl Trait, count: u64)- Increments the count for a key by the given amount.fn estimate<impl AsRef<[u8]>>(self: &Self, key: impl Trait) -> u64- Estimates the count for a key.