kumulant

CountStat

class CountStat(concurrency: Concurrency = Concurrency.None) : SeriesStat<SumResult> (source)

Observation count: each update contributes 1 regardless of supplied value and weight.

Use cases: event rate denominators, sample sizes, "how many".

Memory: O(1).

Update: O(1).

Concurrency: Inherits SumStat's concurrency model.

Constructors

Link copied to clipboard
constructor(concurrency: Concurrency = Concurrency.None)

Properties

Link copied to clipboard
open override val concurrency: Concurrency

The thread-safety contract this stat was constructed with. Each stat picks the cell-encoding and lock strategy that honours this contract for its mathematical structure:

Functions

Link copied to clipboard
open override fun create(concurrency: Concurrency? = null): SeriesStat<SumResult>

Spawn a fresh accumulator with the same configuration. Optionally override the Concurrency; useful for materialising a wire spec at a different concurrency level than the source.

Link copied to clipboard
open override fun merge(values: SumResult)

Fold another accumulator's snapshot into this one. The unit of merge is the immutable Result; not a live Stat; which is what lets the merge cross a process boundary. Many workers track slices of the same stream, call read periodically, ship snapshots to a coordinator, and the coordinator merges them in.

Link copied to clipboard
open override fun read(timestampNanos: Long = currentTimeNanos()): SumResult

Materialise the current state as an immutable Result. Reads never mutate, so the caller can read as often as it likes without affecting the stream.

Link copied to clipboard
open override fun reset()

Reset the stat to its prior-seeded baseline. Equivalent to constructing a fresh stat with the same configuration, but in place; keeps the same Concurrency and any per-stat tunables.

Link copied to clipboard
open override fun update(value: Double, weight: Double = 1.0)

Record an observation with the given weight, stamped at the current time.

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

Record an observation at timestampNanos with the given weight. Stats that consume time (rates, decay, windowing) use this as the ordering signal; pass a monotonic stamp when feeding from a replay log.

CountStat

constructor(concurrency: Concurrency = Concurrency.None)(source)