Crate ddsketch

Crate ddsketch 

Source
Expand description

DDSketch implementations for quantile estimation.

This crate provides two DDSketch implementations:

  • agent: Optimized for the Datadog Agent, with fixed compile-time configuration. Use this when you need wire compatibility with the Datadog Agent or maximum insertion performance.

  • canonical: Full implementation mirroring the official sketches-go library. Use this when you need runtime-configurable accuracy or different store types.

§Quick Start

For most use cases, the agent implementation (re-exported at the crate root) is sufficient:

use ddsketch::DDSketch;

let mut sketch = DDSketch::default();
sketch.insert(1.0);
sketch.insert(2.0);
sketch.insert(3.0);

let median = sketch.quantile(0.5);

For the canonical implementation with configurable accuracy:

use ddsketch::canonical::DDSketch;

let mut sketch = DDSketch::with_relative_accuracy(0.01).unwrap();
sketch.add(1.0);
sketch.add(2.0);
sketch.add(3.0);

let median = sketch.quantile(0.5);

§Feature Flags

  • serde: Enables serialization/deserialization for the agent implementation. Warning: The serialization format is not guaranteed to be stable.

Re-exports§

pub use agent::Bin;
pub use agent::Bucket;
pub use agent::DDSketch;

Modules§

agent
Agent-specific DDSketch implementation.
canonical
Canonical implementation of DDSketch.