Skip to main content

Module hll

Module hll 

Source
Expand description

HyperLogLog (HLL) cardinality estimation.

use apache_datasketches::hll::{HllSketch, TargetHllType};

let mut sketch = HllSketch::new(12, TargetHllType::Hll4)?;
sketch.update_str("some-key");
sketch.update_u64(42);
println!("estimate: {}", sketch.get_estimate());

HllUnion merges multiple sketches into one, e.g. combining per-shard/per-day counts into a total distinct count.

Structs§

HllSketch
A HyperLogLog sketch: estimates the number of distinct items added via update_*, using bounded memory regardless of how many items are added.
HllUnion
Merges multiple HllSketches into one, e.g. combining per-shard or per-day counts into a total distinct count across all of them.

Enums§

TargetHllType
Controls the internal representation HLL uses to store per-bucket state, trading memory for accuracy. Mirrors upstream’s datasketches::target_hll_type.