Interface AggregateFunction<ACC>
- Type Parameters:
ACC- the accumulator type
- All Known Subinterfaces:
AggregateFunction.OfBoolean<ACC>, AggregateFunction.OfDouble<ACC>, AggregateFunction.OfLong<ACC>
public interface AggregateFunction<ACC>
Incremental fold over one window. The pipeline opens an accumulator with the
window's bounds, prior sample and quality filter, adds samples in timestamp
order, closes it with the first sample after the window when one is known,
and finishes it into cells. A fold that reads no window, and every raw or
event-driven fold, receives
AggregateFunction.Window.unbounded(QualityLevelFilter).
A fold answers its whole window, edges included: an aggregate that depends on the signal at
the window's start or end reads it from its AggregateFunction.Window and close(ACC, AggregateFunction.PriorSample). The pipeline owns
the grid, the watermarks, the stamp of a cell with no stated quality, and the fill of a window
with no cell.
Single-threaded per key; add and close may mutate the accumulator in place or
return a fresh one.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordOne value of a finished window.static interfaceboolean-input convenience: coerces the sample and callsAggregateFunction.OfBoolean.addBoolean(ACC, boolean).static interfacedouble-input convenience: coerces the sample and callsAggregateFunction.OfDouble.addDouble(ACC, double).static interfacelong-input convenience: coerces the sample (a floating one rounded half-even) and callsAggregateFunction.OfLong.addLong(ACC, long).static final recordA sample outside a window that bounds it: the latest sample strictly before the window start (a bounding seed before the query range or the last sample of an earlier window), or the first sample at or after its end.static enumHow a fold treats sample quality.static final recordWhat the pipeline needs to know about a fold: how it treats quality, whetheropen(AggregateFunction.Window)reads its window (so the pipeline seeds the key and opens a window that has a prior but no samples), whether time after a window's last sample counts only onceclose(ACC, AggregateFunction.PriorSample)supplies the sample after the window, and whether it reads the stored samples at its window's edges.static final recordThe window a fold opens: its bounds in epoch milliseconds ([startMs, endMs), the end clipped to the query range), the sample in effect at its start when one is known, the levels the query's quality filter admits, and whether the signal ramps linearly between samples (sloped) or holds each value until the next. -
Method Summary
Modifier and TypeMethodDescriptionadd(ACC acc, long tsMs, @Nullable Object value, @Nullable QualityCode quality) One sample, in timestamp order.default ACCaddRow(ACC acc, long tsMs, @Nullable Object value, @Nullable QualityCode quality) Adds an engine's answer for the window of a fold that reads its edges, after the stored samples at its edges and at the last one's time, so the row does not displace the edges that bound the window.default ACCclose(ACC acc, AggregateFunction.PriorSample next) accclosed at its window end bynext, the first sample at or after the end, of any quality.Zero or more cells for the closed window, in emission order: a multi-value aggregate (min_max) emits one cell per value at the same window.id()open(AggregateFunction.Window window) The accumulator of one window.default AggregateFunction.Traitstraits()Read once per key: how the fold treats quality and what it needs from its window.
-
Method Details
-
id
AggregateId id() -
traits
Read once per key: how the fold treats quality and what it needs from its window. -
open
The accumulator of one window. A fold that reads no window ignores the argument. -
add
One sample, in timestamp order. Returns the accumulator to keep: the same one, or a fresh one. A quality-gated fold sees only the samples the query's filter admits; the others see every sample with its quality. -
addRow
Adds an engine's answer for the window of a fold that reads its edges, after the stored samples at its edges and at the last one's time, so the row does not displace the edges that bound the window. The default adds it as a sample. -
close
accclosed at its window end bynext, the first sample at or after the end, of any quality. A window never given one has no sample after it. The default ignoresnext. -
finish
Zero or more cells for the closed window, in emission order: a multi-value aggregate (min_max) emits one cell per value at the same window. A cell with anullquality is stamped by the pipeline from the qualities it gated; a stated quality is the fold's own answer. No cells means the window has no value and goes to the fill.
-