kumulant

Concurrency

Thread-safety mode for statistical accumulators. Each implementation documents how the mode maps to its cells and locks.

Bare stats default to None. A com.eignex.kumulant.schema.runtime.StatSchema can be materialised with a mode that applies to all of its stats.

  • None requires a single-threaded owner.

  • Relaxed uses atomic cells for additive and monotonic stats, permits drift for coupled recurrences, and locks structures that require serialised mutation.

  • Strict protects coupled recurrences with a lock.

  • HighWrite uses striped adders for additive JVM stats and behaves like Strict for coupled state and on other platforms.

Atomic updates to individual cells do not guarantee an atomic snapshot of several cells. Check each stat's concurrency documentation when snapshot consistency matters. Floating-point results can vary with update order even when updates are serialised.

Samples

val hits = SumStat(concurrency = Concurrency.HighWrite)
val ols = UnivariateRegressionStat(concurrency = Concurrency.Strict)
hits.update(1.0)
ols.update(x = 1.0, y = 2.0)

Entries

Link copied to clipboard

Single-threaded access with no synchronisation. Sharing a stat between threads under this mode can corrupt state or throw.

Link copied to clipboard

Concurrent updates with implementation-specific consistency. Independent cells use atomic updates. Coupled recurrences such as mean and variance can drift under contention; no numerical error bound is guaranteed. Sketches that require serialised mutation still lock.

Link copied to clipboard

Concurrent access with locks where coupled state requires them. Independent atomic cells remain lock-free; a multi-cell read is coherent only when the implementation holds a shared lock across reads and writes.

Link copied to clipboard

Striped adders for additive JVM stats, trading cheaper contended updates for a read that sums the stripes without an atomic snapshot. Behaves like Strict on non-JVM platforms and for stats whose state cannot be striped.

Properties

entries

Returns a representation of an immutable list of all enum entries, in the order they're declared.

This method may be used to iterate over the enum entries.

Link copied to clipboard
expect val name: String
Link copied to clipboard
expect val ordinal: Int

Functions

valueOf

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Throws

if this enum type has no constant with the specified name

values

Returns an array containing the constants of this enum type, in the order they're declared.

This method may be used to iterate over the constants.