Hi,
I am trying to have a trigger fires every 5 mins, even when sometimes no event comes (just output default for empty window). The closest solution I got to work is this: datastream.windowAll(GlobalWindows.create()) .trigger(ContinuousProcessingTimeTrigger.of(Time.minutes(5))) .apply { MY_APPLY_FUNCTION} For master branch, this works after the first event appears, then it continuously fires every 5 mins even when there is no events (not work for release 1.0.3 though due to the change in ContinuousProcessingTimeTrigger). However, sometimes my first event may not appear in the first 5 mins. I still need to fire a default value first, but it seems the GlobalWindow is only created after seen an event, so it only works after the first event. Is there any way I can create the window before the first event comes in windowAssigner? Thanks, Xiang |
Hi Xiang,
I think this is a duplicate from the discussion you opened yesterday. I post the same answer here, in case somebody wants to contribute to the discussion. According to your code, you just put all your elements (no splitting by key) into a single infinite window, and you apply your window function every 5min (after the first element had arrived). The combination of the two means that if you have elements arriving at steady pace of 1 element/min, and your function just counts the already seen elements. then the result will be 5, 10, 15 … Under the hood, when the first element arrives the trigger registers the first time to fire after 5 min. Then, for every firing, the trigger registers another timer to fire after 5min, and so on. Your problem is that the first timer is set on the first element. If you control your source, why don’t you put a dummy element in the beginning? This will instantiate the global window and set the first timer. Kostas > On Jul 12, 2016, at 4:21 AM, Xiang Zhang <[hidden email]> wrote: > > Hi, > > I am trying to have a trigger fires every 5 mins, even when sometimes no > event comes (just output default for empty window). The closest solution I > got to work is this: > > datastream.windowAll(GlobalWindows.create()) > > .trigger(ContinuousProcessingTimeTrigger.of(Time.minutes(5))) > .apply { MY_APPLY_FUNCTION} > > For master branch, this works after the first event appears, then it > continuously fires every 5 mins even when there is no events (not work for > release 1.0.3 though due to the change in ContinuousProcessingTimeTrigger). > > However, sometimes my first event may not appear in the first 5 mins. I > still need to fire a default value first, but it seems the GlobalWindow is > only created after seen an event, so it only works after the first event. Is > there any way I can create the window before the first event comes in > windowAssigner? > > Thanks, > Xiang > > > > -- > View this message in context: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/Create-window-before-the-first-event-tp7920.html > Sent from the Apache Flink User Mailing List archive. mailing list archive at Nabble.com. |
Free forum by Nabble | Edit this page |