Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
308 views
in Technique[技术] by (71.8m points)

apache flink - Implications of merge method in AggregateFunction

I am trying to understand the AggregateFunction in Flink which is described here. Totally it has four methods namely,

  1. createAccumulator
  2. add
  3. getResult
  4. merge

From my understanding,

createAccumulator method is invoked when the first element enters into a new window and newly created instance will be used further

add method is invoked to reduce the result based on definition and this uses the instance which is created in createAccumulator method

getResult method is invoked when a window is closed and returns the available result

Whether my understanding about the above methods are correct or not? Finally, what is the use-case of merge method and when it is used/invoked? The definition available here is not clear for me.

question from:https://stackoverflow.com/questions/65848095/implications-of-merge-method-in-aggregatefunction

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The merge method is called when two windows are merged. This applies to session windows, which are merged whenever two sessions are collapsed into one by the arrival of an event that bridges the gap between the sessions. When this occurs, the aggregated results-to-date of both sessions are combined by calling merge.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...