如何在窗口操作中累积列表

时间:2019-05-21 19:44:39

标签: apache-flink

我的目标是使用滑动窗口操作在流上下文中收集/累积字符串列表。我不能使用简单的ListAccumulator<String>,因为结果仅在作业完成后才可用。

我正在考虑使用类似ListAccumulator的聚合函数:

AggregateFunction<Tuple2<String, Integer>,ListAccumulator<String>,List<String>>

但是,我希望在触发Windows事件时将ListAccumulator重置为空,AggregateFunction将在每个触发器上调用createAccumulator()resetAccumulator()函数吗? / p>

DataStream<Tuple2<String, Integer>> ips = ...
            ips.keyBy(0).timeWindow(Time.seconds(WINDOW_DURATION.getSeconds()), Time.seconds(SLIDE_DURATION.getSeconds())).aggregate(new RFAgg());

private static class RFAgg implements AggregateFunction<Tuple2<String, Integer>,ListAccumulator<String>,List<String>> {
...
}

0 个答案:

没有答案
相关问题