Tsering
03/23/2023, 1:47 PMEventTimeTrigger from flink
@Override
public TriggerResult onElement(
Object element, long timestamp, TimeWindow window, TriggerContext ctx)
throws Exception {
if (window.maxTimestamp() <= ctx.getCurrentWatermark()) {
// if the watermark is already past the window fire immediately
return TriggerResult.FIRE;
} else {
ctx.registerEventTimeTimer(window.maxTimestamp());
return TriggerResult.CONTINUE;
}
}
suppose there are 5 elements of a same window got into onElement function and hit the registerEventTimeTimer five times, will the onEventTime get invoke 5 times ?Elphas Toringepi
03/23/2023, 7:56 PMTumblingWindow which has a fixed start and end, window.maxTimestamp() will be the same for all 5 elements in the window so onEventTime will be called only once.
For a SessionWindow which gets extended if it receives an element within a certain time, onEventTime can be invoked up to 5 times. If the 5 events arrive in order and the timestamps are all different then onEventTime will be invoked 5 times.Tsering
03/24/2023, 6:31 AM