/** * Checks whether a DualInputOperator is correctly connected. In case that * the contract is incorrectly connected a RuntimeException is thrown. * * @param dualInputContract * DualInputOperator that is checked. */ private void checkDualInputContract(DualInputOperator<?, ?, ?, ?> dualInputContract) { Operator<?> input1 = dualInputContract.getFirstInput(); Operator<?> input2 = dualInputContract.getSecondInput(); // check if input exists if (input1 == null || input2 == null) { throw new MissingChildException(); } }
@Override public DualInputPlanNode instantiate(Channel in1, Channel in2, TwoInputNode node) { return new DualInputPlanNode(node, "Join("+node.getPactContract().getName()+")", in1, in2, DriverStrategy.HYBRIDHASH_BUILD_FIRST, this.keys1, this.keys2); }
/** * Sets the inputs of the given {@link Operator}.<br> * Currently, the list can have 0, 1, or 2 elements and the number of elements must match the type of the contract. * * @param contract * the Operator whose inputs should be set * @param inputs * all input contracts to this contract */ @SuppressWarnings({ "deprecation", "rawtypes", "unchecked" }) public static void setInputs(final Operator<?> contract, final List<List<Operator>> inputs) { if (contract instanceof GenericDataSinkBase) { if (inputs.size() != 1) { throw new IllegalArgumentException("wrong number of inputs"); } ((GenericDataSinkBase) contract).setInputs(inputs.get(0)); } else if (contract instanceof SingleInputOperator) { if (inputs.size() != 1) { throw new IllegalArgumentException("wrong number of inputs"); } ((SingleInputOperator) contract).setInputs(inputs.get(0)); } else if (contract instanceof DualInputOperator) { if (inputs.size() != 2) { throw new IllegalArgumentException("wrong number of inputs"); } ((DualInputOperator) contract).setFirstInputs(inputs.get(0)); ((DualInputOperator) contract).setSecondInputs(inputs.get(1)); } } }
@Override public void setInput(Map<Operator<?>, OptimizerNode> contractToNode) { final Configuration conf = getPactContract().getParameters(); ShipStrategyType preSet1 = null; ShipStrategyType preSet2 = null; Operator<?> leftPred = contr.getFirstInput(); Operator<?> rightPred = contr.getSecondInput(); throw new CompilerException("Error: Node for '" + getPactContract().getName() + "' has no input set for first input."); } else { pred1 = contractToNode.get(leftPred); PactConnection conn2; if (rightPred == null) { throw new CompilerException("Error: Node for '" + getPactContract().getName() + "' has no input set for second input."); } else { pred2 = contractToNode.get(rightPred);
dataFlowOp.getParameters().addAll(opParams); dataFlowOp.setSemanticProperties(udfOp.getSematicProperties());
/** * Creates a new node with a single input for the optimizer plan. * * @param pactContract * The PACT that the node represents. */ public TwoInputNode(DualInputOperator<?, ?, ?, ?> pactContract) { super(pactContract); int[] k1 = pactContract.getKeyColumns(0); int[] k2 = pactContract.getKeyColumns(1); this.keys1 = k1 == null || k1.length == 0 ? null : new FieldList(k1); this.keys2 = k2 == null || k2.length == 0 ? null : new FieldList(k2); if (this.keys1 != null) { if (this.keys2 != null) { if (this.keys1.size() != this.keys2.size()) { throw new CompilerException("Unequal number of key fields on the two inputs."); } } else { throw new CompilerException("Keys are set on first input, but not on second."); } } else if (this.keys2 != null) { throw new CompilerException("Keys are set on second input, but not on first."); } this.possibleProperties = getPossibleProperties(); }
@Override public boolean isFieldConstant(int input, int fieldNumber) { DualInputOperator<?, ?, ?, ?> c = getPactContract(); DualInputSemanticProperties semanticProperties = c.getSemanticProperties(); switch(input) { case 0: if (semanticProperties != null) { FieldSet fs; if ((fs = semanticProperties.getForwardedField1(fieldNumber)) != null) { return fs.contains(fieldNumber); } } break; case 1: if(semanticProperties != null) { FieldSet fs; if ((fs = semanticProperties.getForwardedField2(fieldNumber)) != null) { return fs.contains(fieldNumber); } } break; default: throw new IndexOutOfBoundsException(); } return false; }
dn.setComparator1(createComparator(dualInputOperator.getOperatorInfo().getFirstInputType(), dn.getKeysForInput1(), getSortOrders(dn.getKeysForInput1(), dn.getSortOrders()))); dn.setComparator2(createComparator(dualInputOperator.getOperatorInfo().getSecondInputType(), dn.getKeysForInput2(), getSortOrders(dn.getKeysForInput2(), dn.getSortOrders()))); dn.setPairComparator(createPairComparator(dualInputOperator.getOperatorInfo().getFirstInputType(), dualInputOperator.getOperatorInfo().getSecondInputType()));
@Override public void setInput(Map<Operator<?>, OptimizerNode> contractToNode) { final Configuration conf = getPactContract().getParameters(); ShipStrategyType preSet1 = null; ShipStrategyType preSet2 = null; Operator<?> leftPred = contr.getFirstInput(); Operator<?> rightPred = contr.getSecondInput(); throw new CompilerException("Error: Node for '" + getPactContract().getName() + "' has no input set for first input."); } else { pred1 = contractToNode.get(leftPred); PactConnection conn2; if (rightPred == null) { throw new CompilerException("Error: Node for '" + getPactContract().getName() + "' has no input set for second input."); } else { pred2 = contractToNode.get(rightPred);
/** * Creates a new node with a single input for the optimizer plan. * * @param pactContract * The PACT that the node represents. */ public TwoInputNode(DualInputOperator<?, ?, ?, ?> pactContract) { super(pactContract); int[] k1 = pactContract.getKeyColumns(0); int[] k2 = pactContract.getKeyColumns(1); this.keys1 = k1 == null || k1.length == 0 ? null : new FieldList(k1); this.keys2 = k2 == null || k2.length == 0 ? null : new FieldList(k2); if (this.keys1 != null) { if (this.keys2 != null) { if (this.keys1.size() != this.keys2.size()) { throw new CompilerException("Unequal number of key fields on the two inputs."); } } else { throw new CompilerException("Keys are set on first input, but not on second."); } } else if (this.keys2 != null) { throw new CompilerException("Keys are set on second input, but not on first."); } this.possibleProperties = getPossibleProperties(); }
@Override public boolean isFieldConstant(int input, int fieldNumber) { DualInputOperator<?, ?, ?, ?> c = getPactContract(); DualInputSemanticProperties semanticProperties = c.getSemanticProperties(); switch(input) { case 0: if (semanticProperties != null) { FieldSet fs; if ((fs = semanticProperties.getForwardedField1(fieldNumber)) != null) { return fs.contains(fieldNumber); } } break; case 1: if(semanticProperties != null) { FieldSet fs; if ((fs = semanticProperties.getForwardedField2(fieldNumber)) != null) { return fs.contains(fieldNumber); } } break; default: throw new IndexOutOfBoundsException(); } return false; }
dn.setComparator1(createComparator(dualInputOperator.getOperatorInfo().getFirstInputType(), dn.getKeysForInput1(), getSortOrders(dn.getKeysForInput1(), dn.getSortOrders()))); dn.setComparator2(createComparator(dualInputOperator.getOperatorInfo().getSecondInputType(), dn.getKeysForInput2(), getSortOrders(dn.getKeysForInput2(), dn.getSortOrders()))); dn.setPairComparator(createPairComparator(dualInputOperator.getOperatorInfo().getFirstInputType(), dualInputOperator.getOperatorInfo().getSecondInputType()));
@Override public DualInputPlanNode instantiate(Channel in1, Channel in2, TwoInputNode node) { return new DualInputPlanNode(node, "Join("+node.getPactContract().getName()+")", in1, in2, DriverStrategy.HYBRIDHASH_BUILD_SECOND, this.keys1, this.keys2); }
/** * Checks whether a DualInputOperator is correctly connected. In case that * the contract is incorrectly connected a RuntimeException is thrown. * * @param dualInputContract * DualInputOperator that is checked. */ private void checkDualInputContract(DualInputOperator<?, ?, ?, ?> dualInputContract) { Operator<?> input1 = dualInputContract.getFirstInput(); Operator<?> input2 = dualInputContract.getSecondInput(); // check if input exists if (input1 == null || input2 == null) { throw new MissingChildException(); } }
/** * Sets the inputs of the given {@link Operator}.<br> * Currently, the list can have 0, 1, or 2 elements and the number of elements must match the type of the contract. * * @param contract * the Operator whose inputs should be set * @param inputs * all input contracts to this contract */ @SuppressWarnings({ "deprecation", "rawtypes", "unchecked" }) public static void setInputs(final Operator<?> contract, final List<List<Operator>> inputs) { if (contract instanceof GenericDataSinkBase) { if (inputs.size() != 1) { throw new IllegalArgumentException("wrong number of inputs"); } ((GenericDataSinkBase) contract).setInputs(inputs.get(0)); } else if (contract instanceof SingleInputOperator) { if (inputs.size() != 1) { throw new IllegalArgumentException("wrong number of inputs"); } ((SingleInputOperator) contract).setInputs(inputs.get(0)); } else if (contract instanceof DualInputOperator) { if (inputs.size() != 2) { throw new IllegalArgumentException("wrong number of inputs"); } ((DualInputOperator) contract).setFirstInputs(inputs.get(0)); ((DualInputOperator) contract).setSecondInputs(inputs.get(1)); } } }
int[] localPositions1 = contract.getKeyColumns(0); int[] localPositions2 = contract.getKeyColumns(1); Class<? extends Key<?>>[] types = recContract.getKeyClasses();
@Override public DualInputPlanNode instantiate(Channel in1, Channel in2, TwoInputNode node) { return new DualInputPlanNode(node, "Join("+node.getPactContract().getName()+")", in1, in2, DriverStrategy.HYBRIDHASH_BUILD_SECOND, this.keys1, this.keys2); }
int[] localPositions1 = contract.getKeyColumns(0); int[] localPositions2 = contract.getKeyColumns(1); Class<? extends Key<?>>[] types = recContract.getKeyClasses();
@Override public DualInputPlanNode instantiate(Channel in1, Channel in2, TwoInputNode node) { return new DualInputPlanNode(node, "Join("+node.getPactContract().getName()+")", in1, in2, DriverStrategy.HYBRIDHASH_BUILD_FIRST, this.keys1, this.keys2); }
@Override public DualInputPlanNode instantiate(Channel in1, Channel in2, TwoInputNode node) { return new DualInputPlanNode(node, "Cross("+node.getPactContract().getName()+")", in1, in2, getStrategy()); }