You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Miyuru Dayarathna <mi...@yahoo.co.uk> on 2018/03/12 05:33:20 UTC

Sliding window based on event arrival

Hi,
I need to create a sliding window of 4 events in Flink streaming application. The window should slide by one event per every new arriving event. Furthermore, per each new arriving event I need to calculate the aggregate sum of a particular field in the 4 events I have in the window. I have referred [1] which describes how this can be implemented based on time. But my use case if little different, hence I am wondering how the window can be slided when a new event gets added to the window.
[1] https://ci.apache.org/projects/flink/flink-docs-release-1.4/dev/stream/operators/windows.html#sliding-windows

Thanks,Miyuru

Re: Sliding window based on event arrival

Posted by Miyuru Dayarathna <mi...@yahoo.co.uk>.
Hi Xingcan,
Thanks for the clarification. I was able to implement the scenario with the example you provided.
Thanks,Miyuru
 

    On Monday, 12 March 2018, 12:53, Xingcan Cui <xi...@gmail.com> wrote:
 

 Hi Miyuru,
what you need should be something like a `SlidingCountWindow`. Flink Datastream API has already provided a `countWindow()` method for that and a related example can be found here.
Hope that helps,Xingcan


On 12 Mar 2018, at 1:33 PM, Miyuru Dayarathna <mi...@yahoo.co.uk> wrote:
Hi,
I need to create a sliding window of 4 events in Flink streaming application. The window should slide by one event per every new arriving event. Furthermore, per each new arriving event I need to calculate the aggregate sum of a particular field in the 4 events I have in the window. I have referred [1] which describes how this can be implemented based on time. But my use case if little different, hence I am wondering how the window can be slided when a new event gets added to the window.
[1] https://ci.apache.org/projects/flink/flink-docs-release-1.4/dev/stream/operators/windows.html#sliding-windows

Thanks,Miyuru




   

Re: Sliding window based on event arrival

Posted by Xingcan Cui <xi...@gmail.com>.
Hi Miyuru,

what you need should be something like a `SlidingCountWindow`. Flink Datastream API has already provided a `countWindow()` method for that and a related example can be found here <https://github.com/apache/flink/blob/baebbabfc6913598122fc5df8645097172bd9e65/flink-examples/flink-examples-streaming/src/main/java/org/apache/flink/streaming/examples/windowing/WindowWordCount.java>.

Hope that helps,
Xingcan

> On 12 Mar 2018, at 1:33 PM, Miyuru Dayarathna <mi...@yahoo.co.uk> wrote:
> 
> Hi,
> 
> I need to create a sliding window of 4 events in Flink streaming application. The window should slide by one event per every new arriving event. Furthermore, per each new arriving event I need to calculate the aggregate sum of a particular field in the 4 events I have in the window. I have referred [1] which describes how this can be implemented based on time. But my use case if little different, hence I am wondering how the window can be slided when a new event gets added to the window.
> 
> [1] https://ci.apache.org/projects/flink/flink-docs-release-1.4/dev/stream/operators/windows.html#sliding-windows <https://ci.apache.org/projects/flink/flink-docs-release-1.4/dev/stream/operators/windows.html#sliding-windows>
> 
> Thanks,
> Miyuru