sketches-rust
This is a direct port of the java DDSketch quantile implementation writen by Rust. DDSketch is mergeable, meaning that multiple sketches from distributed systems can be combined in a central node.
Features
It aims at as compatible as possible with Java implementations, here is some features has support:
- CubicallyInterpolatedMapping
- LogarithmicMapping
- CollapsingHighestDenseStore: collapse the highest bucket when reach specified size
- CollapsingLowestDenseStore: collapse the lowest bucket when reach specified size
- UnboundedSizeDenseStore: unlimited bucket
- Merge with other instance
- Deserialize from bytes
- Serialize to bytes
Usage
Run the following Cargo command in your project directory:
cargo add sketches-rust
Or add the following line to your Cargo.toml:
sketches-rust = "0.2.2"
Demos
Query quantile:
use DDSketch;
let mut d = collapsing_lowest_dense.unwrap;
d.accept;
d.accept;
d.accept;
let c = d.get_count;
assert_eq!;
let q = d.get_value_at_quantile.unwrap;
assert!;
Merge with other instance:
use DDSketch;
let mut d1 = collapsing_lowest_dense.unwrap;
d1.accept;
d1.accept;
d1.accept;
assert_eq!;
let mut d2 = collapsing_lowest_dense.unwrap;
d2.accept;
d2.accept;
d2.accept;
assert_eq!;
d2.merge_with.unwrap;
assert_eq!;
Serialize to bytes:
use DDSketch;
let mut d = unbounded_dense.unwrap;
d.accept;
d.accept;
d.accept;
d.accept;
d.accept;
println!;
Deserialize from bytes:
use DDSketch;
let mut input = vec!;
let mut d = decode.unwrap;
assert_eq!;