Class AbstractUdfOperator<OUT,FT extends Function>
- java.lang.Object
-
- org.apache.flink.api.common.operators.Operator<OUT>
-
- org.apache.flink.api.common.operators.AbstractUdfOperator<OUT,FT>
-
- Type Parameters:
FT
- Type of the user function
- Direct Known Subclasses:
DualInputOperator
,SingleInputOperator
@Internal public abstract class AbstractUdfOperator<OUT,FT extends Function> extends Operator<OUT>
Abstract superclass for all contracts that represent actual operators.
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,Operator<?>>
broadcastInputs
The extra inputs which parameterize the user function.protected UserCodeWrapper<FT>
userFunction
The object or class containing the user function.-
Fields inherited from class org.apache.flink.api.common.operators.Operator
compilerHints, name, operatorInfo, parameters
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractUdfOperator(UserCodeWrapper<FT> function, OperatorInformation<OUT> operatorInfo, String name)
Creates a new abstract operator with the given name wrapping the given user function.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static <U> Class<U>[]
asArray(Class<U> clazz)
Generic utility function that wraps a single class object into an array of that class type.protected static <U> Class<U>[]
emptyClassArray()
Generic utility function that returns an empty class array.Map<String,Operator<?>>
getBroadcastInputs()
Returns the input, or null, if none is set.abstract int[]
getKeyColumns(int inputNum)
Gets the column numbers of the key fields in the input records for the given input.abstract int
getNumberOfInputs()
Gets the number of inputs for this operator.UserCodeWrapper<FT>
getUserCodeWrapper()
Gets the function that is held by this operator.void
setBroadcastVariable(String name, Operator<?> root)
Binds the result produced by a plan rooted atroot
to a variable used by the UDF wrapped in this operator.<T> void
setBroadcastVariables(Map<String,Operator<T>> inputs)
Clears all previous broadcast inputs and binds the given inputs as broadcast variables of this operator.-
Methods inherited from class org.apache.flink.api.common.operators.Operator
createUnionCascade, createUnionCascade, createUnionCascade, getCompilerHints, getMinResources, getName, getOperatorInfo, getParallelism, getParameters, getPreferredResources, setName, setParallelism, setParameter, setResources, toString
-
-
-
-
Constructor Detail
-
AbstractUdfOperator
protected AbstractUdfOperator(UserCodeWrapper<FT> function, OperatorInformation<OUT> operatorInfo, String name)
Creates a new abstract operator with the given name wrapping the given user function.- Parameters:
function
- The wrapper object containing the user function.name
- The given name for the operator, used in plans, logs and progress messages.
-
-
Method Detail
-
getUserCodeWrapper
public UserCodeWrapper<FT> getUserCodeWrapper()
Gets the function that is held by this operator. The function is the actual implementation of the user code.This throws an exception if the pact does not contain an object but a class for the user code.
- Overrides:
getUserCodeWrapper
in classOperator<OUT>
- Returns:
- The object with the user function for this operator.
- See Also:
Operator.getUserCodeWrapper()
-
getBroadcastInputs
public Map<String,Operator<?>> getBroadcastInputs()
Returns the input, or null, if none is set.- Returns:
- The broadcast input root operator.
-
setBroadcastVariable
public void setBroadcastVariable(String name, Operator<?> root)
Binds the result produced by a plan rooted atroot
to a variable used by the UDF wrapped in this operator.- Parameters:
root
- The root of the plan producing this input.
-
setBroadcastVariables
public <T> void setBroadcastVariables(Map<String,Operator<T>> inputs)
Clears all previous broadcast inputs and binds the given inputs as broadcast variables of this operator.- Parameters:
inputs
- The<name, root>
pairs to be set as broadcast inputs.
-
getNumberOfInputs
public abstract int getNumberOfInputs()
Gets the number of inputs for this operator.- Returns:
- The number of inputs for this operator.
-
getKeyColumns
public abstract int[] getKeyColumns(int inputNum)
Gets the column numbers of the key fields in the input records for the given input.- Returns:
- The column numbers of the key fields.
-
asArray
protected static <U> Class<U>[] asArray(Class<U> clazz)
Generic utility function that wraps a single class object into an array of that class type.- Type Parameters:
U
- The type of the classes.- Parameters:
clazz
- The class object to be wrapped.- Returns:
- An array wrapping the class object.
-
emptyClassArray
protected static <U> Class<U>[] emptyClassArray()
Generic utility function that returns an empty class array.- Type Parameters:
U
- The type of the classes.- Returns:
- An empty array of type Class<U>.
-
-