Module hyperloglog_rs::iter
source · Expand description
This module defines a trait and an implementation for estimating the cardinality of an iterator using a HyperLogLog data structure.
Example
You can estimate the cardinality of an iterator using the estimate_cardinality
method.
use hyperloglog_rs::prelude::*;
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let cardinality_estimate = v.iter().estimate_cardinality::<Precision12, 5>();
assert!((cardinality_estimate - 10.0).abs() < 1.0);
You can merge multiple HyperLogLog counters from iterators using the union
method.
use hyperloglog_rs::prelude::*;
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let hll: HyperLogLog<Precision12, 6> = v.into_iter().map(|index|{
HyperLogLog::from(index)
}).union();
let cardinality_estimate = hll.estimate_cardinality();
assert!((cardinality_estimate - 10.0).abs() < 1.0);
Traits
- A trait for estimating the cardinality of an iterator.