tisonkun opened a new pull request, #400: URL: https://github.com/apache/datasketches-rust/pull/400
Add `ddsketch` (`DdSketch`, `DdSketchBuilder`, `DdSketchIter`, `MappingKind`, and `StoreKind`) behind the `ddsketch` feature for mergeable quantile estimation over finite `f64` streams with relative-value error guarantees, based on the [DDSketch paper](https://www.vldb.org/pvldb/vol12/p2195-masson.pdf) and the [Datadog reference implementation](https://github.com/DataDog/sketches-java). ## Overview Existing quantile sketches in the crate bound normalized rank error (`kll`, `req`) or rely on heuristic centroid clustering (`tdigest`). `DdSketch` maps magnitudes to logarithmic buckets so any non-zero quantile from an uncollapsed bucket stays within `relative_accuracy * |value|` across wide dynamic ranges while remaining associative and order-independent under merging. - **Index mappings (`MappingKind`)**: Supports `Cubic` (default degree-3 significand interpolation with under 1% bucket overhead and platform-independent IEEE 754 updates), `Linear`, and `Logarithmic`. Inputs within `[-zero_threshold, zero_threshold]` (including subnormals) map to a dedicated zero bucket, and near-`f64::MAX` bucket representatives clamp to `f64::MAX` so all finite `f64` values are indexable without fallible updates. - **Bin stores (`StoreKind`)**: Supports `CollapsingLowestDense` (default `2048` bins per sign, collapsing smallest magnitudes to preserve high-magnitude tail accuracy within bounded memory), `CollapsingHighestDense` (collapsing largest magnitudes), `UnboundedDense`, and `Sparse` (`BTreeMap<i32, u64>`). Sketches sharing a compatible index mapping merge across heterogeneous store strategies. - **Queries and iteration**: Provides `quantile`, single-pass `quantiles` (using exact `u128` rank scaling above `2^53` total weight), bucket-approximated `min_value`, `max_value`, and `sum`, plus double-ended `ExactSizeIterator` traversal via `DdSketchIter`. - **Serialization**: Encodes and decodes the compact block-oriented binary format of the reference DDSketch implementations (`sketches-java`, `sketches-go`, `sketches-py`, and `sketches-js`), automatically picking the smallest bin representation among `ContiguousCounts`, `IndexDeltas`, and `IndexDeltasAndCounts`, skipping optional `DDSketchWithExactSummaryStatistics` summary blocks, and bounding decoded dense index spans. ## Validation - `cargo x prepare-testdata rust` (`ddsketch_cubic_n*_rust.sk` and `ddsketch_signed_n*_rust.sk`) - `cargo x lint`, `cargo x check`, `cargo x test`, and MSRV (`1.86.0`) check - `cargo run --package examples --example ddsketch_tail_latency` - `cargo x bench -- ddsketch` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
