subms-hyperloglog 0.4.0

submillisecond.com cookbook recipe - data-structures: subms-hyperloglog. Distinct-count cardinality estimator. ~1% standard error at ~16 KB.
Documentation
  • Coverage
  • 62.5%
    5 out of 8 items documented1 out of 8 items with examples
  • Size
  • Source code size: 13.98 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 292.69 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kdog007

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.