Class SlidingWindowAssigner
- java.lang.Object
-
- org.apache.flink.table.runtime.operators.window.assigners.WindowAssigner<W>
-
- org.apache.flink.table.runtime.operators.window.assigners.PanedWindowAssigner<TimeWindow>
-
- org.apache.flink.table.runtime.operators.window.assigners.SlidingWindowAssigner
-
- All Implemented Interfaces:
Serializable,InternalTimeWindowAssigner
public class SlidingWindowAssigner extends PanedWindowAssigner<TimeWindow> implements InternalTimeWindowAssigner
AWindowAssignerthat windows elements into sliding windows based on the timestamp of the elements. Windows can possibly overlap.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSlidingWindowAssigner(long size, long slide, long offset, boolean isEventTime)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TimeWindowassignPane(Object element, long timestamp)Given the timestamp and element, returns the pane into which it should be placed.Collection<TimeWindow>assignWindows(org.apache.flink.table.data.RowData element, long timestamp)Given the timestamp and element, returns the set of windows into which it should be placed.TimeWindowgetLastWindow(TimeWindow pane)Gets the last window which the pane belongs to.org.apache.flink.api.common.typeutils.TypeSerializer<TimeWindow>getWindowSerializer(org.apache.flink.api.common.ExecutionConfig executionConfig)Returns aTypeSerializerfor serializing windows that are assigned by thisWindowAssigner.booleanisEventTime()Returnstrueif elements are assigned to windows based on event time,falseotherwise.static SlidingWindowAssignerof(java.time.Duration size, java.time.Duration slide)Creates a newSlidingEventTimeWindowsWindowAssignerthat assigns elements to sliding time windows based on the element timestamp.Iterable<TimeWindow>splitIntoPanes(TimeWindow window)Splits the given window into panes collection.StringtoString()SlidingWindowAssignerwithEventTime()SlidingWindowAssignerwithOffset(java.time.Duration offset)SlidingWindowAssignerwithProcessingTime()-
Methods inherited from class org.apache.flink.table.runtime.operators.window.assigners.WindowAssigner
open
-
-
-
-
Method Detail
-
assignWindows
public Collection<TimeWindow> assignWindows(org.apache.flink.table.data.RowData element, long timestamp)
Description copied from class:WindowAssignerGiven the timestamp and element, returns the set of windows into which it should be placed.- Specified by:
assignWindowsin classWindowAssigner<TimeWindow>- Parameters:
element- The element to which windows should be assigned.timestamp- The timestamp of the element whenWindowAssigner.isEventTime()returns true, or the current system time whenWindowAssigner.isEventTime()returns false. The timestamp value is mapping to UTC milliseconds for splitting windows simply.
-
assignPane
public TimeWindow assignPane(Object element, long timestamp)
Description copied from class:PanedWindowAssignerGiven the timestamp and element, returns the pane into which it should be placed.- Specified by:
assignPanein classPanedWindowAssigner<TimeWindow>- Parameters:
element- The element to which windows should be assigned.timestamp- The timestamp of the element whenWindowAssigner.isEventTime()returns true, or the current system time whenWindowAssigner.isEventTime()returns false.
-
splitIntoPanes
public Iterable<TimeWindow> splitIntoPanes(TimeWindow window)
Description copied from class:PanedWindowAssignerSplits the given window into panes collection.- Specified by:
splitIntoPanesin classPanedWindowAssigner<TimeWindow>- Parameters:
window- the window to be split.- Returns:
- the panes iterable
-
getLastWindow
public TimeWindow getLastWindow(TimeWindow pane)
Description copied from class:PanedWindowAssignerGets the last window which the pane belongs to.- Specified by:
getLastWindowin classPanedWindowAssigner<TimeWindow>
-
getWindowSerializer
public org.apache.flink.api.common.typeutils.TypeSerializer<TimeWindow> getWindowSerializer(org.apache.flink.api.common.ExecutionConfig executionConfig)
Description copied from class:WindowAssignerReturns aTypeSerializerfor serializing windows that are assigned by thisWindowAssigner.- Specified by:
getWindowSerializerin classWindowAssigner<TimeWindow>
-
isEventTime
public boolean isEventTime()
Description copied from class:WindowAssignerReturnstrueif elements are assigned to windows based on event time,falseotherwise.- Specified by:
isEventTimein classWindowAssigner<TimeWindow>
-
toString
public String toString()
- Specified by:
toStringin classWindowAssigner<TimeWindow>
-
of
public static SlidingWindowAssigner of(java.time.Duration size, java.time.Duration slide)
Creates a newSlidingEventTimeWindowsWindowAssignerthat assigns elements to sliding time windows based on the element timestamp.- Parameters:
size- The size of the generated windows.slide- The slide interval of the generated windows.- Returns:
- The time policy.
-
withOffset
public SlidingWindowAssigner withOffset(java.time.Duration offset)
-
withEventTime
public SlidingWindowAssigner withEventTime()
- Specified by:
withEventTimein interfaceInternalTimeWindowAssigner- Returns:
- an InternalTimeWindowAssigner which in event time mode.
-
withProcessingTime
public SlidingWindowAssigner withProcessingTime()
- Specified by:
withProcessingTimein interfaceInternalTimeWindowAssigner- Returns:
- an InternalTimeWindowAssigner which in processing time mode.
-
-