Program: 87559
Project: 87559
Buggy source:
/** 
 * Private utility method that generates a candidate Match node, given fixed shipping strategies and a fixed local strategy.
 * @param target The list to put the alternatives in.
 * @param subPlan1 The predecessor node for the first input.
 * @param subPlan2 The predecessor node for the second input.
 * @param ss1 The shipping strategy for the first input.
 * @param ss2 The shipping strategy for the second input.
 * @param ls The local strategy.
 * @param outGp The global properties of the data that goes to the user function.
 * @param outLp The local properties of the data that goes to the user function.
 * @param estimator The cost estimator.
 */
private void createMatchAlternative(List<OptimizerNode> target,OptimizerNode subPlan1,OptimizerNode subPlan2,ShipStrategy ss1,ShipStrategy ss2,LocalStrategy ls,Order order,boolean grouped,LocalProperties outLpp,CostEstimator estimator){
  if (ls != LocalStrategy.SELF_NESTEDLOOP && ls != LocalStrategy.SORT_SELF_NESTEDLOOP) {
    GlobalProperties gp1=PactConnection.getGlobalPropertiesAfterConnection(subPlan1,this,ss1);
    GlobalProperties gp2=PactConnection.getGlobalPropertiesAfterConnection(subPlan2,this,ss2);
    int[] scrambledKeyOrder1=null;
    int[] scrambledKeyOrder2=null;
    if (ss1 == ShipStrategy.FORWARD && ss2 == ShipStrategy.PARTITION_HASH) {
      scrambledKeyOrder1=getScrambledKeyOrder(this.keySet1,gp1.getPartitionedFields());
      if (scrambledKeyOrder1 != null) {
        FieldList scrambledKeys2=new FieldList();
        for (int i=0; i < scrambledKeyOrder1.length; i++) {
          scrambledKeys2.add(this.keySet2.get(scrambledKeyOrder1[i]));
        }
        gp2.setPartitioning(gp2.getPartitioning(),scrambledKeys2);
      }
    }
    if (ss2 == ShipStrategy.FORWARD && ss1 == ShipStrategy.PARTITION_HASH) {
      scrambledKeyOrder2=getScrambledKeyOrder(this.keySet2,gp2.getPartitionedFields());
      if (scrambledKeyOrder2 != null) {
        FieldList scrambledKeys1=new FieldList();
        for (int i=0; i < scrambledKeyOrder2.length; i++) {
          scrambledKeys1.add(this.keySet1.get(scrambledKeyOrder2[i]));
        }
        gp1.setPartitioning(gp1.getPartitioning(),scrambledKeys1);
      }
    }
    LocalProperties outLp=outLpp;
    GlobalProperties outGp=new GlobalProperties();
    outGp.setPartitioning(gp1.getPartitioning(),gp1.getPartitionedFields());
    outGp.setOrdering(gp1.getOrdering());
    if (outLpp == null) {
      outLp=new LocalProperties();
      if (order != Order.NONE) {
        Ordering ordering=new Ordering();
        for (        int keyColumn : this.keySet1) {
          ordering.appendOrdering(keyColumn,null,order);
        }
        outLp.setOrdering(ordering);
      }
 else {
        outLp.setOrdering(null);
      }
      outLp.setGrouped(grouped,new FieldSet(this.keySet1));
    }
    MatchNode n=new MatchNode(this,subPlan1,subPlan2,this.input1,this.input2,outGp,outLp);
    n.input1.setShipStrategy(ss1);
    n.input1.setScramblePartitionedFields(scrambledKeyOrder2);
    n.input2.setShipStrategy(ss2);
    n.input2.setScramblePartitionedFields(scrambledKeyOrder1);
    n.setLocalStrategy(ls);
    n.getGlobalProperties().filterByNodesConstantSet(this,0);
    n.getLocalProperties().filterByNodesConstantSet(this,0);
    estimator.costOperator(n);
    target.add(n);
    outGp=new GlobalProperties();
    outGp.setPartitioning(gp2.getPartitioning(),gp2.getPartitionedFields());
    outGp.setOrdering(gp2.getOrdering());
    if (outLpp == null) {
      outLp=new LocalProperties();
      if (order != Order.NONE) {
        Ordering ordering=new Ordering();
        for (        int keyColumn : this.keySet2) {
          ordering.appendOrdering(keyColumn,null,order);
        }
        outLp.setOrdering(ordering);
      }
 else {
        outLp.setOrdering(null);
      }
      outLp.setGrouped(grouped,new FieldSet(this.keySet2));
    }
    n=new MatchNode(this,subPlan1,subPlan2,input1,input2,outGp,outLp);
    n.input1.setShipStrategy(ss1);
    n.input1.setScramblePartitionedFields(scrambledKeyOrder2);
    n.input2.setShipStrategy(ss2);
    n.input2.setScramblePartitionedFields(scrambledKeyOrder1);
    n.setLocalStrategy(ls);
    n.getGlobalProperties().filterByNodesConstantSet(this,1);
    n.getLocalProperties().filterByNodesConstantSet(this,1);
    estimator.costOperator(n);
    target.add(n);
  }
 else {
    GlobalProperties gp1=PactConnection.getGlobalPropertiesAfterConnection(subPlan1,this,ss1);
    GlobalProperties outGp=new GlobalProperties();
    outGp.setPartitioning(gp1.getPartitioning(),gp1.getPartitionedFields());
    outGp.setOrdering(gp1.getOrdering());
    LocalProperties outLp=null;
    if (outLpp == null) {
      outLp=new LocalProperties();
      if (order != Order.NONE) {
        Ordering ordering=new Ordering();
        for (        int keyColumn : this.keySet1) {
          ordering.appendOrdering(keyColumn,null,order);
        }
        outLp.setOrdering(ordering);
      }
 else {
        outLp.setOrdering(null);
      }
      outLp.setGrouped(grouped,new FieldSet(this.keySet1));
    }
    MatchNode n=new MatchNode(this,subPlan1,null,this.input1,null,outGp,outLp);
    n.input1.setShipStrategy(ss1);
    n.setLocalStrategy(ls);
    n.getGlobalProperties().filterByNodesConstantSet(this,0);
    n.getLocalProperties().filterByNodesConstantSet(this,0);
    estimator.costOperator(n);
    target.add(n);
  }
}

Fixed version (ground truth):
/** 
 * Private utility method that generates a candidate Match node, given fixed shipping strategies and a fixed local strategy.
 * @param target The list to put the alternatives in.
 * @param subPlan1 The predecessor node for the first input.
 * @param subPlan2 The predecessor node for the second input.
 * @param ss1 The shipping strategy for the first input.
 * @param ss2 The shipping strategy for the second input.
 * @param ls The local strategy.
 * @param outGp The global properties of the data that goes to the user function.
 * @param outLp The local properties of the data that goes to the user function.
 * @param estimator The cost estimator.
 */
private void createMatchAlternative(List<OptimizerNode> target,OptimizerNode subPlan1,OptimizerNode subPlan2,ShipStrategy ss1,ShipStrategy ss2,LocalStrategy ls,Order order,boolean grouped,LocalProperties outLpp,CostEstimator estimator){
  if (ls != LocalStrategy.SELF_NESTEDLOOP && ls != LocalStrategy.SORT_SELF_NESTEDLOOP) {
    GlobalProperties gp1=PactConnection.getGlobalPropertiesAfterConnection(subPlan1,this,0,ss1);
    GlobalProperties gp2=PactConnection.getGlobalPropertiesAfterConnection(subPlan2,this,1,ss2);
    int[] scrambledKeyOrder1=null;
    int[] scrambledKeyOrder2=null;
    if (ss1 == ShipStrategy.FORWARD && ss2 == ShipStrategy.PARTITION_HASH) {
      scrambledKeyOrder1=getScrambledKeyOrder(this.keySet1,gp1.getPartitionedFields());
      if (scrambledKeyOrder1 != null) {
        FieldList scrambledKeys2=new FieldList();
        for (int i=0; i < scrambledKeyOrder1.length; i++) {
          scrambledKeys2.add(this.keySet2.get(scrambledKeyOrder1[i]));
        }
        gp2.setPartitioning(gp2.getPartitioning(),scrambledKeys2);
      }
    }
    if (ss2 == ShipStrategy.FORWARD && ss1 == ShipStrategy.PARTITION_HASH) {
      scrambledKeyOrder2=getScrambledKeyOrder(this.keySet2,gp2.getPartitionedFields());
      if (scrambledKeyOrder2 != null) {
        FieldList scrambledKeys1=new FieldList();
        for (int i=0; i < scrambledKeyOrder2.length; i++) {
          scrambledKeys1.add(this.keySet1.get(scrambledKeyOrder2[i]));
        }
        gp1.setPartitioning(gp1.getPartitioning(),scrambledKeys1);
      }
    }
    LocalProperties outLp=outLpp;
    GlobalProperties outGp=new GlobalProperties();
    outGp.setPartitioning(gp1.getPartitioning(),gp1.getPartitionedFields());
    outGp.setOrdering(gp1.getOrdering());
    if (outLpp == null) {
      outLp=new LocalProperties();
      if (order != Order.NONE) {
        Ordering ordering=new Ordering();
        for (        int keyColumn : this.keySet1) {
          ordering.appendOrdering(keyColumn,null,order);
        }
        outLp.setOrdering(ordering);
      }
 else {
        outLp.setOrdering(null);
      }
      outLp.setGrouped(grouped,new FieldSet(this.keySet1));
    }
    MatchNode n=new MatchNode(this,subPlan1,subPlan2,this.input1,this.input2,outGp,outLp);
    n.input1.setShipStrategy(ss1);
    n.input1.setScramblePartitionedFields(scrambledKeyOrder2);
    n.input2.setShipStrategy(ss2);
    n.input2.setScramblePartitionedFields(scrambledKeyOrder1);
    n.setLocalStrategy(ls);
    n.getGlobalProperties().filterByNodesConstantSet(this,0);
    n.getLocalProperties().filterByNodesConstantSet(this,0);
    estimator.costOperator(n);
    target.add(n);
    outGp=new GlobalProperties();
    outGp.setPartitioning(gp2.getPartitioning(),gp2.getPartitionedFields());
    outGp.setOrdering(gp2.getOrdering());
    if (outLpp == null) {
      outLp=new LocalProperties();
      if (order != Order.NONE) {
        Ordering ordering=new Ordering();
        for (        int keyColumn : this.keySet2) {
          ordering.appendOrdering(keyColumn,null,order);
        }
        outLp.setOrdering(ordering);
      }
 else {
        outLp.setOrdering(null);
      }
      outLp.setGrouped(grouped,new FieldSet(this.keySet2));
    }
    n=new MatchNode(this,subPlan1,subPlan2,input1,input2,outGp,outLp);
    n.input1.setShipStrategy(ss1);
    n.input1.setScramblePartitionedFields(scrambledKeyOrder2);
    n.input2.setShipStrategy(ss2);
    n.input2.setScramblePartitionedFields(scrambledKeyOrder1);
    n.setLocalStrategy(ls);
    n.getGlobalProperties().filterByNodesConstantSet(this,1);
    n.getLocalProperties().filterByNodesConstantSet(this,1);
    estimator.costOperator(n);
    target.add(n);
  }
 else {
    GlobalProperties gp1=PactConnection.getGlobalPropertiesAfterConnection(subPlan1,this,0,ss1);
    GlobalProperties outGp=new GlobalProperties();
    outGp.setPartitioning(gp1.getPartitioning(),gp1.getPartitionedFields());
    outGp.setOrdering(gp1.getOrdering());
    LocalProperties outLp=null;
    if (outLpp == null) {
      outLp=new LocalProperties();
      if (order != Order.NONE) {
        Ordering ordering=new Ordering();
        for (        int keyColumn : this.keySet1) {
          ordering.appendOrdering(keyColumn,null,order);
        }
        outLp.setOrdering(ordering);
      }
 else {
        outLp.setOrdering(null);
      }
      outLp.setGrouped(grouped,new FieldSet(this.keySet1));
    }
    MatchNode n=new MatchNode(this,subPlan1,null,this.input1,null,outGp,outLp);
    n.input1.setShipStrategy(ss1);
    n.setLocalStrategy(ls);
    n.getGlobalProperties().filterByNodesConstantSet(this,0);
    n.getLocalProperties().filterByNodesConstantSet(this,0);
    estimator.costOperator(n);
    target.add(n);
  }
}