HyperLogLog - Rust
Distinct-count cardinality estimator. ~16 KB of state gives ~1% standard error up to 10^9 distinct.
Part of the submillisecond.com cookbook. Zero external dependencies; std only.
Install
[]
= "0.4"
Quickstart
Public API
pub struct HyperLogLogpub fn new(precision: u32) -> Selfpub fn precision(&self) -> u32pub fn register_count(&self) -> u32pub fn add(&mut self, key: &str)pub fn estimate(&self) -> f64pub fn merge(&mut self, other: &Self) -> Result<(), &'static str>
Files
src/lib.rs- implementation.tests/- integration tests; correctness, edge cases, property/stress.examples/demo.rs- stdout walkthrough.examples/perf_main.rs- bench entry (behind theharnessfeature).
License
Dual-licensed under MIT OR Apache-2.0.