是否有 flink 等效于 takeOrdered 从数据流中的 window 过滤前 k 项?

Is there a flink equivalent for takeOrdered to filter top k items from a window in a datastream?

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;
                    }
                });

我有一个数据流,其中包含每个键控流的计数。我现在只想根据计数过滤前 'k' 项。

您必须在 window apply 函数中自己实现排序和前 k 操作。