@Internal public abstract class AbstractPythonFunctionOperator<OUT> extends AbstractStreamOperator<OUT>
Modifier and Type | Field and Description |
---|---|
protected int |
elementCount
Number of processed elements in the current bundle.
|
protected int |
maxBundleSize
Max number of elements to include in a bundle.
|
protected PythonFunctionRunner |
pythonFunctionRunner
The
PythonFunctionRunner which is responsible for Python user-defined function
execution. |
chainingStrategy, latencyStats, LOG, metrics, output, processingTimeService
Constructor and Description |
---|
AbstractPythonFunctionOperator(Configuration config) |
Modifier and Type | Method and Description |
---|---|
protected void |
checkInvokeFinishBundleByCount()
Checks whether to invoke finishBundle by elements count.
|
void |
close()
This method is called after all records have been added to the operators via the methods
Input.processElement(StreamRecord) , or TwoInputStreamOperator.processElement1(StreamRecord) and TwoInputStreamOperator.processElement2(StreamRecord) . |
protected PythonEnvironmentManager |
createPythonEnvironmentManager() |
abstract PythonFunctionRunner |
createPythonFunctionRunner()
Creates the
PythonFunctionRunner which is responsible for Python user-defined
function execution. |
void |
dispose()
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.
|
abstract void |
emitResult(Tuple2<byte[],Integer> resultTuple)
Sends the execution result to the downstream operator.
|
protected void |
emitResults() |
PythonConfig |
getConfig()
Returns the
PythonConfig . |
protected FlinkMetricContainer |
getFlinkMetricContainer() |
PythonConfig |
getPythonConfig() |
abstract PythonEnv |
getPythonEnv()
Returns the
PythonEnv used to create PythonEnvironmentManager.. |
protected void |
invokeFinishBundle() |
boolean |
isBundleFinished()
Returns whether the bundle is finished.
|
void |
open()
This method is called immediately before any elements are processed, it should contain the
operator's initialization logic, e.g.
|
void |
prepareSnapshotPreBarrier(long checkpointId)
This method is called when the operator should do a snapshot, before it emits its own
checkpoint barrier.
|
void |
processWatermark(Watermark mark) |
void |
setPythonConfig(PythonConfig pythonConfig)
Reset the
PythonConfig if needed. |
getChainingStrategy, getContainingTask, getCurrentKey, getExecutionConfig, getInternalTimerService, getKeyedStateBackend, getKeyedStateStore, getMetricGroup, getOperatorConfig, getOperatorID, getOperatorName, getOperatorStateBackend, getOrCreateKeyedState, getPartitionedState, getPartitionedState, getProcessingTimeService, getRuntimeContext, getTimeServiceManager, getUserCodeClassloader, initializeState, initializeState, isUsingCustomRawKeyedState, notifyCheckpointAborted, notifyCheckpointComplete, processLatencyMarker, processLatencyMarker1, processLatencyMarker2, processWatermark1, processWatermark2, reportOrForwardLatencyMarker, setChainingStrategy, setCurrentKey, setKeyContextElement1, setKeyContextElement2, setProcessingTimeService, setup, snapshotState, snapshotState
protected transient PythonFunctionRunner pythonFunctionRunner
PythonFunctionRunner
which is responsible for Python user-defined function
execution.protected transient int maxBundleSize
protected transient int elementCount
public AbstractPythonFunctionOperator(Configuration config)
public PythonConfig getPythonConfig()
public void open() throws Exception
AbstractStreamOperator
The default implementation does nothing.
open
in interface StreamOperator<OUT>
open
in class AbstractStreamOperator<OUT>
Exception
- An exception in this method causes the operator to fail.public void close() throws Exception
AbstractStreamOperator
Input.processElement(StreamRecord)
, or TwoInputStreamOperator.processElement1(StreamRecord)
and TwoInputStreamOperator.processElement2(StreamRecord)
.
The method is expected to flush all remaining buffered data. Exceptions during this flushing of buffered should be propagated, in order to cause the operation to be recognized asa failed, because the last data items are not processed properly.
close
in interface StreamOperator<OUT>
close
in class AbstractStreamOperator<OUT>
Exception
- An exception in this method causes the operator to fail.public void dispose() throws Exception
AbstractStreamOperator
This method is expected to make a thorough effort to release all resources that the operator has acquired.
dispose
in interface StreamOperator<OUT>
dispose
in interface Disposable
dispose
in class AbstractStreamOperator<OUT>
Exception
- if something goes wrong during disposal.public void prepareSnapshotPreBarrier(long checkpointId) throws Exception
StreamOperator
This method is intended not for any actual state persistence, but only for emitting some data before emitting the checkpoint barrier. Operators that maintain some small transient state that is inefficient to checkpoint (especially when it would need to be checkpointed in a re-scalable way) but can simply be sent downstream before the checkpoint. An example are opportunistic pre-aggregation operators, which have small the pre-aggregation state that is frequently flushed downstream.
Important: This method should not be used for any actual state snapshot logic, because it will inherently be within the synchronous part of the operator's checkpoint. If heavy work is done within this method, it will affect latency and downstream checkpoint alignments.
prepareSnapshotPreBarrier
in interface StreamOperator<OUT>
prepareSnapshotPreBarrier
in class AbstractStreamOperator<OUT>
checkpointId
- The ID of the checkpoint.Exception
- Throwing an exception here causes the operator to fail and go into
recovery.public void processWatermark(Watermark mark) throws Exception
processWatermark
in class AbstractStreamOperator<OUT>
Exception
public boolean isBundleFinished()
public void setPythonConfig(PythonConfig pythonConfig)
PythonConfig
if needed.public PythonConfig getConfig()
PythonConfig
.public abstract PythonFunctionRunner createPythonFunctionRunner() throws Exception
PythonFunctionRunner
which is responsible for Python user-defined
function execution.Exception
public abstract PythonEnv getPythonEnv()
PythonEnv
used to create PythonEnvironmentManager..public abstract void emitResult(Tuple2<byte[],Integer> resultTuple) throws Exception
Exception
protected void checkInvokeFinishBundleByCount() throws Exception
Exception
protected PythonEnvironmentManager createPythonEnvironmentManager() throws IOException
IOException
protected FlinkMetricContainer getFlinkMetricContainer()
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.