DDSketchStat
DDSketchStat: relative-error quantile sketch with logarithmic bins.
Targets relativeError for quantile values within the indexable range. Out-of-range magnitudes fold into edge bins and lose that guarantee. Supports negative values via mirrored bins and a zero bucket. At a fixed indexable range, tightening relativeError grows bin count roughly as 1/epsilon.
Use cases: quantile / percentile monitoring of any positive-skewed scalar (latencies, payload sizes). Reach for this over TDigestStat when relative-error guarantees are required.
Memory: bounded by the indexable range, at log([maxIndexableValue] / [minIndexableValue]) / log(1 + [relativeError]) bins; roughly 2400 bins at the defaults. Values outside the range fold into the edge bins and still count toward every rank, so the bound holds whatever the input. Narrow the range if you know your data's span and want fewer bins at a tighter relativeError.
Update: O(1) per observation; one log/bin-assignment + striped atomic add. A NaN weight is inert, as everywhere in the library. A NaN value is a real observation with no bin of its own, so it falls into the zero bucket; filter it upstream with !X.isNaN() when that is not wanted.
Concurrency: Independent additive bins preserve per-cell updates under concurrent modes. Concurrency.HighWrite uses striped adders on the JVM; Concurrency.None uses plain cells. Multi-bin reads are not atomic, and floating-point results depend on update order.
Constructors
DDSketchStat
Properties
concurrency
Thread-safety mode fixed at construction. See Concurrency for the shared contract and the implementation's KDoc for its cell and lock strategy.
maxIndexableValue
Largest magnitude given its own bin. Anything larger folds into the top bin, on the same terms as minIndexableValue.
minIndexableValue
Smallest magnitude given its own bin. Anything smaller (but non-zero) folds into the bottom bin, so it still counts toward the rank but stops driving bin allocation.
probabilities
Quantiles to evaluate at read time.
relativeError
Relative value error target within the indexable range.
Functions
create
Create an independent accumulator at the configured baseline. A null concurrency preserves this accumulator's mode; a non-null value overrides it. Modality subtypes narrow the return type to preserve the input shape.
merge
Fold a compatible snapshot values into this accumulator at timestampNanos. Implementations document whether the combine is exact or approximate and which state the snapshot omits. The source accumulator is unaffected.
Time-dependent statistics, such as windows, place the snapshot at timestampNanos, which must share the clock the caller uses for updates and reads. Time-independent statistics ignore it.
read
Return the current result evaluated at timestampNanos. Time-independent statistics ignore the timestamp. Reading does not add an observation.
Snapshot consistency depends on the implementation's synchronisation. Locks protect coupled state under Concurrency.Strict and Concurrency.HighWrite; independently updated cells and JVM striped adders can still yield a best-effort snapshot. Concurrency.Relaxed permits drift across coupled cells.
reset
Restore the configured baseline, including any prior seed. Preserves the configuration and concurrency.