You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by to...@toletum.org on 2016/05/05 09:39:07 UTC

Window

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

Re: Window

Posted by Aljoscha Krettek <al...@apache.org>.
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 <to...@toletum.org> 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
>
>