代码如下: evictor设置的在窗口触发前清理所有数据,按理进入sum是没有数据,但是调试的时候发现,sum经过计算会输出 null 进入 print,导致报 Nullpoint。不知道是bug还是我的问题;
class A { String word; Long time; public A(String word, Long time) { this.word = word; this.time = time; } }; streamEnv.fromElements(new A("a", 1L)) .assignTimestampsAndWatermarks( WatermarkStrategy. forBoundedOutOfOrderness(Duration.ofSeconds(10)) .withTimestampAssigner(((element, recordTimestamp) -> element.time)) ) .keyBy(x -> x.time) .map(x -> new Tuple2<>(x.word, 1L)) .returns(Types.TUPLE(Types.STRING, Types.LONG)) .keyBy((KeySelector<Tuple2<String, Long>, String>) o -> o.f0) .window(TumblingEventTimeWindows.of(Time.seconds(20))) .evictor(TimeEvictor.of(Time.seconds(0))) .sum(1) .print(); streamEnv.execute(); -- Sent from: http://apache-flink.147419.n8.nabble.com/