ddsketch/canonical/
mod.rs

1//! Canonical implementation of DDSketch.
2//!
3//! This module provides a DDSketch implementation that closely follows the official Datadog implementations of
4//! DDSketch, with configurable storage and index mappings.
5//!
6//! # Quick Start
7//!
8//! ```
9//! use ddsketch::canonical::DDSketch;
10//!
11//! // Create a sketch with 1% relative accuracy
12//! let mut sketch = DDSketch::with_relative_accuracy(0.01).unwrap();
13//!
14//! // Add some values
15//! sketch.add(1.5);
16//! sketch.add(2.5);
17//! sketch.add(3.5);
18//!
19//! // Query quantiles
20//! let p50 = sketch.quantile(0.5);
21//! let p99 = sketch.quantile(0.99);
22//! ```
23//!
24//! # Store Types
25//!
26//! The canonical implementation supports multiple store types:
27//!
28//! - [`CollapsingLowestDenseStore`][store::CollapsingLowestDenseStore]: Collapses lowest bins when limit is
29//!   reached. Best for when higher quantiles (p95, p99) matter most.
30//! - [`CollapsingHighestDenseStore`][store::CollapsingHighestDenseStore]: Collapses highest bins when limit is
31//!   reached. Best for when lower quantiles (p1, p5) matter most.
32//! - [`DenseStore`][store::DenseStore]: Unbounded dense storage. Best when memory is not a concern.
33//! - [`SparseStore`][store::SparseStore]: Hash-based storage. Best for widely scattered values.
34
35mod error;
36pub use self::error::ProtoConversionError;
37
38pub mod mapping;
39pub use self::mapping::IndexMapping;
40
41pub mod store;
42pub use self::store::Store;
43
44mod sketch;
45pub use self::sketch::DDSketch;