Search code examples
apache-flinkflink-streaming

What's the flink ReduceFunction's default trigger?


And what's the difference about WindowFunction's trigger and ReduceFunction's trigger?


Solution

  • There is no such thing as a "ReduceFunction Trigger" or "WindowFunction Trigger" because triggers and functions are orthogonal. In Flink, a window operation consists of at least three parts:

    • WindowAssigner: The window assigner decides for each records into which window(s) it is assigned.
    • Function: The function(s) of a window process the records that are assigned to a window. Functions can be a ReduceFunction, AggregateFunction, WindowFunction, or ProcessWindowFunction. ReduceFunction and AggregateFunction can be eagerly applied before all records have been received. This is beneficial because the amount of data to store in the state of a window can be significantly reduced that way. WindowFunction and ProcessWindowFunction process all records that are collected by the window. It is also possible to combine an eager function (ReduceFunction, AggregateFunction) and a full window function (WindowFunction, ProcessFunction). In this case, the records are eagerly aggregated and the eager aggregation result is eventually given to the full window function.
    • Trigger: A Trigger decides when to emit a result from and/or discard the state of a window operation.

    A ReduceFunction is always immediately applied when a new record is added to the window. The result of the window is emitted when the Trigger of the window fires.