Class AbstractPythonStreamAggregateOperator
- java.lang.Object
-
- org.apache.flink.streaming.api.operators.AbstractStreamOperator<OUT>
-
- org.apache.flink.streaming.api.operators.python.AbstractPythonFunctionOperator<OUT>
-
- org.apache.flink.streaming.api.operators.python.process.AbstractExternalPythonFunctionOperator<OUT>
-
- org.apache.flink.table.runtime.operators.python.AbstractOneInputPythonFunctionOperator<RowData,RowData>
-
- org.apache.flink.table.runtime.operators.python.aggregate.AbstractPythonStreamAggregateOperator
-
- All Implemented Interfaces:
Serializable
,CheckpointListener
,BoundedOneInput
,Input<RowData>
,KeyContext
,KeyContextHandler
,OneInputStreamOperator<RowData,RowData>
,StreamOperator<RowData>
,StreamOperatorStateHandler.CheckpointedStreamOperator
,YieldingOperator<RowData>
- Direct Known Subclasses:
AbstractPythonStreamGroupAggregateOperator
,PythonStreamGroupWindowAggregateOperator
@Internal public abstract class AbstractPythonStreamAggregateOperator extends AbstractOneInputPythonFunctionOperator<RowData,RowData>
Base class forAbstractPythonStreamGroupAggregateOperator
andPythonStreamGroupWindowAggregateOperator
.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ByteArrayInputStreamWithPos
bais
Reusable InputStream used to holding the execution results to be deserialized.protected DataInputViewStreamWrapper
baisWrapper
InputStream Wrapper.protected ByteArrayOutputStreamWithPos
baos
Reusable OutputStream used to holding the serialized input elements.protected DataOutputViewStreamWrapper
baosWrapper
OutputStream Wrapper.protected RowType
inputType
The input logical type.protected RowType
outputType
The output logical type.protected StreamRecordRowDataWrappingCollector
rowDataWrapper
The collector used to collect records.protected RowType
userDefinedFunctionInputType
The user-defined function input logical type.protected RowType
userDefinedFunctionOutputType
The user-defined function output logical type.-
Fields inherited from class org.apache.flink.streaming.api.operators.python.process.AbstractExternalPythonFunctionOperator
pythonFunctionRunner
-
Fields inherited from class org.apache.flink.streaming.api.operators.python.AbstractPythonFunctionOperator
bundleFinishedCallback, config, elementCount, lastFinishBundleTime, maxBundleSize, systemEnvEnabled
-
Fields inherited from class org.apache.flink.streaming.api.operators.AbstractStreamOperator
lastRecordAttributes1, lastRecordAttributes2, latencyStats, LOG, metrics, output, processingTimeService, stateHandler, stateKeySelector1, stateKeySelector2, timeServiceManager
-
-
Constructor Summary
Constructors Constructor Description AbstractPythonStreamAggregateOperator(Configuration config, RowType inputType, RowType outputType, PythonAggregateFunctionInfo[] aggregateFunctions, DataViewSpec[][] dataViewSpecs, int[] grouping, int indexOfCountStar, boolean generateUpdateBefore)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description FlinkFnApi.CoderInfoDescriptor
createInputCoderInfoDescriptor(RowType runnerInputType)
FlinkFnApi.CoderInfoDescriptor
createOutputCoderInfoDescriptor(RowType runnerOutType)
PythonFunctionRunner
createPythonFunctionRunner()
Creates thePythonFunctionRunner
which is responsible for Python user-defined function execution.abstract RowType
createUserDefinedFunctionInputType()
abstract RowType
createUserDefinedFunctionOutputType()
Object
getCurrentKey()
abstract String
getFunctionUrn()
protected RowType
getKeyType()
PythonEnv
getPythonEnv()
Returns thePythonEnv
used to create PythonEnvironmentManager..protected FlinkFnApi.UserDefinedAggregateFunctions
getUserDefinedFunctionsProto()
Gets the proto representation of the Python user-defined aggregate functions to be executed.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> element)
Processes one element that arrived on this input of theMultipleInputStreamOperator
.abstract void
processElementInternal(RowData value)
void
setCurrentKey(Object key)
As the beam state gRPC service will access the KeyedStateBackend in parallel with this operator, we must override this method to prevent changing the current key of the KeyedStateBackend while the beam service is handling requests.-
Methods inherited from class org.apache.flink.table.runtime.operators.python.AbstractOneInputPythonFunctionOperator
endInput
-
Methods inherited from class org.apache.flink.streaming.api.operators.python.process.AbstractExternalPythonFunctionOperator
close, createPythonEnvironmentManager, emitResult, emitResults, invokeFinishBundle
-
Methods inherited from class org.apache.flink.streaming.api.operators.python.AbstractPythonFunctionOperator
checkInvokeFinishBundleByCount, finish, getConfiguration, getFlinkMetricContainer, isBundleFinished, prepareSnapshotPreBarrier, processWatermark
-
Methods inherited from class org.apache.flink.streaming.api.operators.AbstractStreamOperator
getContainingTask, getExecutionConfig, getInternalTimerService, getKeyedStateBackend, getKeyedStateStore, getMetricGroup, getOperatorConfig, getOperatorID, getOperatorName, getOperatorStateBackend, getOrCreateKeyedState, getPartitionedState, getPartitionedState, getProcessingTimeService, getRuntimeContext, getStateKeySelector1, getStateKeySelector2, getTimeServiceManager, getUserCodeClassloader, hasKeyContext1, hasKeyContext2, initializeState, initializeState, isUsingCustomRawKeyedState, notifyCheckpointAborted, notifyCheckpointComplete, processLatencyMarker, processLatencyMarker1, processLatencyMarker2, processRecordAttributes, processRecordAttributes1, processRecordAttributes2, processWatermark1, processWatermark2, processWatermarkStatus, processWatermarkStatus1, processWatermarkStatus2, reportOrForwardLatencyMarker, setKeyContextElement1, setKeyContextElement2, setMailboxExecutor, setProcessingTimeService, setup, snapshotState, snapshotState, useSplittableTimers
-
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.KeyContextHandler
hasKeyContext
-
Methods inherited from interface org.apache.flink.streaming.api.operators.OneInputStreamOperator
setKeyContextElement
-
Methods inherited from interface org.apache.flink.streaming.api.operators.StreamOperator
close, finish, getMetricGroup, getOperatorAttributes, getOperatorID, initializeState, prepareSnapshotPreBarrier, setKeyContextElement1, setKeyContextElement2, snapshotState
-
-
-
-
Field Detail
-
inputType
protected final RowType inputType
The input logical type.
-
outputType
protected final RowType outputType
The output logical type.
-
userDefinedFunctionInputType
protected transient RowType userDefinedFunctionInputType
The user-defined function input logical type.
-
userDefinedFunctionOutputType
protected transient RowType userDefinedFunctionOutputType
The user-defined function output logical type.
-
bais
protected transient ByteArrayInputStreamWithPos bais
Reusable InputStream used to holding the execution results to be deserialized.
-
baisWrapper
protected transient DataInputViewStreamWrapper baisWrapper
InputStream Wrapper.
-
baos
protected transient ByteArrayOutputStreamWithPos baos
Reusable OutputStream used to holding the serialized input elements.
-
baosWrapper
protected transient DataOutputViewStreamWrapper baosWrapper
OutputStream Wrapper.
-
rowDataWrapper
protected transient StreamRecordRowDataWrappingCollector rowDataWrapper
The collector used to collect records.
-
-
Constructor Detail
-
AbstractPythonStreamAggregateOperator
public AbstractPythonStreamAggregateOperator(Configuration config, RowType inputType, RowType outputType, PythonAggregateFunctionInfo[] aggregateFunctions, DataViewSpec[][] dataViewSpecs, int[] grouping, int indexOfCountStar, boolean generateUpdateBefore)
-
-
Method Detail
-
open
public void open() throws Exception
Description copied from class:AbstractStreamOperator
This method is called immediately before any elements are processed, it should contain the operator's initialization logic, e.g. state initialization.The default implementation does nothing.
- Specified by:
open
in interfaceStreamOperator<RowData>
- Overrides:
open
in classAbstractExternalPythonFunctionOperator<RowData>
- Throws:
Exception
- An exception in this method causes the operator to fail.
-
processElement
public void processElement(StreamRecord<RowData> element) throws Exception
Description copied from interface:Input
Processes one element that arrived on this input of theMultipleInputStreamOperator
. This method is guaranteed to not be called concurrently with other methods of the operator.- Throws:
Exception
-
createPythonFunctionRunner
public PythonFunctionRunner createPythonFunctionRunner() throws Exception
Description copied from class:AbstractExternalPythonFunctionOperator
Creates thePythonFunctionRunner
which is responsible for Python user-defined function execution.- Specified by:
createPythonFunctionRunner
in classAbstractExternalPythonFunctionOperator<RowData>
- Throws:
Exception
-
setCurrentKey
public void setCurrentKey(Object key)
As the beam state gRPC service will access the KeyedStateBackend in parallel with this operator, we must override this method to prevent changing the current key of the KeyedStateBackend while the beam service is handling requests.- Specified by:
setCurrentKey
in interfaceKeyContext
- Overrides:
setCurrentKey
in classAbstractPythonFunctionOperator<RowData>
-
getCurrentKey
public Object getCurrentKey()
- Specified by:
getCurrentKey
in interfaceKeyContext
- Overrides:
getCurrentKey
in classAbstractStreamOperator<RowData>
-
getPythonEnv
public PythonEnv getPythonEnv()
Description copied from class:AbstractExternalPythonFunctionOperator
Returns thePythonEnv
used to create PythonEnvironmentManager..- Specified by:
getPythonEnv
in classAbstractExternalPythonFunctionOperator<RowData>
-
getKeyType
protected RowType getKeyType()
-
getUserDefinedFunctionsProto
protected FlinkFnApi.UserDefinedAggregateFunctions getUserDefinedFunctionsProto()
Gets the proto representation of the Python user-defined aggregate functions to be executed.
-
getFunctionUrn
public abstract String getFunctionUrn()
-
processElementInternal
public abstract void processElementInternal(RowData value) throws Exception
- Throws:
Exception
-
createUserDefinedFunctionInputType
public abstract RowType createUserDefinedFunctionInputType()
-
createUserDefinedFunctionOutputType
public abstract RowType createUserDefinedFunctionOutputType()
-
createInputCoderInfoDescriptor
public FlinkFnApi.CoderInfoDescriptor createInputCoderInfoDescriptor(RowType runnerInputType)
-
createOutputCoderInfoDescriptor
public FlinkFnApi.CoderInfoDescriptor createOutputCoderInfoDescriptor(RowType runnerOutType)
-
-