Skip to main content

RollupColumnGenerator

Namespace: Meshmakers.Octo.Runtime.Contracts.StreamData

Derives the CkArchiveColumnSpec set a rollup archive must materialise to back its CkRollupAggregationSpec entries. Pure function, DB-neutral. The output is the same list a raw archive would carry in ArchiveSnapshot.Columns, so the existing DDL / query / insert paths can consume a rollup snapshot without branching on rollup-ness. Rollup-archives concept §4.

public static class RollupColumnGenerator

Inheritance ObjectRollupColumnGenerator

Remarks:

CkRollupFunction.Avg materialises as two columns ({base}_sum + {base}_count) so chained rollups stay numerically correct — the average is recomputed on read as sum / NULLIF(count, 0). The other functions map 1:1. All generated columns are Indexed = true and Required = false: aggregations can be null for empty buckets and the orchestrator's upsert is the only writer, so a missing value never indicates user error.

Methods

Generate(IReadOnlyList<CkRollupAggregationSpec>)

Generates the column list for a rollup archive from its aggregation specs. The path field of each emitted CkArchiveColumnSpec is the storage column name (already resolved via the lower-cased {sourcePath}{function} / explicit CkRollupAggregationSpec.TargetColumnName rule).

public static IReadOnlyList<CkArchiveColumnSpec> Generate(IReadOnlyList<CkRollupAggregationSpec> aggregations)

Parameters

aggregations IReadOnlyList<CkRollupAggregationSpec>

Returns

IReadOnlyList<CkArchiveColumnSpec>

Exceptions

ArgumentException
Thrown when two aggregations would produce the same target column name.

TargetColumnNamesFor(CkRollupAggregationSpec)

Returns the target column name(s) produced by one aggregation spec, in stable order. Single name for MIN/MAX/SUM/COUNT, two names for AVG ({base}_sum, {base}_count). Exposed so callers that need the same naming convention without instantiating CkArchiveColumnSpec values (e.g. the DDL generator) can share the logic.

public static IEnumerable<string> TargetColumnNamesFor(CkRollupAggregationSpec spec)

Parameters

spec CkRollupAggregationSpec

Returns

IEnumerable<String>