Search code examples
javaapache-flink

Is there a count-based window in Apache Flink?


I am writing code for data stream processing in Apache Flink, but I am having trouble finding any mention of count-based windows in the Apache Flink documentation.

I checked the link below, but it looks like there are only time-based windows. https://nightlies.apache.org/flink/flink-docs-release-1.19/docs/dev/datastream/operators/windows/


Solution

  • I think it exists. There is at least .countWindow() for keyed streams and .countWindowAll() for non-keyed. There is an example WindowWordCount provided by Flink developers.

    countWindow(size: Long):

    Windows this KeyedStream into tumbling count windows. Params: size – The size of the windows in number of elements.

    countWindow(size: Long, slide: Long):

    Windows this KeyedStream into sliding count windows. Params: size – The size of the windows in number of elements. slide – The slide interval in number of elements.

    I never used it myself but I hope it's what you are looking for.