Triggers and accumulation mode
When should a window's result be emitted, and how must the trigger mode match the sink?
Once results are provisional, when to emit a result becomes a separate question from what to compute. A trigger is the rule that decides when a window's result is emitted. Relative to the watermark there are three classes:
| Class | When | Character |
|---|---|---|
| Early | Before the watermark reaches the window end (for example every minute) | Speculative, incomplete, low latency |
| On-time | When the watermark passes the window end | The declared-complete answer |
| Late | For each late record, or in batches, after on-time | Corrections |
Accumulation mode: the knob people miss
The second knob matters more and is often missed: accumulation mode. When a window fires again, does it emit the new total or only the change since the last fire?
- Accumulating: emit the new total (3,100, then 3,260). The sink must overwrite by key, so the sink must be keyed and mutable.
- Discarding: emit only the delta (3,100, then +160). The sink must be additive and must have received every earlier fire exactly once.
So the trigger mode is really a statement about the algebra of the sink. Getting it wrong gives double counting that stays invisible until someone compares totals with the source.
Early firings carry an unstated contract
A dashboard whose count rises and then falls is not a pipeline bug. It is a consumer who was never told the number was provisional. That failure is informational, not technical, and no amount of engineering can fix it. Early results must be labelled as early.