Reputation: 232
DataStream<Tuple2<String, Long>> result = mappedStream
.timeWindow(Time.seconds(30))
.fold(new Tuple2<>("", 0L), new FoldFunction<Pojo, Tuple2<String, Long>>() {
@Override
public Tuple2<String, Long> fold(Tuple2<String, Long> acc, Pojo event) {
acc.f0 = event.getEt();
acc.f1 += 1;
return acc;
}
});
I have a datastream where I have the counts for each keyedstream. I would now want to filter only the top 'k' items based on the count.
Upvotes: 0
Views: 235
Reputation: 4542
You have to implement the sorting and top k operation yourself within the window apply function.
Upvotes: 1