Window

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Window

toletum
Hi!

I want a window which should be fired each 5 seconds, whether or not there events.

        env.socketTextStream("192.168.1.101", 9999)
        .map(new mapper())
        .keyBy(0)
        .timeWindow(Time.seconds(5))
        .apply(new MyRichWindowFunction())

      
It works if the window has events, but, it doesn't if there aren't events.

Somebody knows how I could force it. I tried with a trigger and ContinuousProcessingTimeTrigger, but, I don't know how use it.

Regards,
Toletum

Reply | Threaded
Open this post in threaded view
|

Re: Window

Aljoscha Krettek
Hi,
you could do it with a combination of GlobalWindows and the ContinuousProcessingTimeTrigger:

env.socketTextStream("192.168.1.101", 9999)
  .map(new mapper())
  .keyBy(0)
  .window(GlobalWindows.create())
  .trigger(PurgingTrigger.of(ContinuousProcessingTimeTrigger.of(Time.seconds(5))))
  .apply(new MyRichWindowFunction())

This, however, will fire on 5 second intervals only for keys that have already been seen once. So it might not be too useful. In general, it is hard to do empty windows since windows are normally always tied to a key, and if there is not element there is no key, and therefore normally no window.

Cheers,
Aljoscha


On Thu, 5 May 2016 at 11:39 <[hidden email]> wrote:
Hi!

I want a window which should be fired each 5 seconds, whether or not there events.

        env.socketTextStream("192.168.1.101", 9999)
        .map(new mapper())
        .keyBy(0)
        .timeWindow(Time.seconds(5))
        .apply(new MyRichWindowFunction())

      
It works if the window has events, but, it doesn't if there aren't events.

Somebody knows how I could force it. I tried with a trigger and ContinuousProcessingTimeTrigger, but, I don't know how use it.

Regards,
Toletum