@Internal public abstract class BeamPythonFunctionRunner extends Object implements PythonFunctionRunner
BeamPythonFunctionRunner used to execute Python functions.| 限定符和类型 | 字段和说明 |
|---|---|
protected static org.slf4j.Logger |
LOG |
protected org.apache.beam.sdk.fn.data.FnDataReceiver<org.apache.beam.sdk.util.WindowedValue<byte[]>> |
mainInputReceiver
The receiver which forwards the input elements to a remote environment for processing.
|
protected LinkedBlockingQueue<byte[]> |
resultBuffer
The Python function execution result receiver.
|
protected org.apache.flink.api.java.tuple.Tuple2<byte[],Integer> |
resultTuple
The Python function execution result tuple.
|
| 构造器和说明 |
|---|
BeamPythonFunctionRunner(String taskName,
PythonEnvironmentManager environmentManager,
String functionUrn,
Map<String,String> jobOptions,
FlinkMetricContainer flinkMetricContainer,
org.apache.flink.runtime.state.KeyedStateBackend keyedStateBackend,
org.apache.flink.api.common.typeutils.TypeSerializer keySerializer,
org.apache.flink.runtime.memory.MemoryManager memoryManager,
double managedMemoryFraction) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close()
Tear-down the Python function runner.
|
org.apache.beam.runners.fnexecution.control.JobBundleFactory |
createJobBundleFactory(org.apache.beam.vendor.grpc.v1p26p0.com.google.protobuf.Struct pipelineOptions) |
void |
flush()
Forces to finish the processing of the current bundle of elements.
|
protected abstract org.apache.beam.model.pipeline.v1.RunnerApi.Coder |
getInputCoderProto() |
protected abstract org.apache.beam.model.pipeline.v1.RunnerApi.Coder |
getOutputCoderProto() |
protected abstract byte[] |
getUserDefinedFunctionsProtoBytes() |
void |
open(PythonConfig config)
Prepares the Python function runner, such as preparing the Python execution environment, etc.
|
org.apache.flink.api.java.tuple.Tuple2<byte[],Integer> |
pollResult()
Retrieves the Python function result.
|
void |
process(byte[] data)
Executes the Python function with the input byte array.
|
protected void |
startBundle() |
protected static final org.slf4j.Logger LOG
protected final org.apache.flink.api.java.tuple.Tuple2<byte[],Integer> resultTuple
protected transient LinkedBlockingQueue<byte[]> resultBuffer
protected transient org.apache.beam.sdk.fn.data.FnDataReceiver<org.apache.beam.sdk.util.WindowedValue<byte[]>> mainInputReceiver
public BeamPythonFunctionRunner(String taskName, PythonEnvironmentManager environmentManager, String functionUrn, Map<String,String> jobOptions, FlinkMetricContainer flinkMetricContainer, @Nullable org.apache.flink.runtime.state.KeyedStateBackend keyedStateBackend, @Nullable org.apache.flink.api.common.typeutils.TypeSerializer keySerializer, @Nullable org.apache.flink.runtime.memory.MemoryManager memoryManager, double managedMemoryFraction)
public void open(PythonConfig config) throws Exception
PythonFunctionRunneropen 在接口中 PythonFunctionRunnerExceptionpublic void close()
throws Exception
PythonFunctionRunnerclose 在接口中 PythonFunctionRunnerExceptionpublic void process(byte[] data)
throws Exception
PythonFunctionRunnerprocess 在接口中 PythonFunctionRunnerdata - the byte array data.Exceptionpublic org.apache.flink.api.java.tuple.Tuple2<byte[],Integer> pollResult() throws Exception
PythonFunctionRunnerpollResult 在接口中 PythonFunctionRunnernull if the result buffer is
empty. f0 means the byte array buffer which stores the Python function result. f1 means
the length of the Python function result byte array.Exceptionpublic void flush()
throws Exception
PythonFunctionRunnerflush 在接口中 PythonFunctionRunnerExceptionpublic org.apache.beam.runners.fnexecution.control.JobBundleFactory createJobBundleFactory(org.apache.beam.vendor.grpc.v1p26p0.com.google.protobuf.Struct pipelineOptions)
throws Exception
Exceptionprotected void startBundle()
protected abstract byte[] getUserDefinedFunctionsProtoBytes()
protected abstract org.apache.beam.model.pipeline.v1.RunnerApi.Coder getInputCoderProto()
protected abstract org.apache.beam.model.pipeline.v1.RunnerApi.Coder getOutputCoderProto()
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.