Class WindowOperator<K,W extends Window>
- java.lang.Object
-
- org.apache.flink.streaming.api.operators.AbstractStreamOperator<org.apache.flink.table.data.RowData>
-
- org.apache.flink.table.runtime.operators.window.groupwindow.operator.WindowOperator<K,W>
-
- Type Parameters:
K- The type of key returned by theKeySelector.W- The type ofWindowthat theWindowAssignerassigns.
- All Implemented Interfaces:
Serializable,org.apache.flink.api.common.state.CheckpointListener,org.apache.flink.streaming.api.operators.Input<org.apache.flink.table.data.RowData>,org.apache.flink.streaming.api.operators.KeyContext,org.apache.flink.streaming.api.operators.KeyContextHandler,org.apache.flink.streaming.api.operators.OneInputStreamOperator<org.apache.flink.table.data.RowData,org.apache.flink.table.data.RowData>,org.apache.flink.streaming.api.operators.SetupableStreamOperator<org.apache.flink.table.data.RowData>,org.apache.flink.streaming.api.operators.StreamOperator<org.apache.flink.table.data.RowData>,org.apache.flink.streaming.api.operators.StreamOperatorStateHandler.CheckpointedStreamOperator,org.apache.flink.streaming.api.operators.Triggerable<K,W>
- Direct Known Subclasses:
AggregateWindowOperator,TableAggregateWindowOperator
public abstract class WindowOperator<K,W extends Window> extends org.apache.flink.streaming.api.operators.AbstractStreamOperator<org.apache.flink.table.data.RowData> implements org.apache.flink.streaming.api.operators.OneInputStreamOperator<org.apache.flink.table.data.RowData,org.apache.flink.table.data.RowData>, org.apache.flink.streaming.api.operators.Triggerable<K,W>An operator that implements the logic for windowing based on aGroupWindowAssignerandTrigger.This is the base class for
AggregateWindowOperatorandTableAggregateWindowOperator. The big difference betweenAggregateWindowOperatorandTableAggregateWindowOperatorisAggregateWindowOperatoremits only one result for each aggregate group, whileTableAggregateWindowOperatorcan emit multi results for each aggregate group.When an element arrives it gets assigned a key using a
KeySelectorand it gets assigned to zero or more windows using aGroupWindowAssigner. Based on this, the element is put into panes. A pane is the bucket of elements that have the same key and sameWindow. An element can be in multiple panes if it was assigned to multiple windows by theWindowAssigner.Each pane gets its own instance of the provided
Trigger. This trigger determines when the contents of the pane should be processed to emit results. When a trigger fires, the givenNamespaceAggsHandleFunctionBaseis invoked to produce the results that are emitted for the pane to which theTriggerbelongs.The parameter types:
<IN>: RowData<OUT>: JoinedRowData(KEY, AGG_RESULT)<KEY>: GenericRowData<AGG_RESULT>: GenericRowData<ACC>: GenericRowData- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.flink.streaming.api.operators.TimestampedCollector<org.apache.flink.table.data.RowData>collectorThis is used for emitting elements with a given timestamp.protected org.apache.flink.runtime.state.internal.InternalValueState<K,W,org.apache.flink.table.data.RowData>previousStateprotected booleanproduceUpdatesprotected RecordCounterrecordCounterUsed to count the number of added and retracted input records.protected java.time.ZoneIdshiftTimeZoneThe shift timezone of the window, if the proctime or rowtime type is TIMESTAMP_LTZ, the shift timezone is the timezone user configured in TableConfig, other cases the timezone is UTC which means never shift when assigning windows.protected NamespaceAggsHandleFunctionBase<W>windowAggregatorprotected InternalWindowProcessFunction<K,W>windowFunction
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()protected abstract voidcompileGeneratedCode()protected abstract voidemitWindowResult(W window)Emits the window result of the given window.protected org.apache.flink.metrics.CountergetNumLateRecordsDropped()protected org.apache.flink.metrics.Gauge<Long>getWatermarkLatency()voidonEventTime(org.apache.flink.streaming.api.operators.InternalTimer<K,W> timer)voidonProcessingTime(org.apache.flink.streaming.api.operators.InternalTimer<K,W> timer)voidopen()voidprocessElement(org.apache.flink.streaming.runtime.streamrecord.StreamRecord<org.apache.flink.table.data.RowData> record)-
Methods inherited from class org.apache.flink.streaming.api.operators.AbstractStreamOperator
finish, getChainingStrategy, getContainingTask, getCurrentKey, getExecutionConfig, getInternalTimerService, getKeyedStateBackend, getKeyedStateStore, getMetricGroup, getOperatorConfig, getOperatorID, getOperatorName, getOperatorStateBackend, getOrCreateKeyedState, getPartitionedState, getPartitionedState, getProcessingTimeService, getRuntimeContext, getTimeServiceManager, getUserCodeClassloader, hasKeyContext1, hasKeyContext2, initializeState, initializeState, isUsingCustomRawKeyedState, notifyCheckpointAborted, notifyCheckpointComplete, prepareSnapshotPreBarrier, processLatencyMarker, processLatencyMarker1, processLatencyMarker2, processRecordAttributes, processRecordAttributes1, processRecordAttributes2, processWatermark, processWatermark1, processWatermark2, processWatermarkStatus, processWatermarkStatus1, processWatermarkStatus2, reportOrForwardLatencyMarker, setChainingStrategy, setCurrentKey, setKeyContextElement1, setKeyContextElement2, setProcessingTimeService, setup, snapshotState, snapshotState
-
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.api.common.state.CheckpointListener
notifyCheckpointAborted, notifyCheckpointComplete
-
Methods inherited from interface org.apache.flink.streaming.api.operators.Input
processLatencyMarker, processRecordAttributes, processWatermark, processWatermarkStatus
-
Methods inherited from interface org.apache.flink.streaming.api.operators.KeyContext
getCurrentKey, setCurrentKey
-
Methods inherited from interface org.apache.flink.streaming.api.operators.KeyContextHandler
hasKeyContext
-
-
-
-
Field Detail
-
produceUpdates
protected final boolean produceUpdates
-
shiftTimeZone
protected final java.time.ZoneId shiftTimeZone
The shift timezone of the window, if the proctime or rowtime type is TIMESTAMP_LTZ, the shift timezone is the timezone user configured in TableConfig, other cases the timezone is UTC which means never shift when assigning windows.
-
recordCounter
protected final RecordCounter recordCounter
Used to count the number of added and retracted input records.
-
windowAggregator
protected NamespaceAggsHandleFunctionBase<W extends Window> windowAggregator
-
windowFunction
protected transient InternalWindowProcessFunction<K,W extends Window> windowFunction
-
collector
protected transient org.apache.flink.streaming.api.operators.TimestampedCollector<org.apache.flink.table.data.RowData> collector
This is used for emitting elements with a given timestamp.
-
-
Method Detail
-
compileGeneratedCode
protected abstract void compileGeneratedCode()
-
open
public void open() throws Exception
-
close
public void close() throws Exception
-
processElement
public void processElement(org.apache.flink.streaming.runtime.streamrecord.StreamRecord<org.apache.flink.table.data.RowData> record) throws Exception
-
onEventTime
public void onEventTime(org.apache.flink.streaming.api.operators.InternalTimer<K,W> timer) throws Exception
-
onProcessingTime
public void onProcessingTime(org.apache.flink.streaming.api.operators.InternalTimer<K,W> timer) throws Exception
-
emitWindowResult
protected abstract void emitWindowResult(W window) throws Exception
Emits the window result of the given window.- Throws:
Exception
-
getNumLateRecordsDropped
protected org.apache.flink.metrics.Counter getNumLateRecordsDropped()
-
getWatermarkLatency
protected org.apache.flink.metrics.Gauge<Long> getWatermarkLatency()
-
-