MetricsMap

@Serializable(with = MetricsMapSerializer::class)
class MetricsMap(map: MutableMap<MetricKey<Metric>, Metric> = mutableMapOf())

A mutable, typed wrapper around Map<MetricKey<*>, Metric>.

Mutability invariant: MetricsMap is always updated in-place via recomputeAll and set. It is never replaced wholesale on a StageRecord -- the same instance is mutated throughout the stage's lifetime. The plus operator creates a new instance (used only during preset composition at stage creation time).

Serialized like a plain Map, e.g. { "metric_key_id": { ... metric fields ... }, ... }.

Constructors

Link copied to clipboard
constructor(map: MutableMap<MetricKey<Metric>, Metric> = mutableMapOf())

Types

Link copied to clipboard
object Companion

Factory helpers for building a MetricsMap.

Properties

Link copied to clipboard

The key/metric pairs currently held by this map.

Functions

Link copied to clipboard
operator fun <T : Metric> get(key: MetricKey<T>): T?

Returns the metric stored under key, or null if absent.

Link copied to clipboard
operator fun plus(other: MetricsMap): MetricsMap

Returns a new MetricsMap containing this map's entries plus other's (the latter wins on key clashes).

Link copied to clipboard
fun recomputeAll(currentStage: StageRecord, substages: List<TrainingRecord>, isStageUpdate: Boolean)

Recompute all metrics in-place from the given substages.

Link copied to clipboard
operator fun <T : Metric> set(key: MetricKey<T>, value: T)

Stores value under key, replacing any existing metric with that key.

Link copied to clipboard

Returns an immutable snapshot of the underlying key-to-metric map.

Link copied to clipboard
open override fun toString(): String

Renders the map as {key_id: metric, ...}.