I have the following situation
stream<Tuple2<String, Integer>
.keyBy(0)
.timeWindow(Time.of(10, TimeUnit.SECONDS))
.sum(1)
.flatMap(..)
.sink()
What I am trying to do is calculate a top N for my time window. The top N for each window is stored by the sink.
I can calculate the top N in the flatmap, but I do not know when to send it to the sink for storage. As far as I can see there is no way to know when the window has ended from within the flatmap function.
I know there are alternatives such as an apply function which does both or creating markers in the stream to indicate the end, but I am wondering if there is a more elegant solution.