Class AbstractWindowAggProcessor
- java.lang.Object
-
- org.apache.flink.table.runtime.operators.aggregate.window.processors.AbstractWindowAggProcessor
-
- All Implemented Interfaces:
Serializable,SlicingWindowProcessor<Long>
- Direct Known Subclasses:
SliceSharedWindowAggProcessor,SliceUnsharedWindowAggProcessor
public abstract class AbstractWindowAggProcessor extends Object implements SlicingWindowProcessor<Long>
A base implementation ofSlicingWindowProcessorfor window aggregate.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.flink.table.runtime.operators.window.slicing.SlicingWindowProcessor
SlicingWindowProcessor.Context<W>
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.flink.api.common.typeutils.TypeSerializer<org.apache.flink.table.data.RowData>accSerializerprotected NamespaceAggsHandleFunction<Long>aggregatorprotected ClockServiceclockServiceprotected SlicingWindowProcessor.Context<Long>ctxprotected longcurrentProgressprotected GeneratedNamespaceAggsHandleFunction<Long>genAggsHandlerprotected booleanisEventTimeprotected org.apache.flink.table.data.utils.JoinedRowDatareuseOutputprotected java.time.ZoneIdshiftTimeZoneprotected SliceAssignersliceAssignerprotected booleanuseDayLightSavingThe shift timezone is using DayLightSaving time or not.protected WindowBufferwindowBufferprotected WindowBuffer.FactorywindowBufferFactoryprotected longwindowIntervalprotected WindowValueState<Long>windowStatestate schema: [key, window_end, accumulator].protected WindowTimerService<Long>windowTimerService
-
Constructor Summary
Constructors Constructor Description AbstractWindowAggProcessor(GeneratedNamespaceAggsHandleFunction<Long> genAggsHandler, WindowBuffer.Factory bufferFactory, SliceAssigner sliceAssigner, org.apache.flink.api.common.typeutils.TypeSerializer<org.apache.flink.table.data.RowData> accSerializer, java.time.ZoneId shiftTimeZone)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidadvanceProgress(long progress)Advances the progress time, the progress time is watermark if working in event-time mode, or current processing time if working in processing-time mode.voidclearWindow(Long windowEnd)Clear state and resources associated with the given window namespace.voidclose()The tear-down method of the function.protected voidcollect(org.apache.flink.table.data.RowData aggResult)org.apache.flink.api.common.typeutils.TypeSerializer<Long>createWindowSerializer()Returns the serializer of the window type.voidinitializeWatermark(long watermark)Initializes the watermark which restores from state.voidopen(SlicingWindowProcessor.Context<Long> context)Initialization method for the function.voidprepareCheckpoint()Performs a preparation before checkpoint.booleanprocessElement(org.apache.flink.table.data.RowData key, org.apache.flink.table.data.RowData element)Process an element with associated key from the input stream.protected abstract longsliceStateMergeTarget(long sliceToMerge)Returns the slice state target to merge the given slice into when firing windows.-
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.slicing.SlicingWindowProcessor
fireWindow
-
-
-
-
Field Detail
-
genAggsHandler
protected final GeneratedNamespaceAggsHandleFunction<Long> genAggsHandler
-
windowBufferFactory
protected final WindowBuffer.Factory windowBufferFactory
-
sliceAssigner
protected final SliceAssigner sliceAssigner
-
accSerializer
protected final org.apache.flink.api.common.typeutils.TypeSerializer<org.apache.flink.table.data.RowData> accSerializer
-
isEventTime
protected final boolean isEventTime
-
windowInterval
protected final long windowInterval
-
shiftTimeZone
protected final java.time.ZoneId shiftTimeZone
-
useDayLightSaving
protected final boolean useDayLightSaving
The shift timezone is using DayLightSaving time or not.
-
currentProgress
protected transient long currentProgress
-
ctx
protected transient SlicingWindowProcessor.Context<Long> ctx
-
clockService
protected transient ClockService clockService
-
windowTimerService
protected transient WindowTimerService<Long> windowTimerService
-
aggregator
protected transient NamespaceAggsHandleFunction<Long> aggregator
-
windowBuffer
protected transient WindowBuffer windowBuffer
-
windowState
protected transient WindowValueState<Long> windowState
state schema: [key, window_end, accumulator].
-
reuseOutput
protected transient org.apache.flink.table.data.utils.JoinedRowData reuseOutput
-
-
Constructor Detail
-
AbstractWindowAggProcessor
public AbstractWindowAggProcessor(GeneratedNamespaceAggsHandleFunction<Long> genAggsHandler, WindowBuffer.Factory bufferFactory, SliceAssigner sliceAssigner, org.apache.flink.api.common.typeutils.TypeSerializer<org.apache.flink.table.data.RowData> accSerializer, java.time.ZoneId shiftTimeZone)
-
-
Method Detail
-
open
public void open(SlicingWindowProcessor.Context<Long> context) throws Exception
Description copied from interface:SlicingWindowProcessorInitialization method for the function. It is called before the actual working methods.- Specified by:
openin interfaceSlicingWindowProcessor<Long>- Throws:
Exception
-
initializeWatermark
public void initializeWatermark(long watermark)
Description copied from interface:SlicingWindowProcessorInitializes the watermark which restores from state. The method is called after open method and before the actual working methods.- Specified by:
initializeWatermarkin interfaceSlicingWindowProcessor<Long>- Parameters:
watermark- the initial watermark
-
processElement
public boolean processElement(org.apache.flink.table.data.RowData key, org.apache.flink.table.data.RowData element) throws ExceptionDescription copied from interface:SlicingWindowProcessorProcess an element with associated key from the input stream. Returns true if this element is dropped because of late arrival.- Specified by:
processElementin interfaceSlicingWindowProcessor<Long>- Parameters:
key- the key associated with the elementelement- The element to process.- Throws:
Exception
-
sliceStateMergeTarget
protected abstract long sliceStateMergeTarget(long sliceToMerge) throws ExceptionReturns the slice state target to merge the given slice into when firing windows. For unshared windows, there should no merging happens, so the merge target should be just the givensliceToMerge. For shared windows, the merge target should be the shared slice state.
-
advanceProgress
public void advanceProgress(long progress) throws ExceptionDescription copied from interface:SlicingWindowProcessorAdvances the progress time, the progress time is watermark if working in event-time mode, or current processing time if working in processing-time mode.This will potentially flush buffered data into states, because the watermark advancement may be in a very small step, but we don't need to flush buffered data for every watermark advancement.
- Specified by:
advanceProgressin interfaceSlicingWindowProcessor<Long>- Parameters:
progress- the current progress time- Throws:
Exception
-
prepareCheckpoint
public void prepareCheckpoint() throws ExceptionDescription copied from interface:SlicingWindowProcessorPerforms a preparation before checkpoint. This usually flushes buffered data into state.- Specified by:
prepareCheckpointin interfaceSlicingWindowProcessor<Long>- Throws:
Exception
-
clearWindow
public void clearWindow(Long windowEnd) throws Exception
Description copied from interface:SlicingWindowProcessorClear state and resources associated with the given window namespace.Note: the key context has been set.
- Specified by:
clearWindowin interfaceSlicingWindowProcessor<Long>- Parameters:
windowEnd- the window to clear- Throws:
Exception
-
close
public void close() throws ExceptionDescription copied from interface:SlicingWindowProcessorThe tear-down method of the function. It is called after the last call to the main working methods.- Specified by:
closein interfaceSlicingWindowProcessor<Long>- Throws:
Exception
-
createWindowSerializer
public org.apache.flink.api.common.typeutils.TypeSerializer<Long> createWindowSerializer()
Description copied from interface:SlicingWindowProcessorReturns the serializer of the window type.- Specified by:
createWindowSerializerin interfaceSlicingWindowProcessor<Long>
-
collect
protected void collect(org.apache.flink.table.data.RowData aggResult)
-
-