看到源码了,这里如果contents == null,就不触发计算了 evictingWindowState.clear();会导致contents 变成null,然后如果窗口没有数据就不会触发窗口计算
if (triggerResult.isFire()) { Iterable<StreamRecord<IN>> contents = evictingWindowState.get(); if (contents == null) { // if we have no state, there is nothing to do continue; } emitWindowContents(actualWindow, contents, evictingWindowState); } -- 这里会吧 evictingWindowState给clear了 if (triggerResult.isPurge()) { evictingWindowState.clear(); } 在 2020-01-19 13:27:17,"USERNAME" <oracle...@126.com> 写道: >大家新年快乐! > > >版本:FLINK 1.9.1 > > >----部分代码 >.keyBy("key") >.window(EventTimeSessionWindows.withGap(Time.hours(1))) >.trigger(new NewTrigger()) >.process(new NewProcess()) > > >--NewTrigger() >@Override >public TriggerResult onElement(Bean bean, long l, TimeWindow timeWindow, >TriggerContext ctx) throws Exception { >.. >ctx.registerEventTimeTimer(l + INTERVAL); >return TriggerResult.FIRE_AND_PURGE; >} > > >问题: >通过触发器,定义在窗口内,每隔固定时间计算一次并且清空计算数据,正常如果固定时间内没有数据也要输出一次。 >但是实际用的时候只有窗口有数据的时候才会触发process计算,如果没有数据不会触发,TriggerResult.FIRE_AND_PURGE改为TriggerResult.FIRE之后就可以正常的固定每隔一定时间输出一次。 >TriggerResult.FIRE_AND_PURGE会有哪些操作?好像不止清理了窗口数据,还对触发时间有操作呀? > > > > > > > > > > > > > > > > >