Class TimeSeriesCollapseOperator
- All Implemented Interfaces:
Closeable,AutoCloseable,Operator,Releasable
Groups are the output dimensions from the preceding aggregation. For each group this operator stores values by requested
time step, then emits the steps in range order so the step and value multi-valued columns stay positionally aligned.
The collapse state is a dense grid of groupId x stepOrdinal flattened into parallel values and seen
arrays:
stepCount = 4
steps = [10, 20, 30, 40]
| group 0 | group 1 | group 2 |
|-----------------------|-----------------------|-----------------------|
stepOrdinal | 0 | 1 | 2 | 3 | 0 | 1 | 2 | 3 | 0 | 1 | 2 | 3 |
timestamp | 10 | 20 | 30 | 40 | 10 | 20 | 30 | 40 | 10 | 20 | 30 | 40 |
flat index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
values[] | 1.2 | -- | 3.4 | -- | -- | 8.1 | -- | 8.4 | 5.0 | -- | -- | -- |
seen[] | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 0 |
The grouping hash maps dimension keys to the groupId slices:
{host=h1, metric=cpu} -> group 0 -> flat indexes 0..3
{host=h2, metric=cpu} -> group 1 -> flat indexes 4..7
{host=h3, metric=mem} -> group 2 -> flat indexes 8..11
The value storage grows to the end of a group's slice when that group is first encountered, so observing group 1
grows the value array to at least flat index 7 + 1. The seen bitset still marks only the slots that
actually received values.
The value column is ElementType.DOUBLE only for now (e.g. PROMQL scalar outputs).
Step semantics: step is a fixed millisecond interval and the operator assumes input timestamps fall
on the uniform grid start, start + step, start + 2*step, ..., end. Calendar units (months, years) and
timezone-aware steps that span DST transitions are not supported — input timestamps that don't satisfy
(timestamp - start) % step == 0 are rejected with an IllegalArgumentException. This matches PROMQL
query_range semantics; for calendar-aware bucketing, use a different operator wired to Rounding.Prepared.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.elasticsearch.compute.operator.HashAggregationOperator
HashAggregationOperator.Builder, HashAggregationOperator.StatusNested classes/interfaces inherited from interface org.elasticsearch.compute.operator.Operator
Operator.OperatorFactory -
Field Summary
Fields inherited from class org.elasticsearch.compute.operator.HashAggregationOperator
aggregatorFactories, aggregatorMode, aggregators, blockHash, blockHashSupplier, DEFAULT_PARTIAL_EMIT_KEYS_THRESHOLD, DEFAULT_PARTIAL_EMIT_UNIQUENESS_THRESHOLD, driverContext, emitCount, emitNanos, output, partialEmitKeysThreshold, partialEmitUniquenessThreshold, rowsAddedInCurrentBatchFields inherited from interface org.elasticsearch.compute.operator.Operator
MIN_TARGET_PAGE_SIZE, NOT_BLOCKED, TARGET_PAGE_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionTimeSeriesCollapseOperator(List<BlockHash.GroupSpec> groups, int valueChannel, int stepChannel, long start, long end, long step, int maxPageSize, Supplier<BlockHash> blockHash, DriverContext driverContext) -
Method Summary
Methods inherited from class org.elasticsearch.compute.operator.HashAggregationOperator
addInput, canProduceMoreDataWithoutExtraInput, checkState, close, customizeSelected, evaluationContext, finish, getOutput, isFinished, needsInput, statusMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.compute.operator.Operator
isBlocked, tryPromote
-
Constructor Details
-
TimeSeriesCollapseOperator
public TimeSeriesCollapseOperator(List<BlockHash.GroupSpec> groups, int valueChannel, int stepChannel, long start, long end, long step, int maxPageSize, Supplier<BlockHash> blockHash, DriverContext driverContext)
-
-
Method Details
-
emit
protected void emit()- Overrides:
emitin classHashAggregationOperator
-
shouldEmitPartialResultsPeriodically
protected boolean shouldEmitPartialResultsPeriodically()- Overrides:
shouldEmitPartialResultsPeriodicallyin classHashAggregationOperator
-
toString
- Overrides:
toStringin classHashAggregationOperator
-