Early Triggers

Triggers allow Beam to emit early results, before all the data in a given window has arrived. For example, emitting after a certain amount of time elapses, or after a certain number of elements arrives.

Kata: Given that events are being generated every second and a fixed window of 1-day duration, please implement an early trigger that emits the number of events count immediately after new element is processed.


Use withEarlyFirings to set early firing triggers.
Use FixedWindows with 1-day duration using AfterWatermark.pastEndOfWindow() trigger.
Set the allowed lateness to 0 with discarding accumulation mode.
Use Combine.globally and Count.combineFn to calculate the count of events.
Refer to the Beam Programming Guide "Event time triggers" section for more information.