subms-hyperloglog 0.5.0

submillisecond.com cookbook recipe - data-structures: subms-hyperloglog. Distinct-count cardinality estimator. ~1% standard error at ~16 KB.
Documentation

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

[dependencies]
subms-hyperloglog = "0.4"

Quickstart

cargo test --release
cargo run --example demo

Public API

  • pub struct HyperLogLog
  • pub fn new(precision: u32) -> Self
  • pub fn precision(&self) -> u32
  • pub fn register_count(&self) -> u32
  • pub fn add(&mut self, key: &str)
  • pub fn estimate(&self) -> f64
  • pub 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 the harness feature).

License

Dual-licensed under MIT OR Apache-2.0.