gpt4 book ai didi

apache-flink - Flink 在没有窗口的情况下减少键控流

转载 作者:行者123 更新时间:2023-12-04 02:44:04 25 4
gpt4 key购买 nike

我阅读了源代码,reduce 会将每个结果转发给下游。


我想在没有窗口的情况下按键减少流,

    stream.keyBy(key)
.reduce((a, b) -> {
//reduce
return a+b;
});

如果reduce on window,flink会在watermark到达的时候forword元素到下游,那么flink如何判断reduce finish without window。

最佳答案

根据官方文档https://ci.apache.org/projects/flink/flink-docs-stable/dev/stream/operators/

Reduce KeyedStream → DataStream

A "rolling" reduce on a keyed data stream. Combines the current element with the last reduced value and emits the new value.

Window Reduce WindowedStream → DataStream

Applies a functional reduce function to the window and returns the reduced value.

主要区别在于:

  • reduce 在窗口中完成时,该函数将当前值与窗口值合并。
  • reduce 在 KeyedStream 中完成时,该函数将当前值与最新值组合。

关于apache-flink - Flink 在没有窗口的情况下减少键控流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57988769/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com