背景
-
ValueState
文档指出:partitioned single-value state
. -
ReducingState
文档指出:combined using a reduce function
. -
AggregatingState
文档指出:eagerly pre-aggregated
. -
ValueState
延伸State
而两者ReducingState
和AggregatingState
延伸MergingState
.
问题
- 各州何时合并?
- 我应该如何为特定问题选择正确的状态原语?
- 什么机制调用reduce和aggregate函数?它是否跳过非
MergingState
?
最佳答案
Fabian Hueske 不久前(2018 年 5 月 6 日)回答了我关于 AggregateFunctions 中合并的问题。他说:
The only situation when merge() is called in a DataStream job (that I am aware of) is when session windows get merged. For example when you define a session window with 30 minute gap and you receive the following records R1, 12:00:00 R2, 12:05:00 R3, 12:40:00 R4, 12:20:00
In this case, Flink R1 will create a new window W1, R2 will be assigned to W1, R3 > creates a new window W2, and R4 connects and merges W1 and W2.
我认为您其他问题的部分答案是 ValueState
是通用(键控)状态。因此,当您实现通用函数时,您最终会使用它,而不是聚合器或缩减器(带有组合器)。
关于apache-flink - 弗林克 : ValueState vs ReducingState/AggregatingState,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57943469/