Class MergingWindowSet<W extends org.apache.flink.streaming.api.windowing.windows.Window>
java.lang.Object
org.apache.flink.datastream.impl.extension.window.operators.MergingWindowSet<W>
public class MergingWindowSet<W extends org.apache.flink.streaming.api.windowing.windows.Window>
extends Object
Utility for keeping track of merging
Windows when using a MergingWindowAssigner in a WindowProcessOperator.
Please refer to MergingWindowSet. We do not use this
directly because we are utilizing State V2, while it is based on State V1.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionMergingWindowSet(org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner<?, W> windowAssigner, org.apache.flink.runtime.state.v2.internal.InternalListState<?, org.apache.flink.runtime.state.VoidNamespace, org.apache.flink.api.java.tuple.Tuple2<W, W>> state) Restores aMergingWindowSetfrom the given state. -
Method Summary
Modifier and TypeMethodDescriptionaddWindow(W newWindow, MergingWindowSet.MergeFunction<W> mergeFunction) Adds a newWindowto the set of in-flight windows.getStateWindow(W window) Returns the state window for the given in-flightWindow.voidpersist()Persist the updated mapping to the given state if the mapping changed since initialization.voidretireWindow(W window) Removes the given window from the set of in-flight windows.toString()
-
Constructor Details
-
MergingWindowSet
public MergingWindowSet(org.apache.flink.streaming.api.windowing.assigners.MergingWindowAssigner<?, W> windowAssigner, org.apache.flink.runtime.state.v2.internal.InternalListState<?, throws Exceptionorg.apache.flink.runtime.state.VoidNamespace, org.apache.flink.api.java.tuple.Tuple2<W, W>> state) Restores aMergingWindowSetfrom the given state.- Throws:
Exception
-
-
Method Details
-
persist
Persist the updated mapping to the given state if the mapping changed since initialization.- Throws:
Exception
-
getStateWindow
Returns the state window for the given in-flightWindow. The state window is theWindowin which we keep the actual state of a given in-flight window. Windows might expand but we keep to original state window for keeping the elements of the window to avoid costly state juggling.- Parameters:
window- The window for which to get the state window.
-
retireWindow
Removes the given window from the set of in-flight windows.- Parameters:
window- TheWindowto remove.
-
addWindow
Adds a newWindowto the set of in-flight windows. It might happen that this triggers merging of previously in-flight windows. In that case, the providedMergingWindowSet.MergeFunctionis called.This returns the window that is the representative of the added window after adding. This can either be the new window itself, if no merge occurred, or the newly merged window. Adding an element to a window or calling trigger functions should only happen on the returned representative. This way, we never have to deal with a new window that is immediately swallowed up by another window.
If the new window is merged, the
MergeFunctioncallback arguments also don't contain the new window as part of the list of merged windows.- Parameters:
newWindow- The newWindowto add.mergeFunction- The callback to be invoked in case a merge occurs.- Returns:
- The
Windowthat new newWindowended up in. This can also be the newWindowitself in case no merge occurred. - Throws:
Exception
-
toString
-