A count min sketch implementation in Rust.
Ported from Facebook/CacheLib.
```rust use cmsketch::CMSketchU32;
const ERROR: f64 = 0.01; const PROBABILITY: f64 = 0.95; const MAXWIDTH: usize = 0; // no limits const MAXDEPTH: usize = 0; // no limits
fn main() { let mut cms = CMSketchU32::new(ERROR, PROBABILITY, MAXWIDTH, MAXDEPTH);
for i in 0..10 {
for _ in 0..i {
cms.record(i);
}
}
for i in 0..10 {
assert!(cms.count(i) >= i as u32);
}
cms.decay(0.5);
for i in 0..10 {
assert!(cms.count(i) >= (i as f64 * 0.5) as u32);
}
} ```