Chirag
Chirag

Reputation: 1

Apache Flink DataStream - Count of Element in Tumbling Window

I’m very new to Apache Flink and its API.I want to create Java program which will do event time based processing with tumbling windows. I want to count the number of elements in the given window. However, I couldn't figure how to do that.

Upvotes: 0

Views: 1235

Answers (1)

Dominik Wosiński
Dominik Wosiński

Reputation: 3874

So, if you want to calculate the number of elements in window, probably the simplest idea is like this. Assuming you have dataset variable representing your dataset:

dataset.map(element => (element,1)).timeWindowAll(Time.seconds(5)).sum(1)

This should give you the number of elements in the window.

Upvotes: 2

Related Questions