Class ExternalPythonKeyedProcessOperator<OUT>

All Implemented Interfaces:
Serializable, org.apache.flink.api.common.state.CheckpointListener, org.apache.flink.api.java.typeutils.ResultTypeQueryable<OUT>, org.apache.flink.streaming.api.operators.BoundedOneInput, org.apache.flink.streaming.api.operators.Input<org.apache.flink.types.Row>, org.apache.flink.streaming.api.operators.KeyContext, org.apache.flink.streaming.api.operators.KeyContextHandler, org.apache.flink.streaming.api.operators.OneInputStreamOperator<org.apache.flink.types.Row,OUT>, DataStreamPythonFunctionOperator<OUT>, org.apache.flink.streaming.api.operators.StreamOperator<OUT>, org.apache.flink.streaming.api.operators.StreamOperatorStateHandler.CheckpointedStreamOperator, org.apache.flink.streaming.api.operators.Triggerable<org.apache.flink.types.Row,Object>, org.apache.flink.streaming.api.operators.YieldingOperator<OUT>

@Internal public class ExternalPythonKeyedProcessOperator<OUT> extends AbstractExternalOneInputPythonFunctionOperator<org.apache.flink.types.Row,OUT> implements org.apache.flink.streaming.api.operators.Triggerable<org.apache.flink.types.Row,Object>
ExternalPythonKeyedProcessOperator is responsible for launching beam runner which will start a python harness to execute user defined python function. It is also able to handle the timer and state request from the python stateful user defined function.
See Also:
  • Constructor Details

    • ExternalPythonKeyedProcessOperator

      public ExternalPythonKeyedProcessOperator(org.apache.flink.configuration.Configuration config, DataStreamPythonFunctionInfo pythonFunctionInfo, org.apache.flink.api.java.typeutils.RowTypeInfo inputTypeInfo, org.apache.flink.api.common.typeinfo.TypeInformation<OUT> outputTypeInfo)
    • ExternalPythonKeyedProcessOperator

      public ExternalPythonKeyedProcessOperator(org.apache.flink.configuration.Configuration config, DataStreamPythonFunctionInfo pythonFunctionInfo, org.apache.flink.api.java.typeutils.RowTypeInfo inputTypeInfo, org.apache.flink.api.common.typeinfo.TypeInformation<OUT> outputTypeInfo, org.apache.flink.api.common.typeutils.TypeSerializer namespaceSerializer)
  • Method Details

    • open

      public void open() throws Exception
      Specified by:
      open in interface org.apache.flink.streaming.api.operators.StreamOperator<OUT>
      Overrides:
      open in class AbstractExternalOneInputPythonFunctionOperator<org.apache.flink.types.Row,OUT>
      Throws:
      Exception
    • onEventTime

      public void onEventTime(org.apache.flink.streaming.api.operators.InternalTimer<org.apache.flink.types.Row,Object> timer) throws Exception
      Specified by:
      onEventTime in interface org.apache.flink.streaming.api.operators.Triggerable<org.apache.flink.types.Row,Object>
      Throws:
      Exception
    • onProcessingTime

      public void onProcessingTime(org.apache.flink.streaming.api.operators.InternalTimer<org.apache.flink.types.Row,Object> timer) throws Exception
      Specified by:
      onProcessingTime in interface org.apache.flink.streaming.api.operators.Triggerable<org.apache.flink.types.Row,Object>
      Throws:
      Exception
    • createPythonFunctionRunner

      public PythonFunctionRunner createPythonFunctionRunner() throws Exception
      Description copied from class: AbstractExternalPythonFunctionOperator
      Creates the PythonFunctionRunner which is responsible for Python user-defined function execution.
      Specified by:
      createPythonFunctionRunner in class AbstractExternalPythonFunctionOperator<OUT>
      Throws:
      Exception
    • processElement

      public void processElement(org.apache.flink.streaming.runtime.streamrecord.StreamRecord<org.apache.flink.types.Row> element) throws Exception
      Specified by:
      processElement in interface org.apache.flink.streaming.api.operators.Input<OUT>
      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 interface org.apache.flink.streaming.api.operators.KeyContext
      Overrides:
      setCurrentKey in class AbstractPythonFunctionOperator<OUT>
    • getCurrentKey

      public Object getCurrentKey()
      Specified by:
      getCurrentKey in interface org.apache.flink.streaming.api.operators.KeyContext
      Overrides:
      getCurrentKey in class org.apache.flink.streaming.api.operators.AbstractStreamOperator<OUT>
    • copy

      public <T> AbstractExternalDataStreamPythonFunctionOperator<T> copy(DataStreamPythonFunctionInfo pythonFunctionInfo, org.apache.flink.api.common.typeinfo.TypeInformation<T> outputTypeInfo)
      Description copied from interface: DataStreamPythonFunctionOperator
      Make a copy of the DataStreamPythonFunctionOperator with the given pythonFunctionInfo and outputTypeInfo. This is used for chaining optimization which may need to update the underlying pythonFunctionInfo and outputTypeInfo with the other fields not changed.
      Specified by:
      copy in interface DataStreamPythonFunctionOperator<OUT>