apache-datasketches
Safe, idiomatic Rust bindings for Apache DataSketches,
built via the cxx crate over
apache-datasketches-sys.
Usage
use ;
let mut sketch = new?;
sketch.update_str;
sketch.update_u64;
println!;
Merging multiple sketches with HllUnion:
use ;
let mut sketch1 = new?;
sketch1.update_u64;
let mut sketch2 = new?;
sketch2.update_u64;
let mut union = new?;
union.update_sketch;
union.update_sketch;
let result = union.get_result;
println!;
HllSketch supports serialize_compact/serialize_updatable and
HllSketch::deserialize for persisting sketches. HllUnion has no
serializable state of its own upstream (only its result sketch does),
so HllUnion::serialize_compact/serialize_updatable serialize
get_result(tgt_type) directly — to resume accumulating after
deserializing, feed the deserialized HllSketch back into a new
HllUnion via update_sketch.
See examples/hll.rs (cargo run -p apache-datasketches --example hll)
for a complete runnable demo.
Sketch families
- HLL (HyperLogLog) —
hllfeature, enabled by default (sketch + union).
License
Dual-licensed under MIT or Apache-2.0, at your option.