Class Operator<OUT>
- java.lang.Object
-
- org.apache.flink.api.common.operators.Operator<OUT>
-
- Type Parameters:
OUT
- Output type of the records output by this operator
- Direct Known Subclasses:
AbstractUdfOperator
,BulkIterationBase.PartialSolutionPlaceHolder
,DeltaIterationBase.SolutionSetPlaceHolder
,DeltaIterationBase.WorksetPlaceHolder
,GenericDataSinkBase
,GenericDataSourceBase
@Internal public abstract class Operator<OUT> extends Object implements Visitable<Operator<?>>
Abstract base class for all operators. An operator is a source, sink, or it applies an operation to one or more inputs, producing a result.
-
-
Field Summary
Fields Modifier and Type Field Description protected CompilerHints
compilerHints
protected String
name
protected OperatorInformation<OUT>
operatorInfo
The return type of the user function.protected Configuration
parameters
-
Constructor Summary
Constructors Modifier Constructor Description protected
Operator(OperatorInformation<OUT> operatorInfo, String name)
Creates a new contract with the given name.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> Operator<T>
createUnionCascade(List<? extends Operator<T>> operators)
Takes a list of operators and creates a cascade of unions of this inputs, if needed.static <T> Operator<T>
createUnionCascade(Operator<T>... operators)
Takes a list of operators and creates a cascade of unions of this inputs, if needed.static <T> Operator<T>
createUnionCascade(Operator<T> input1, Operator<T>... input2)
Takes a single Operator and a list of operators and creates a cascade of unions of this inputs, if needed.CompilerHints
getCompilerHints()
Gets the compiler hints for this contract instance.ResourceSpec
getMinResources()
Gets the minimum resources for this operator.String
getName()
Gets the name of the contract instance.OperatorInformation<OUT>
getOperatorInfo()
Gets the information about the operators input/output types.int
getParallelism()
Gets the parallelism for this contract instance.Configuration
getParameters()
Gets the stub parameters of this contract.ResourceSpec
getPreferredResources()
Gets the preferred resources for this contract instance.UserCodeWrapper<?>
getUserCodeWrapper()
Gets the user code wrapper.void
setName(String name)
Sets the name of the contract instance.void
setParallelism(int parallelism)
Sets the parallelism for this contract instance.void
setParameter(String key, String value)
Sets a stub parameters in the configuration of this contract.void
setResources(ResourceSpec minResources, ResourceSpec preferredResources)
Sets the minimum and preferred resources for this contract instance.String
toString()
-
-
-
Field Detail
-
parameters
protected final Configuration parameters
-
compilerHints
protected CompilerHints compilerHints
-
name
protected String name
-
operatorInfo
protected final OperatorInformation<OUT> operatorInfo
The return type of the user function.
-
-
Constructor Detail
-
Operator
protected Operator(OperatorInformation<OUT> operatorInfo, String name)
Creates a new contract with the given name. The parameters are empty by default and the compiler hints are not set.- Parameters:
name
- The name that is used to describe the contract.
-
-
Method Detail
-
getOperatorInfo
public OperatorInformation<OUT> getOperatorInfo()
Gets the information about the operators input/output types.
-
getName
public String getName()
Gets the name of the contract instance. The name is only used to describe the contract instance in logging output and graphical representations.- Returns:
- The contract instance's name.
-
setName
public void setName(String name)
Sets the name of the contract instance. The name is only used to describe the contract instance in logging output and graphical representations.- Parameters:
name
- The operator's name.
-
getCompilerHints
public CompilerHints getCompilerHints()
Gets the compiler hints for this contract instance. In the compiler hints, different fields may be set (for example the selectivity) that will be evaluated by the pact compiler when generating plan alternatives.- Returns:
- The compiler hints object.
-
getParameters
public Configuration getParameters()
Gets the stub parameters of this contract. The stub parameters are a map that maps string keys to string or integer values. The map is accessible by the user code at runtime. Parameters that the user code needs to access at runtime to configure its behavior are typically stored in that configuration object.- Returns:
- The configuration containing the stub parameters.
-
setParameter
public void setParameter(String key, String value)
Sets a stub parameters in the configuration of this contract. The stub parameters are accessible by the user code at runtime. Parameters that the user code needs to access at runtime to configure its behavior are typically stored as stub parameters.- Parameters:
key
- The parameter key.value
- The parameter value.- See Also:
getParameters()
-
getParallelism
public int getParallelism()
Gets the parallelism for this contract instance. The parallelism denotes how many parallel instances of the user function will be spawned during the execution. If this value isExecutionConfig.PARALLELISM_DEFAULT
, then the system will decide the number of parallel instances by itself.- Returns:
- The parallelism.
-
setParallelism
public void setParallelism(int parallelism)
Sets the parallelism for this contract instance. The parallelism denotes how many parallel instances of the user function will be spawned during the execution.- Parameters:
parallelism
- The number of parallel instances to spawn. Set this value toExecutionConfig.PARALLELISM_DEFAULT
to let the system decide on its own.
-
getMinResources
@PublicEvolving public ResourceSpec getMinResources()
Gets the minimum resources for this operator. The minimum resources denotes how many resources will be needed at least minimum for the operator or user function during the execution.- Returns:
- The minimum resources of this operator.
-
getPreferredResources
@PublicEvolving public ResourceSpec getPreferredResources()
Gets the preferred resources for this contract instance. The preferred resources denote how many resources will be needed in the maximum for the user function during the execution.- Returns:
- The preferred resource of this operator.
-
setResources
@PublicEvolving public void setResources(ResourceSpec minResources, ResourceSpec preferredResources)
Sets the minimum and preferred resources for this contract instance. The resource denotes how many memories and cpu cores of the user function will be consumed during the execution.- Parameters:
minResources
- The minimum resource of this operator.preferredResources
- The preferred resource of this operator.
-
getUserCodeWrapper
public UserCodeWrapper<?> getUserCodeWrapper()
Gets the user code wrapper. In the case of a pact, that object will be the stub with the user function, in the case of an input or output format, it will be the format object.- Returns:
- The class with the user code.
-
createUnionCascade
public static <T> Operator<T> createUnionCascade(List<? extends Operator<T>> operators)
Takes a list of operators and creates a cascade of unions of this inputs, if needed. If not needed (there was only one operator in the list), then that operator is returned.- Parameters:
operators
- The operators.- Returns:
- The single operator or a cascade of unions of the operators.
-
createUnionCascade
public static <T> Operator<T> createUnionCascade(Operator<T>... operators)
Takes a list of operators and creates a cascade of unions of this inputs, if needed. If not needed (there was only one operator in the list), then that operator is returned.- Parameters:
operators
- The operators.- Returns:
- The single operator or a cascade of unions of the operators.
-
createUnionCascade
public static <T> Operator<T> createUnionCascade(Operator<T> input1, Operator<T>... input2)
Takes a single Operator and a list of operators and creates a cascade of unions of this inputs, if needed. If not needed there was only one operator as input, then this operator is returned.- Parameters:
input1
- The first input operator.input2
- The other input operators.- Returns:
- The single operator or a cascade of unions of the operators.
-
-