kumulant

DiscreteStat

interface DiscreteStat<R : Result> : Stat<R> (source)

Accumulator over a stream of discrete Long values. The Long carries two interpretations across the family:

  • Opaque keys: cardinality estimators (HyperLogLogStat), heavy-hitter sketches (SpaceSavingStat), Bloom filters (BloomFilterStat). The numeric value of the Long is irrelevant; only equality matters. Hash domain-specific keys through com.eignex.kumulant.math.hash64 first so the input carries uniform 64-bit entropy.

  • Integer-valued measurements: Poisson counts, time deltas, integer histograms. Here the value is meaningful and arithmetic is applied to it.

Each concrete stat documents which interpretation it uses.

Inheritors

Properties

Link copied to clipboard
abstract val concurrency: Concurrency

Thread-safety mode fixed at construction. See Concurrency for the shared contract and the implementation's KDoc for its cell and lock strategy.

Functions

create

abstract override fun create(concurrency: Concurrency? = null): DiscreteStat<R>(source)

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.

update

open fun update(value: Long, weight: Double = 1.0)(source)

Record value with weight at the current monotonic time.


abstract fun update(value: Long, timestampNanos: Long, weight: Double = 1.0)(source)

Record value with weight at timestampNanos.

Link copied to clipboard
abstract fun merge(values: R, timestampNanos: Long = currentTimeNanos())

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.

Link copied to clipboard
abstract fun read(timestampNanos: Long = currentTimeNanos()): R

Return the current result evaluated at timestampNanos. Time-independent statistics ignore the timestamp. Reading does not add an observation.

Link copied to clipboard
abstract fun reset()

Restore the configured baseline, including any prior seed. Preserves the configuration and concurrency.

Link copied to clipboard
open fun validateMerge(values: R)

Validate values for merge without changing accumulator state. Containers validate every child before merging any of them. Successful validation checks compatibility; it does not make a concurrent merge transactional.