Apache Flink 中的空窗口 [英] Empty windows in Apache Flink
问题描述
我有一个带事件时间的数据流,是否可以在 Apache Flink 中发出没有数据的窗口?例如,滚动窗口大小为 15 分钟
,如果在 [(0, 15), (15, 20), ...]
例如.
I have a datastream with event time, is it possible to emit windows with no data in Apache Flink? For example with a tumbling window size of 15 minutes
it would be ideal if I could empty windows if they have no events in the time period of [(0, 15), (15, 20), ...]
for example.
推荐答案
不,这是不可能的.Flink 的 window 操作符只会在添加第一个事件时创建一个窗口.
No, this is not possible. Flink's window operator only creates a window when the first event is added to it.
不为空窗口发出结果的原因是,窗口通常定义在一个键控流上(如果没有键控流,就不可能并行处理窗口).如果 Flink 会为键控流上的空窗口发出记录,则它需要为每个可能的键值发出结果.由于可能的键太多,这是不可能的.
The reason for not emitting results for empty windows is, that windows are typically defined on a keyed stream (without keying a stream it is not possible to process the window in parallel). If Flink would emit records for empty windows on a keyed stream, it would need to emit a result for every possible key value. Since there are way too many possible keys, this is not possible.
这篇关于Apache Flink 中的空窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!