本文整理汇总了Java中org.apache.flink.api.common.operators.AbstractUdfOperator类的典型用法代码示例。如果您正苦于以下问题:Java AbstractUdfOperator类的具体用法?Java AbstractUdfOperator怎么用?Java AbstractUdfOperator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractUdfOperator类属于org.apache.flink.api.common.operators包,在下文中一共展示了AbstractUdfOperator类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: translateBcVariables
import org.apache.flink.api.common.operators.AbstractUdfOperator; //导入依赖的package包/类
private void translateBcVariables(DataSet<?> setOrOp, Operator<?> dataFlowOp) {
// check if this is actually an operator that could have broadcast variables
if (setOrOp instanceof UdfOperator) {
if (!(dataFlowOp instanceof AbstractUdfOperator<?, ?>)) {
throw new RuntimeException("Error while creating the data flow plan for the program: A UDF operation was not translated to a UDF operator.");
}
UdfOperator<?> udfOp = (UdfOperator<?>) setOrOp;
AbstractUdfOperator<?, ?> udfDataFlowOp = (AbstractUdfOperator<?, ?>) dataFlowOp;
for (Map.Entry<String, DataSet<?>> bcVariable : udfOp.getBroadcastSets().entrySet()) {
Operator<?> bcInput = translate(bcVariable.getValue());
udfDataFlowOp.setBroadcastVariable(bcVariable.getKey(), bcInput);
}
}
}
示例2: setBroadcastInputs
import org.apache.flink.api.common.operators.AbstractUdfOperator; //导入依赖的package包/类
/**
* This function connects the operators that produce the broadcast inputs to this operator.
*
* @param operatorToNode The map from program operators to optimizer nodes.
* @param defaultExchangeMode The data exchange mode to use, if the operator does not
* specify one.
*
* @throws CompilerException
*/
public void setBroadcastInputs(Map<Operator<?>, OptimizerNode> operatorToNode, ExecutionMode defaultExchangeMode) {
// skip for Operators that don't support broadcast variables
if (!(getOperator() instanceof AbstractUdfOperator<?, ?>)) {
return;
}
// get all broadcast inputs
AbstractUdfOperator<?, ?> operator = ((AbstractUdfOperator<?, ?>) getOperator());
// create connections and add them
for (Map.Entry<String, Operator<?>> input : operator.getBroadcastInputs().entrySet()) {
OptimizerNode predecessor = operatorToNode.get(input.getValue());
DagConnection connection = new DagConnection(predecessor, this,
ShipStrategyType.BROADCAST, defaultExchangeMode);
addBroadcastConnection(input.getKey(), connection);
predecessor.addOutgoingConnection(connection);
}
}
示例3: OptimizerNode
import org.apache.flink.api.common.operators.AbstractUdfOperator; //导入依赖的package包/类
/**
* Creates a new node for the optimizer plan.
*
* @param op The operator that the node represents.
*/
public OptimizerNode(Operator<?> op) {
this.pactContract = op;
readStubAnnotations();
if (this.pactContract instanceof AbstractUdfOperator) {
final AbstractUdfOperator<?, ?> pact = (AbstractUdfOperator<?, ?>) this.pactContract;
this.remappedKeys = new int[pact.getNumberOfInputs()][];
for (int i = 0; i < this.remappedKeys.length; i++) {
final int[] keys = pact.getKeyColumns(i);
int[] rk = new int[keys.length];
System.arraycopy(keys, 0, rk, 0, keys.length);
this.remappedKeys[i] = rk;
}
}
}
示例4: setBroadcastInputs
import org.apache.flink.api.common.operators.AbstractUdfOperator; //导入依赖的package包/类
/**
* This function is for plan translation purposes. Upon invocation, this method creates a {@link PactConnection}
* for each one of the broadcast inputs associated with the {@code Operator} referenced by this node.
* <p>
* The {@code PactConnections} must set its shipping strategy type to BROADCAST.
*
* @param operatorToNode
* The map associating operators with their corresponding optimizer nodes.
* @throws CompilerException
*/
public void setBroadcastInputs(Map<Operator<?>, OptimizerNode> operatorToNode) throws CompilerException {
// skip for Operators that don't support broadcast variables
if (!(getPactContract() instanceof AbstractUdfOperator<?, ?>)) {
return;
}
// get all broadcast inputs
AbstractUdfOperator<?, ?> operator = ((AbstractUdfOperator<?, ?>) getPactContract());
// create connections and add them
for (Map.Entry<String, Operator<?>> input : operator.getBroadcastInputs().entrySet()) {
OptimizerNode predecessor = operatorToNode.get(input.getValue());
PactConnection connection = new PactConnection(predecessor, this, ShipStrategyType.BROADCAST);
addBroadcastConnection(input.getKey(), connection);
predecessor.addOutgoingConnection(connection);
}
}
示例5: getConstantKeySet
import org.apache.flink.api.common.operators.AbstractUdfOperator; //导入依赖的package包/类
/**
* Returns the key columns for the specific input, if all keys are preserved
* by this node. Null, otherwise.
*/
protected int[] getConstantKeySet(int input) {
Operator<?> contract = getPactContract();
if (contract instanceof AbstractUdfOperator<?, ?>) {
AbstractUdfOperator<?, ?> abstractPact = (AbstractUdfOperator<?, ?>) contract;
int[] keyColumns = abstractPact.getKeyColumns(input);
if (keyColumns != null) {
if (keyColumns.length == 0) {
return null;
}
for (int keyColumn : keyColumns) {
if (!isFieldConstant(input, keyColumn)) {
return null;
}
}
return keyColumns;
}
}
return null;
}
示例6: translateBcVariables
import org.apache.flink.api.common.operators.AbstractUdfOperator; //导入依赖的package包/类
private void translateBcVariables(DataSet<?> setOrOp, Operator<?> dataFlowOp) {
// check if this is actually an operator that could have broadcast variables
if (setOrOp instanceof UdfOperator) {
if (!(dataFlowOp instanceof AbstractUdfOperator<?, ?>)) {
throw new RuntimeException("Error while creating the data flow plan for the program: A UDF operation was not translated to a UDF operator.");
}
UdfOperator<?> udfOp = (UdfOperator<?>) setOrOp;
AbstractUdfOperator<?, ?> udfDataFlowOp = (AbstractUdfOperator<?, ?>) dataFlowOp;
for (Map.Entry<String, DataSet<?>> bcVariable : udfOp.getBroadcastSets().entrySet()) {
Operator<?> bcInput = translate(bcVariable.getValue());
udfDataFlowOp.setBroadcastVariable(bcVariable.getKey(), bcInput);
}
}
}