Class SliceAssigners.HoppingSliceAssigner
- java.lang.Object
-
- org.apache.flink.table.runtime.operators.window.tvf.slicing.SliceAssigners.HoppingSliceAssigner
-
- All Implemented Interfaces:
Serializable,WindowAssigner,SliceAssigner,SliceSharedAssigner
- Enclosing class:
- SliceAssigners
public static final class SliceAssigners.HoppingSliceAssigner extends Object implements SliceSharedAssigner
TheSliceAssignerfor hopping windows.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedHoppingSliceAssigner(int rowtimeIndex, ZoneId shiftTimeZone, long size, long slide, long offset)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longassignSliceEnd(long timestamp)org.apache.flink.api.common.state.v2.StateFuture<org.apache.flink.api.java.tuple.Tuple2<org.apache.flink.table.data.RowData,org.apache.flink.table.data.RowData>>asyncMergeSlices(long sliceEnd, AsyncMergeCallback<Long,Iterable<Long>> callback)Determines which slices (if any) should be merged and then merge them.Iterable<Long>expiredSlices(long windowEnd)Returns an iterator of slices to expire when the given window is emitted.StringgetDescription()Returns a description of this window assigner.longgetLastWindowEnd(long sliceEnd)Returns the last window which the slice belongs to.longgetSliceEndInterval()Returns the interval of slice ends, i.e. the step size to advance of the slice end when a new slice assigned.longgetWindowStart(long windowEnd)Returns the corresponding window start timestamp of the given window end timestamp.voidmergeSlices(long sliceEnd, MergeCallback<Long,Iterable<Long>> callback)Determines which slices (if any) should be merged and then merge them.Optional<Long>nextTriggerWindow(long windowEnd, Supplier<Boolean> isWindowEmpty)Returns the optional end timestamp of next window which should be triggered.Optional<Long>nextTriggerWindow(long windowEnd, org.apache.flink.table.data.RowData acc, Function<org.apache.flink.table.data.RowData,Boolean> isWindowEmpty)SliceAssigners.HoppingSliceAssignerwithOffset(Duration offset)Creates a newSliceAssigners.HoppingSliceAssignerwith a new specified offset.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.flink.table.runtime.operators.window.tvf.slicing.SliceAssigner
assignSliceEnd
-
Methods inherited from interface org.apache.flink.table.runtime.operators.window.tvf.common.WindowAssigner
isEventTime
-
-
-
-
Constructor Detail
-
HoppingSliceAssigner
protected HoppingSliceAssigner(int rowtimeIndex, ZoneId shiftTimeZone, long size, long slide, long offset)
-
-
Method Detail
-
withOffset
public SliceAssigners.HoppingSliceAssigner withOffset(Duration offset)
Creates a newSliceAssigners.HoppingSliceAssignerwith a new specified offset.
-
assignSliceEnd
public long assignSliceEnd(long timestamp)
-
getLastWindowEnd
public long getLastWindowEnd(long sliceEnd)
Description copied from interface:SliceAssignerReturns the last window which the slice belongs to. The window and slices are both identified by the end timestamp.- Specified by:
getLastWindowEndin interfaceSliceAssigner
-
getWindowStart
public long getWindowStart(long windowEnd)
Description copied from interface:SliceAssignerReturns the corresponding window start timestamp of the given window end timestamp.- Specified by:
getWindowStartin interfaceSliceAssigner
-
expiredSlices
public Iterable<Long> expiredSlices(long windowEnd)
Description copied from interface:SliceAssignerReturns an iterator of slices to expire when the given window is emitted. The window and slices are both identified by the end timestamp.- Specified by:
expiredSlicesin interfaceSliceAssigner- Parameters:
windowEnd- the end timestamp of window emitted.
-
getSliceEndInterval
public long getSliceEndInterval()
Description copied from interface:SliceAssignerReturns the interval of slice ends, i.e. the step size to advance of the slice end when a new slice assigned.- Specified by:
getSliceEndIntervalin interfaceSliceAssigner
-
mergeSlices
public void mergeSlices(long sliceEnd, MergeCallback<Long,Iterable<Long>> callback) throws ExceptionDescription copied from interface:SliceSharedAssignerDetermines which slices (if any) should be merged and then merge them.- Specified by:
mergeSlicesin interfaceSliceSharedAssigner- Parameters:
sliceEnd- the triggered slice, identified by end timestampcallback- a callback that can be invoked to signal which slices should be merged.- Throws:
Exception
-
asyncMergeSlices
public org.apache.flink.api.common.state.v2.StateFuture<org.apache.flink.api.java.tuple.Tuple2<org.apache.flink.table.data.RowData,org.apache.flink.table.data.RowData>> asyncMergeSlices(long sliceEnd, AsyncMergeCallback<Long,Iterable<Long>> callback) throws ExceptionDescription copied from interface:SliceSharedAssignerDetermines which slices (if any) should be merged and then merge them.- Specified by:
asyncMergeSlicesin interfaceSliceSharedAssigner- Parameters:
sliceEnd- the triggered slice, identified by end timestampcallback- a callback that can be invoked to signal which slices should be merged.- Returns:
- f0 is the accumulators after merging, f1 is the result of the aggregation from the merged accumulators with this slice end as namespace
- Throws:
Exception
-
nextTriggerWindow
public Optional<Long> nextTriggerWindow(long windowEnd, Supplier<Boolean> isWindowEmpty)
Description copied from interface:SliceSharedAssignerReturns the optional end timestamp of next window which should be triggered. Empty if no following window to trigger for now.The purpose of this method is avoid register too many timers for each hopping and cumulative slice, e.g. HOP(1day, 10s) needs register 8640 timers for every slice. In order to improve this, we only register one timer for the next window. For hopping windows we don't register next window if current window is empty (i.e. no records in current window). That means we will have one more unnecessary window triggered for hopping windows if no elements arrives for a key for a long time. We will skip to emit window result for the triggered empty window, see
AsyncStateSliceSharedWindowAggProcessor#fireWindow(Long, Long).- Specified by:
nextTriggerWindowin interfaceSliceSharedAssigner- Parameters:
windowEnd- the current triggered window, identified by end timestampisWindowEmpty- a supplier that can be invoked to get whether the triggered window is empty (i.e. no records in the window).
-
nextTriggerWindow
public Optional<Long> nextTriggerWindow(long windowEnd, org.apache.flink.table.data.RowData acc, Function<org.apache.flink.table.data.RowData,Boolean> isWindowEmpty)
- Specified by:
nextTriggerWindowin interfaceSliceSharedAssigner
-
getDescription
public String getDescription()
Description copied from interface:WindowAssignerReturns a description of this window assigner.- Specified by:
getDescriptionin interfaceWindowAssigner
-
-