K
- The type of key returned by the KeySelector
.W
- The type of Window
that the WindowAssigner
assigns.public abstract class WindowOperator<K,W extends Window> extends AbstractStreamOperator<RowData> implements OneInputStreamOperator<RowData,RowData>, Triggerable<K,W>
WindowAssigner
and Trigger
.
This is the base class for AggregateWindowOperator
and TableAggregateWindowOperator
. The big difference between AggregateWindowOperator
and
TableAggregateWindowOperator
is AggregateWindowOperator
emits only one result for
each aggregate group, while TableAggregateWindowOperator
can emit multi results for each
aggregate group.
When an element arrives it gets assigned a key using a KeySelector
and it gets
assigned to zero or more windows using a WindowAssigner
. Based on this, the element is
put into panes. A pane is the bucket of elements that have the same key and same Window
.
An element can be in multiple panes if it was assigned to multiple windows by the WindowAssigner
.
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 given
NamespaceAggsHandleFunctionBase
is invoked to
produce the results that are emitted for the pane to which the Trigger
belongs.
The parameter types: <IN>
: RowData <OUT>
: JoinedRowData(KEY, AGG_RESULT)
<KEY>
: GenericRowData <AGG_RESULT>
: GenericRowData <ACC>
: GenericRowData
Modifier and Type | Field and Description |
---|---|
protected TimestampedCollector<RowData> |
collector
This is used for emitting elements with a given timestamp.
|
protected InternalValueState<K,W,RowData> |
previousState |
protected boolean |
produceUpdates |
protected RecordCounter |
recordCounter
Used to count the number of added and retracted input records.
|
protected 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.
|
protected NamespaceAggsHandleFunctionBase<W> |
windowAggregator |
protected InternalWindowProcessFunction<K,W> |
windowFunction |
chainingStrategy, config, latencyStats, LOG, metrics, output, processingTimeService
Modifier and Type | Method and Description |
---|---|
void |
close()
This method is called at the very end of the operator's life, both in the case of a
successful completion of the operation, and in the case of a failure and canceling.
|
protected abstract void |
compileGeneratedCode() |
protected abstract void |
emitWindowResult(W window)
Emits the window result of the given window.
|
protected Counter |
getNumLateRecordsDropped() |
protected Gauge<Long> |
getWatermarkLatency() |
void |
onEventTime(InternalTimer<K,W> timer)
Invoked when an event-time timer fires.
|
void |
onProcessingTime(InternalTimer<K,W> timer)
Invoked when a processing-time timer fires.
|
void |
open()
This method is called immediately before any elements are processed, it should contain the
operator's initialization logic, e.g. state initialization.
|
void |
processElement(StreamRecord<RowData> record)
Processes one element that arrived on this input of the
MultipleInputStreamOperator . |
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, processWatermark, processWatermark1, processWatermark2, processWatermarkStatus, processWatermarkStatus1, processWatermarkStatus2, reportOrForwardLatencyMarker, setChainingStrategy, setCurrentKey, setKeyContextElement1, setKeyContextElement2, setProcessingTimeService, setup, snapshotState, snapshotState
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
setKeyContextElement
finish, getMetricGroup, getOperatorID, initializeState, prepareSnapshotPreBarrier, setKeyContextElement1, setKeyContextElement2, snapshotState
notifyCheckpointAborted, notifyCheckpointComplete
getCurrentKey, setCurrentKey
processLatencyMarker, processWatermark, processWatermarkStatus
hasKeyContext
protected final boolean produceUpdates
protected final ZoneId shiftTimeZone
protected final RecordCounter recordCounter
protected NamespaceAggsHandleFunctionBase<W extends Window> windowAggregator
protected transient InternalWindowProcessFunction<K,W extends Window> windowFunction
protected transient TimestampedCollector<RowData> collector
protected transient InternalValueState<K,W extends Window,RowData> previousState
protected abstract void compileGeneratedCode()
public void open() throws Exception
AbstractStreamOperator
The default implementation does nothing.
open
in interface StreamOperator<RowData>
open
in class AbstractStreamOperator<RowData>
Exception
- An exception in this method causes the operator to fail.public void close() throws Exception
StreamOperator
This method is expected to make a thorough effort to release all resources that the operator has acquired.
NOTE:It can not emit any records! If you need to emit records at the end of
processing, do so in the StreamOperator.finish()
method.
close
in interface StreamOperator<RowData>
close
in class AbstractStreamOperator<RowData>
Exception
public void processElement(StreamRecord<RowData> record) throws Exception
Input
MultipleInputStreamOperator
.
This method is guaranteed to not be called concurrently with other methods of the operator.processElement
in interface Input<RowData>
Exception
public void onEventTime(InternalTimer<K,W> timer) throws Exception
Triggerable
onEventTime
in interface Triggerable<K,W extends Window>
Exception
public void onProcessingTime(InternalTimer<K,W> timer) throws Exception
Triggerable
onProcessingTime
in interface Triggerable<K,W extends Window>
Exception
protected abstract void emitWindowResult(W window) throws Exception
Exception
protected Counter getNumLateRecordsDropped()
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.