Skip to content

shadowmodder/cmsketch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cmsketch

A small, dependency-free Count-Min Sketch in Rust — approximate frequency counts over high-cardinality streams (device fingerprints, IPs, event keys) in sublinear memory. Library + CLI.

Library

use cmsketch::CountMinSketch;

let mut cms = CountMinSketch::with_error(0.001, 0.01); // ~0.1% error, 99% confidence
cms.add(b"device-123", 1);
cms.add(b"device-123", 1);
assert!(cms.estimate(b"device-123") >= 2); // never underestimates

CLI

cat events.txt | cmsketch device-123 1.2.3.4
# device-123   42
# 1.2.3.4      7

Test

cargo test

Estimates never undercount; overcounting is bounded by the configured error. MIT licensed.

About

A small, dependency-free [Count-Min Sketch](https://en.wikipedia.org/wiki/Count%E2%80%93min_sketch) in Rust —

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages