Program: 55369
Project: 55369
Buggy source:
@Override protected void computeValidPlanAlternatives(List<? extends OptimizerNode> altSubPlans1,List<? extends OptimizerNode> altSubPlans2,CostEstimator estimator,List<OptimizerNode> outputPlans){
  for (  OptimizerNode subPlan1 : altSubPlans1) {
    for (    OptimizerNode subPlan2 : altSubPlans2) {
      if (!areBranchCompatible(subPlan1,subPlan2)) {
        continue;
      }
      ShipStrategy ss1=this.input1.getShipStrategy();
      ShipStrategy ss2=this.input2.getShipStrategy();
      GlobalProperties gp1;
      GlobalProperties gp2;
      if (ss1 == ShipStrategy.NONE) {
        gp1=subPlan1.getGlobalProperties();
        if (ss2 == ShipStrategy.NONE) {
          gp2=subPlan2.getGlobalProperties();
          if (partitioningIsOnRightFields(gp1,0) && gp1.getPartitioning().isComputablyPartitioned()) {
            ss1=ShipStrategy.FORWARD;
          }
          if (partitioningIsOnRightFields(gp2,1) && gp2.getPartitioning().isComputablyPartitioned()) {
            if (!partitioningIsOnRightFields(gp1,0) || !gp1.getPartitioning().isComputablyPartitioned()) {
              ss2=ShipStrategy.FORWARD;
            }
 else {
              if (gp1.getPartitioning().isCompatibleWith(gp2.getPartitioning()) && partitioningIsOnSameSubkey(gp1.getPartitionedFields(),gp2.getPartitionedFields())) {
                ss2=ShipStrategy.FORWARD;
              }
 else {
                if (gp1.getPartitioning() == PartitionProperty.HASH_PARTITIONED) {
                  createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.FORWARD,ShipStrategy.PARTITION_HASH,estimator);
                }
 else                 if (gp1.getPartitioning() == PartitionProperty.RANGE_PARTITIONED) {
                  createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.FORWARD,ShipStrategy.PARTITION_RANGE,estimator);
                }
                if (gp2.getPartitioning() == PartitionProperty.HASH_PARTITIONED) {
                  createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.PARTITION_HASH,ShipStrategy.FORWARD,estimator);
                }
 else                 if (gp2.getPartitioning() == PartitionProperty.RANGE_PARTITIONED) {
                  createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.PARTITION_RANGE,ShipStrategy.FORWARD,estimator);
                }
                continue;
              }
            }
          }
          if (ss1 == ShipStrategy.FORWARD) {
            if (ss2 == ShipStrategy.FORWARD) {
              createLocalAlternatives(outputPlans,subPlan1,subPlan2,ss1,ss2,estimator);
              if (gp1.getPartitioning() != PartitionProperty.RANGE_PARTITIONED) {
                createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.PARTITION_RANGE,ShipStrategy.PARTITION_RANGE,estimator);
              }
            }
 else {
              if (partitioningIsOnRightFields(gp1,0) && gp1.getPartitioning() == PartitionProperty.HASH_PARTITIONED) {
                createLocalAlternatives(outputPlans,subPlan1,subPlan2,ss1,ShipStrategy.PARTITION_HASH,estimator);
              }
 else               if (partitioningIsOnRightFields(gp1,0) && gp1.getPartitioning() == PartitionProperty.RANGE_PARTITIONED) {
                createLocalAlternatives(outputPlans,subPlan1,subPlan2,ss1,ShipStrategy.PARTITION_RANGE,estimator);
                createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.PARTITION_HASH,ShipStrategy.PARTITION_HASH,estimator);
              }
 else {
                throw new CompilerException("String_Node_Str" + getPactContract().getName() + "String_Node_Str");
              }
            }
          }
 else           if (ss2 == ShipStrategy.FORWARD) {
            if (partitioningIsOnRightFields(gp2,1) && gp2.getPartitioning() == PartitionProperty.HASH_PARTITIONED) {
              createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.PARTITION_HASH,ss2,estimator);
            }
 else             if (partitioningIsOnRightFields(gp2,1) && gp2.getPartitioning() == PartitionProperty.RANGE_PARTITIONED) {
              createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.PARTITION_RANGE,ss2,estimator);
              createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.PARTITION_HASH,ShipStrategy.PARTITION_HASH,estimator);
            }
 else {
              throw new CompilerException("String_Node_Str" + getPactContract().getName() + "String_Node_Str");
            }
          }
 else {
            createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.PARTITION_HASH,ShipStrategy.PARTITION_HASH,estimator);
            if (haveValidOutputEstimates(subPlan1) && haveValidOutputEstimates(subPlan2)) {
              createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.BROADCAST,ShipStrategy.FORWARD,estimator);
              createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.FORWARD,ShipStrategy.BROADCAST,estimator);
            }
          }
        }
 else {
          gp2=PactConnection.getGlobalPropertiesAfterConnection(subPlan2,this,ss2);
switch (ss2) {
case BROADCAST:
            ss1=ShipStrategy.FORWARD;
          break;
case FORWARD:
        if (partitioningIsOnRightFields(gp2,1) && gp2.getPartitioning().isPartitioned()) {
          if (gp2.getPartitioning() == PartitionProperty.HASH_PARTITIONED) {
            ss1=ShipStrategy.PARTITION_HASH;
          }
 else           if (gp2.getPartitioning() == PartitionProperty.RANGE_PARTITIONED) {
            ss1=ShipStrategy.PARTITION_RANGE;
          }
 else {
            throw new CompilerException();
          }
        }
 else {
          ss1=ShipStrategy.BROADCAST;
        }
      break;
case PARTITION_HASH:
    ss1=(partitioningIsOnSameSubkey(gp1.getPartitionedFields(),this.keySet2) && gp1.getPartitioning() == PartitionProperty.HASH_PARTITIONED) ? ShipStrategy.FORWARD : ShipStrategy.PARTITION_HASH;
  break;
case PARTITION_RANGE:
ss1=(partitioningIsOnRightFields(gp1,0) && gp1.getPartitioning() == PartitionProperty.RANGE_PARTITIONED) ? ShipStrategy.FORWARD : ShipStrategy.PARTITION_RANGE;
break;
default :
throw new CompilerException("String_Node_Str" + ss2.name() + "String_Node_Str"+ getPactContract().getName()+ "String_Node_Str");
}
createLocalAlternatives(outputPlans,subPlan1,subPlan2,ss1,ss2,estimator);
}
}
 else if (ss2 == ShipStrategy.NONE) {
gp1=PactConnection.getGlobalPropertiesAfterConnection(subPlan1,this,ss1);
gp2=subPlan2.getGlobalProperties();
switch (ss1) {
case BROADCAST:
ss2=ShipStrategy.FORWARD;
break;
case FORWARD:
if (partitioningIsOnRightFields(gp1,0) && gp1.getPartitioning().isPartitioned()) {
if (gp1.getPartitioning() == PartitionProperty.HASH_PARTITIONED) {
ss2=ShipStrategy.PARTITION_HASH;
}
 else if (gp1.getPartitioning() == PartitionProperty.RANGE_PARTITIONED) {
ss2=ShipStrategy.PARTITION_RANGE;
}
 else {
throw new CompilerException();
}
}
 else {
ss2=ShipStrategy.BROADCAST;
}
break;
case PARTITION_HASH:
ss2=(partitioningIsOnSameSubkey(this.keySet1,gp2.getPartitionedFields()) && partitioningIsOnRightFields(gp2,1) && gp2.getPartitioning() == PartitionProperty.HASH_PARTITIONED) ? ShipStrategy.FORWARD : ShipStrategy.PARTITION_HASH;
break;
case PARTITION_RANGE:
ss2=(partitioningIsOnRightFields(gp2,1) && gp2.getPartitioning() == PartitionProperty.RANGE_PARTITIONED) ? ShipStrategy.FORWARD : ShipStrategy.PARTITION_RANGE;
break;
default :
throw new CompilerException("String_Node_Str" + ss1.name() + "String_Node_Str"+ getPactContract().getName()+ "String_Node_Str");
}
createLocalAlternatives(outputPlans,subPlan1,subPlan2,ss1,ss2,estimator);
}
 else {
if ((ss1 == ShipStrategy.BROADCAST && ss2 != ShipStrategy.BROADCAST) || (ss1 != ShipStrategy.BROADCAST && ss2 == ShipStrategy.BROADCAST)) {
createLocalAlternatives(outputPlans,subPlan1,subPlan2,ss1,ss2,estimator);
}
 else {
gp1=PactConnection.getGlobalPropertiesAfterConnection(subPlan1,this,ss1);
gp2=PactConnection.getGlobalPropertiesAfterConnection(subPlan2,this,ss2);
if (gp1.getPartitioning().isComputablyPartitioned() && gp1.getPartitioning() == gp2.getPartitioning() && partitioningIsOnSameSubkey(gp1.getPartitionedFields(),gp2.getPartitionedFields())) {
createLocalAlternatives(outputPlans,subPlan1,subPlan2,ss1,ss2,estimator);
}
 else {
continue;
}
}
}
}
}
}

Fixed version (ground truth):
@Override protected void computeValidPlanAlternatives(List<? extends OptimizerNode> altSubPlans1,List<? extends OptimizerNode> altSubPlans2,CostEstimator estimator,List<OptimizerNode> outputPlans){
  for (  OptimizerNode subPlan1 : altSubPlans1) {
    for (    OptimizerNode subPlan2 : altSubPlans2) {
      if (!areBranchCompatible(subPlan1,subPlan2)) {
        continue;
      }
      ShipStrategy ss1=this.input1.getShipStrategy();
      ShipStrategy ss2=this.input2.getShipStrategy();
      GlobalProperties gp1;
      GlobalProperties gp2;
      if (ss1 == ShipStrategy.NONE) {
        gp1=subPlan1.getGlobalProperties();
        if (ss2 == ShipStrategy.NONE) {
          gp2=subPlan2.getGlobalProperties();
          if (partitioningIsOnRightFields(gp1,0) && gp1.getPartitioning().isComputablyPartitioned()) {
            ss1=ShipStrategy.FORWARD;
          }
          if (partitioningIsOnRightFields(gp2,1) && gp2.getPartitioning().isComputablyPartitioned()) {
            if (!partitioningIsOnRightFields(gp1,0) || !gp1.getPartitioning().isComputablyPartitioned()) {
              ss2=ShipStrategy.FORWARD;
            }
 else {
              if (gp1.getPartitioning().isCompatibleWith(gp2.getPartitioning()) && partitioningIsOnSameSubkey(gp1.getPartitionedFields(),gp2.getPartitionedFields())) {
                ss2=ShipStrategy.FORWARD;
              }
 else {
                if (gp1.getPartitioning() == PartitionProperty.HASH_PARTITIONED) {
                  createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.FORWARD,ShipStrategy.PARTITION_HASH,estimator);
                }
 else                 if (gp1.getPartitioning() == PartitionProperty.RANGE_PARTITIONED) {
                  createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.FORWARD,ShipStrategy.PARTITION_RANGE,estimator);
                }
                if (gp2.getPartitioning() == PartitionProperty.HASH_PARTITIONED) {
                  createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.PARTITION_HASH,ShipStrategy.FORWARD,estimator);
                }
 else                 if (gp2.getPartitioning() == PartitionProperty.RANGE_PARTITIONED) {
                  createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.PARTITION_RANGE,ShipStrategy.FORWARD,estimator);
                }
                continue;
              }
            }
          }
          if (ss1 == ShipStrategy.FORWARD) {
            if (ss2 == ShipStrategy.FORWARD) {
              createLocalAlternatives(outputPlans,subPlan1,subPlan2,ss1,ss2,estimator);
              if (gp1.getPartitioning() != PartitionProperty.RANGE_PARTITIONED) {
                createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.PARTITION_RANGE,ShipStrategy.PARTITION_RANGE,estimator);
              }
            }
 else {
              if (partitioningIsOnRightFields(gp1,0) && gp1.getPartitioning() == PartitionProperty.HASH_PARTITIONED) {
                createLocalAlternatives(outputPlans,subPlan1,subPlan2,ss1,ShipStrategy.PARTITION_HASH,estimator);
              }
 else               if (partitioningIsOnRightFields(gp1,0) && gp1.getPartitioning() == PartitionProperty.RANGE_PARTITIONED) {
                createLocalAlternatives(outputPlans,subPlan1,subPlan2,ss1,ShipStrategy.PARTITION_RANGE,estimator);
                createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.PARTITION_HASH,ShipStrategy.PARTITION_HASH,estimator);
              }
 else {
                throw new CompilerException("String_Node_Str" + getPactContract().getName() + "String_Node_Str");
              }
            }
          }
 else           if (ss2 == ShipStrategy.FORWARD) {
            if (partitioningIsOnRightFields(gp2,1) && gp2.getPartitioning() == PartitionProperty.HASH_PARTITIONED) {
              createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.PARTITION_HASH,ss2,estimator);
            }
 else             if (partitioningIsOnRightFields(gp2,1) && gp2.getPartitioning() == PartitionProperty.RANGE_PARTITIONED) {
              createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.PARTITION_RANGE,ss2,estimator);
              createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.PARTITION_HASH,ShipStrategy.PARTITION_HASH,estimator);
            }
 else {
              throw new CompilerException("String_Node_Str" + getPactContract().getName() + "String_Node_Str");
            }
          }
 else {
            createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.PARTITION_HASH,ShipStrategy.PARTITION_HASH,estimator);
            if (haveValidOutputEstimates(subPlan1) && haveValidOutputEstimates(subPlan2)) {
              createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.BROADCAST,ShipStrategy.FORWARD,estimator);
              createLocalAlternatives(outputPlans,subPlan1,subPlan2,ShipStrategy.FORWARD,ShipStrategy.BROADCAST,estimator);
            }
          }
        }
 else {
          gp2=PactConnection.getGlobalPropertiesAfterConnection(subPlan2,this,1,ss2);
switch (ss2) {
case BROADCAST:
            ss1=ShipStrategy.FORWARD;
          break;
case FORWARD:
        if (partitioningIsOnRightFields(gp2,1) && gp2.getPartitioning().isPartitioned()) {
          if (gp2.getPartitioning() == PartitionProperty.HASH_PARTITIONED) {
            ss1=ShipStrategy.PARTITION_HASH;
          }
 else           if (gp2.getPartitioning() == PartitionProperty.RANGE_PARTITIONED) {
            ss1=ShipStrategy.PARTITION_RANGE;
          }
 else {
            throw new CompilerException();
          }
        }
 else {
          ss1=ShipStrategy.BROADCAST;
        }
      break;
case PARTITION_HASH:
    ss1=(partitioningIsOnSameSubkey(gp1.getPartitionedFields(),this.keySet2) && gp1.getPartitioning() == PartitionProperty.HASH_PARTITIONED) ? ShipStrategy.FORWARD : ShipStrategy.PARTITION_HASH;
  break;
case PARTITION_RANGE:
ss1=(partitioningIsOnRightFields(gp1,0) && gp1.getPartitioning() == PartitionProperty.RANGE_PARTITIONED) ? ShipStrategy.FORWARD : ShipStrategy.PARTITION_RANGE;
break;
default :
throw new CompilerException("String_Node_Str" + ss2.name() + "String_Node_Str"+ getPactContract().getName()+ "String_Node_Str");
}
createLocalAlternatives(outputPlans,subPlan1,subPlan2,ss1,ss2,estimator);
}
}
 else if (ss2 == ShipStrategy.NONE) {
gp1=PactConnection.getGlobalPropertiesAfterConnection(subPlan1,this,0,ss1);
gp2=subPlan2.getGlobalProperties();
switch (ss1) {
case BROADCAST:
ss2=ShipStrategy.FORWARD;
break;
case FORWARD:
if (partitioningIsOnRightFields(gp1,0) && gp1.getPartitioning().isPartitioned()) {
if (gp1.getPartitioning() == PartitionProperty.HASH_PARTITIONED) {
ss2=ShipStrategy.PARTITION_HASH;
}
 else if (gp1.getPartitioning() == PartitionProperty.RANGE_PARTITIONED) {
ss2=ShipStrategy.PARTITION_RANGE;
}
 else {
throw new CompilerException();
}
}
 else {
ss2=ShipStrategy.BROADCAST;
}
break;
case PARTITION_HASH:
ss2=(partitioningIsOnSameSubkey(this.keySet1,gp2.getPartitionedFields()) && partitioningIsOnRightFields(gp2,1) && gp2.getPartitioning() == PartitionProperty.HASH_PARTITIONED) ? ShipStrategy.FORWARD : ShipStrategy.PARTITION_HASH;
break;
case PARTITION_RANGE:
ss2=(partitioningIsOnRightFields(gp2,1) && gp2.getPartitioning() == PartitionProperty.RANGE_PARTITIONED) ? ShipStrategy.FORWARD : ShipStrategy.PARTITION_RANGE;
break;
default :
throw new CompilerException("String_Node_Str" + ss1.name() + "String_Node_Str"+ getPactContract().getName()+ "String_Node_Str");
}
createLocalAlternatives(outputPlans,subPlan1,subPlan2,ss1,ss2,estimator);
}
 else {
if ((ss1 == ShipStrategy.BROADCAST && ss2 != ShipStrategy.BROADCAST) || (ss1 != ShipStrategy.BROADCAST && ss2 == ShipStrategy.BROADCAST)) {
createLocalAlternatives(outputPlans,subPlan1,subPlan2,ss1,ss2,estimator);
}
 else {
gp1=PactConnection.getGlobalPropertiesAfterConnection(subPlan1,this,0,ss1);
gp2=PactConnection.getGlobalPropertiesAfterConnection(subPlan2,this,1,ss2);
if (gp1.getPartitioning().isComputablyPartitioned() && gp1.getPartitioning() == gp2.getPartitioning() && partitioningIsOnSameSubkey(gp1.getPartitionedFields(),gp2.getPartitionedFields())) {
createLocalAlternatives(outputPlans,subPlan1,subPlan2,ss1,ss2,estimator);
}
 else {
continue;
}
}
}
}
}
}