你说的应该是这里的代码:


http://flink-cn.shinonomelab.com/quickstart/setup_quickstart.html#read-the-code


其实SUM应该会在每一条数据来的时候调用的,但是输出结果只有在最后FireAndPurge的时候。


本质上,sum是执行了一个Sum类型的Aggregate:
其AggregateFunction是:


org.apache.flink.streaming.api.functions.aggregation.SumAggregator#SumAggregator(int,
 org.apache.flink.api.common.typeinfo.TypeInformation<T>, 
org.apache.flink.api.common.ExecutionConfig)




其中实现了reduce方法:


所以你可以不必关心究竟是在何时计算的,有可能在多个地方计算以后再合并,但是如论如何,Reduce计算的性质保证,结果一定是对的。





在 2019-02-28 13:04:59," " <[email protected]> 写道:
>请问:   flink wordcount中      sum是在什么时候,哪个地方调用的?

回复