@Internal public abstract class AbstractPythonStatelessFunctionFlatMap extends RichFlatMapFunction<Row,Row> implements ResultTypeQueryable<Row>
RichFlatMapFunction
used to invoke Python stateless functions for
the old planner.Modifier and Type | Field and 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 LinkedBlockingQueue<Row> |
forwardedInputQueue
The queue holding the input elements for which the execution results have not been received.
|
protected TypeSerializer<Row> |
forwardedInputSerializer
The type serializer for the forwarded fields.
|
protected RowType |
inputType
The input logical type.
|
protected Map<String,String> |
jobOptions
The options used to configure the Python worker process.
|
protected RowType |
outputType
The output logical type.
|
protected PythonFunctionRunner |
pythonFunctionRunner
The
PythonFunctionRunner which is responsible for Python user-defined function
execution. |
protected Collector<Row> |
resultCollector
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.
|
Constructor and Description |
---|
AbstractPythonStatelessFunctionFlatMap(Configuration config,
RowType inputType,
RowType outputType,
int[] userDefinedFunctionInputOffsets) |
Modifier and Type | Method and Description |
---|---|
abstract void |
bufferInput(Row input) |
protected void |
checkInvokeFinishBundleByCount()
Checks whether to invoke finishBundle by elements count.
|
void |
close()
Tear-down method for the user code.
|
protected PythonEnvironmentManager |
createPythonEnvironmentManager() |
abstract void |
emitResult(Tuple2<byte[],Integer> resultTuple) |
void |
flatMap(Row value,
Collector<Row> out)
The core method of the FlatMapFunction.
|
protected FlinkMetricContainer |
getFlinkMetricContainer() |
abstract int |
getForwardedFieldsCount() |
protected Row |
getFunctionInput(Row element) |
abstract String |
getFunctionUrn() |
abstract String |
getInputOutputCoderUrn() |
TypeInformation<Row> |
getProducedType()
Gets the data type (as a
TypeInformation ) produced by this function or input format. |
protected PythonConfig |
getPythonConfig() |
abstract PythonEnv |
getPythonEnv()
Returns the
PythonEnv used to create PythonEnvironmentManager.. |
abstract FlinkFnApi.UserDefinedFunctions |
getUserDefinedFunctionsProto()
Gets the proto representation of the Python user-defined functions to be executed.
|
protected void |
invokeFinishBundle() |
void |
open(Configuration parameters)
Initialization method for the function.
|
abstract void |
processElementInternal(Row value) |
getIterationRuntimeContext, getRuntimeContext, setRuntimeContext
protected final RowType inputType
protected final RowType outputType
protected final Map<String,String> jobOptions
protected transient RowType userDefinedFunctionInputType
protected transient RowType userDefinedFunctionOutputType
protected transient LinkedBlockingQueue<Row> forwardedInputQueue
protected transient Collector<Row> resultCollector
protected transient PythonFunctionRunner pythonFunctionRunner
PythonFunctionRunner
which is responsible for Python user-defined function
execution.protected transient ByteArrayInputStreamWithPos bais
protected transient DataInputViewStreamWrapper baisWrapper
protected transient TypeSerializer<Row> forwardedInputSerializer
protected transient ByteArrayOutputStreamWithPos baos
public AbstractPythonStatelessFunctionFlatMap(Configuration config, RowType inputType, RowType outputType, int[] userDefinedFunctionInputOffsets)
protected PythonConfig getPythonConfig()
public void open(Configuration parameters) throws Exception
RichFunction
The configuration object passed to the function can be used for configuration and initialization. The configuration contains all parameters that were configured on the function in the program composition.
public class MyFilter extends RichFilterFunction<String> {
private String searchString;
public void open(Configuration parameters) {
this.searchString = parameters.getString("foo");
}
public boolean filter(String value) {
return value.equals(searchString);
}
}
By default, this method does nothing.
open
in interface RichFunction
open
in class AbstractRichFunction
parameters
- The configuration containing the parameters attached to the contract.Exception
- Implementations may forward exceptions, which are caught by the runtime.
When the runtime catches an exception, it aborts the task and lets the fail-over logic
decide whether to retry the task execution.Configuration
public void flatMap(Row value, Collector<Row> out) throws Exception
FlatMapFunction
flatMap
in interface FlatMapFunction<Row,Row>
flatMap
in class RichFlatMapFunction<Row,Row>
value
- The input value.out
- The collector for returning result values.Exception
- This method may throw exceptions. Throwing an exception will cause the
operation to fail and may trigger recovery.public TypeInformation<Row> getProducedType()
ResultTypeQueryable
TypeInformation
) produced by this function or input format.getProducedType
in interface ResultTypeQueryable<Row>
public void close() throws Exception
RichFunction
This method can be used for clean up work.
close
in interface RichFunction
close
in class AbstractRichFunction
Exception
- Implementations may forward exceptions, which are caught by the runtime.
When the runtime catches an exception, it aborts the task and lets the fail-over logic
decide whether to retry the task execution.public abstract PythonEnv getPythonEnv()
PythonEnv
used to create PythonEnvironmentManager..public abstract void bufferInput(Row input)
public abstract void emitResult(Tuple2<byte[],Integer> resultTuple) throws Exception
Exception
public abstract int getForwardedFieldsCount()
public abstract FlinkFnApi.UserDefinedFunctions getUserDefinedFunctionsProto()
public abstract String getInputOutputCoderUrn()
public abstract String getFunctionUrn()
public abstract void processElementInternal(Row value) throws Exception
Exception
protected void checkInvokeFinishBundleByCount() throws Exception
Exception
protected PythonEnvironmentManager createPythonEnvironmentManager() throws IOException
IOException
protected FlinkMetricContainer getFlinkMetricContainer()
Copyright © 2014–2022 The Apache Software Foundation. All rights reserved.