Originally by @linear[bot] on 2026-02-17:
PRO-415
Originally by @GnaneshGnani on 2026-02-27:
Type / shape
CountMinSketch
sketch: Vec<Vec<f64>>
row_num: usize
col_num: usize
CountMin<S, Mode>
CountMin<Vector2D<i32>, RegularPath>
MatrixStorage
Vec<Vec<f64>>
Key argument
update(&str, f64)
query_key(&str) -> f64
&str
";"
insert(&SketchInput)
estimate(&SketchInput) -> S::Counter
SketchInput::Str("key")
SketchInput::String("key".into())
Value argument
value: f64
+ value
+1
insert
i32
i64
i128
many
insert_many
Hashing
xxhash_rust::xxh32(key_bytes, i as u32)
hash64_seeded(row_idx, &SketchInput)
Merge
merge(Vec<CountMinSketch>) -> Result<CountMinSketch, _>
merge_refs(&[&CountMinSketch]) -> Result<CountMinSketch, _>
merge(&mut self, &Self)
self
Serialization
serialize_msgpack() -> Vec<u8>
deserialize_msgpack(&[u8]) -> Result<Self, _>
{ row_num, col_num, sketch }
serialize_to_bytes() -> Result<Vec<u8>, _>
deserialize_from_bytes(&[u8]) -> Result<Self, _>
UDAF helpers
aggregate_count(depth, width, keys, values) -> Option<Vec<u8>>
aggregate_sum(depth, width, keys, values) -> Option<Vec<u8>>
Type / name
KllSketchData { k: u16, sketch_bytes: Vec<u8> }
KllSketch { k: u16, sketch: KllDoubleSketch }
KLL { items, levels, k, m, num_levels, ... }
Construction
KllSketch::new(k: u16)
KLL::init_kll(k: i32)
init(k: usize, m: usize)
Update input
update(value: f64)
f64
update(&SketchInput) -> Result<(), &'static str>
SketchInput
SketchInput::F64(value)
Query
get_quantile(q: f64) -> f64
quantile(q: f64) -> f64
cdf()
merge(Vec<KllSketch>) -> Result<KllSketch, _>
merge_refs(&[&KllSketch]) -> Result<KllSketch, _>
merge(&mut self, &KLL)
KllSketchData { k, sketch_bytes }
from_dsrs_bytes(&[u8], k)
KllSketchData
UDAF helper
aggregate_kll(k, values: &[f64]) -> Option<Vec<u8>>
Dedicated vs generic type
HydraKllSketch
HydraKllSketch { sketch: Vec<Vec<KllSketch>>, row_num, col_num }
Hydra { row_num, col_num, sketches: Vector2D<HydraCounter>, type_to_clone }
HydraCounter::KLL(KLL)
Update key/value
update(&str, value: f64)
KllSketch
update(&str, &SketchInput, Option<i32>)
value
';'
query(&str, quantile: f64) -> f64
KllSketch::get_quantile
query_key(Vec<&str>, &HydraQuery) -> f64
HydraQuery::Quantile(f64)
HydraQuery::Cdf(f64)
query_frequency(Vec<&str>, &SketchInput) -> f64
query_quantile(Vec<&str>, threshold: f64) -> f64
HydraKllSketch::query("key", q)
Hydra::query_key(vec!["key"], &HydraQuery::Quantile(q))
HydraKllSketch::new(row_num, col_num, k)
Hydra::with_dimensions(row_num, col_num, HydraCounter::KLL(KLL::init_kll(k)))
serialize_msgpack()
deserialize_msgpack()
HydraKllSketchData
serialize_to_bytes()
deserialize_from_bytes()
Hydra
aggregate_hydrakll(...) -> Option<Vec<u8>>
HllSketch
datafusion_summary_library
hyperloglogplus::HyperLogLogPlus
HyperLogLog<Regular>
HyperLogLog<DataFusion>
HllBucketList
HllSketch::new()
HyperLogLog::<Regular>::new()
HyperLogLog::<DataFusion>::new()
Insert input
insert<T: Hash>(&T)
insert_bytes(&[u8])
U64
Str
String
Bytes
Query (cardinality)
count() -> u64
estimate() -> usize
count()
merge(&mut self, &mut other)
hyperloglogplus
HyperLogLog<Variant>
to_bytes() -> Vec<u8>
from_bytes(&[u8]) -> Option<Self>
Activity
milindsrivastava1997 commentedon Mar 4, 2026
PRO-415
milindsrivastava1997 commentedon Mar 4, 2026
CountMin
Type / shape
CountMinSketchis a plain struct:sketch: Vec<Vec<f64>>row_num: usizecol_num: usizeCountMin<S, Mode>is generic:CountMin<Vector2D<i32>, RegularPath>MatrixStorageinstead of a rawVec<Vec<f64>>.Key argument
update(&str, f64)query_key(&str) -> f64&str(caller can pre-join labels with";"if needed).insert(&SketchInput)estimate(&SketchInput) -> S::CounterSketchInput::Str("key")orSketchInput::String("key".into()).Value argument
value: f64is added directly into the matrix cell (+ value).+1) and sum semantics.insertincrements an integer counter (i32/i64/i128) by 1 (or bymanyforinsert_many).Hashing
xxhash_rust::xxh32(key_bytes, i as u32)per row.hash64_seeded(row_idx, &SketchInput)(TwoX-based 64‑bit hash).Merge
merge(Vec<CountMinSketch>) -> Result<CountMinSketch, _>merge_refs(&[&CountMinSketch]) -> Result<CountMinSketch, _>merge(&mut self, &Self)selfin place.Serialization
serialize_msgpack() -> Vec<u8>deserialize_msgpack(&[u8]) -> Result<Self, _>{ row_num, col_num, sketch }via MessagePack.serialize_to_bytes() -> Result<Vec<u8>, _>deserialize_from_bytes(&[u8]) -> Result<Self, _>CountMinSketch.UDAF helpers
aggregate_count(depth, width, keys, values) -> Option<Vec<u8>>aggregate_sum(depth, width, keys, values) -> Option<Vec<u8>>KLL
Type / name
KllSketchData { k: u16, sketch_bytes: Vec<u8> }(wire wrapper).KllSketch { k: u16, sketch: KllDoubleSketch }.KLL { items, levels, k, m, num_levels, ... }.Construction
KllSketch::new(k: u16).KLL::init_kll(k: i32)(andinit(k: usize, m: usize)).Update input
update(value: f64)accepts a plainf64.update(&SketchInput) -> Result<(), &'static str>expects aSketchInputthat can be converted tof64(e.g.,SketchInput::F64(value)).Query
get_quantile(q: f64) -> f64.quantile(q: f64) -> f64.cdf()for CDF operations.Merge
merge(Vec<KllSketch>) -> Result<KllSketch, _>merge_refs(&[&KllSketch]) -> Result<KllSketch, _>merge(&mut self, &KLL)Serialization
serialize_msgpack() -> Vec<u8>anddeserialize_msgpack(&[u8]) -> Result<Self, _>KllSketchData { k, sketch_bytes }around the inner dsrs sketch serialization.from_dsrs_bytes(&[u8], k)for legacy formats.serialize_to_bytes() -> Result<Vec<u8>, _>deserialize_from_bytes(&[u8]) -> Result<Self, _>KllSketchData.UDAF helper
aggregate_kll(k, values: &[f64]) -> Option<Vec<u8>>.Hydra KLL
Dedicated vs generic type
HydraKllSketchtype:HydraKllSketch { sketch: Vec<Vec<KllSketch>>, row_num, col_num }.Hydra { row_num, col_num, sketches: Vector2D<HydraCounter>, type_to_clone }.HydraCounter::KLL(KLL).Update key/value
update(&str, value: f64):KllSketch.update(&str, &SketchInput, Option<i32>):valueis aSketchInput(e.g.SketchInput::F64(value)).';'and updates multiple combinations (multi-dimensional behavior).Query
query(&str, quantile: f64) -> f64:KllSketch::get_quantile, and returns the median across rows.query_key(Vec<&str>, &HydraQuery) -> f64:HydraQuery::Quantile(f64)(and can also useHydraQuery::Cdf(f64)).query_frequency(Vec<&str>, &SketchInput) -> f64query_quantile(Vec<&str>, threshold: f64) -> f64(CDF-based).HydraKllSketch::query("key", q)in sketch-core corresponds to:Hydra::query_key(vec!["key"], &HydraQuery::Quantile(q))in sketchlib-rust.Construction
HydraKllSketch::new(row_num, col_num, k).Hydra::with_dimensions(row_num, col_num, HydraCounter::KLL(KLL::init_kll(k))).Serialization
serialize_msgpack()anddeserialize_msgpack()onHydraKllSketchData.serialize_to_bytes()/deserialize_from_bytes()onHydra.UDAF helper
aggregate_hydrakll(...) -> Option<Vec<u8>>.HLL (HyperLogLog)
Type / name
HllSketchindatafusion_summary_library, wrappinghyperloglogplus::HyperLogLogPlus.HyperLogLog<Regular>andHyperLogLog<DataFusion>, using a customHllBucketListstorage.Construction
HllSketch::new()(with fixed precision).HyperLogLog::<Regular>::new()HyperLogLog::<DataFusion>::new().Insert input
insert<T: Hash>(&T)– accepts any hashable type directly.insert_bytes(&[u8]).insert(&SketchInput)– expects aSketchInput(e.g.U64,Str,String,Bytes).SketchInput.Query (cardinality)
count() -> u64.estimate() -> usize.count()alias by default; semantic is the same (returns a cardinality estimate).Merge
merge(&mut self, &mut other)(for thehyperloglogplustype).merge(&mut self, &Self)forHyperLogLog<Variant>.Serialization
to_bytes() -> Vec<u8>andfrom_bytes(&[u8]) -> Option<Self>usinghyperloglogplus’s internal format.serialize_to_bytes() -> Result<Vec<u8>, _>anddeserialize_from_bytes(&[u8]) -> Result<Self, _>using its own MessagePack-based format.