Program: 55190
Project: 55190
Buggy source:
private void visit(DumpableNode<?> node,PrintWriter writer,boolean first){
  if (this.nodeIds.containsKey(node)) {
    return;
  }
  this.nodeIds.put(node,this.nodeCnt++);
  for (Iterator<? extends DumpableNode<?>> children=node.getPredecessors(); children.hasNext(); ) {
    final DumpableNode<?> child=children.next();
    visit(child,writer,false);
  }
  final OptimizerNode n=node.getOptimizerNode();
  writer.print("String_Node_Str" + this.nodeIds.get(node));
  final String type;
  final String contents;
  if (n instanceof DataSinkNode) {
    type="String_Node_Str";
    contents=n.getPactContract().toString();
  }
 else   if (n instanceof DataSourceNode) {
    type="String_Node_Str";
    contents=n.getPactContract().toString();
  }
 else   if (n instanceof BinaryUnionNode) {
    type="String_Node_Str";
    contents="String_Node_Str";
  }
 else {
    type="String_Node_Str";
    contents=n.getPactContract().getName();
  }
  writer.print("String_Node_Str" + type + "String_Node_Str");
  writer.print("String_Node_Str" + n.getName() + "String_Node_Str");
  writer.print("String_Node_Str" + contents + "String_Node_Str");
  writer.print("String_Node_Str" + (n.getDegreeOfParallelism() >= 1 ? n.getDegreeOfParallelism() : "String_Node_Str") + "String_Node_Str");
  Iterator<? extends DumpableConnection<?>> inConns=node.getDumpableInputs();
  String child1name="String_Node_Str", child2name="String_Node_Str";
  if (inConns != null && inConns.hasNext()) {
    writer.print("String_Node_Str");
    int connNum=0;
    int inputNum=0;
    while (inConns.hasNext()) {
      final DumpableConnection<?> conn=inConns.next();
      final Collection<DumpableConnection<?>> inConnsForInput;
      if (conn.getSource() instanceof UnionPlanNode) {
        inConnsForInput=new ArrayList<DumpableConnection<?>>();
        for (Iterator<? extends DumpableConnection<?>> inputOfUnion=conn.getSource().getDumpableInputs(); inputOfUnion.hasNext(); ) {
          inConnsForInput.add(inputOfUnion.next());
        }
      }
 else {
        inConnsForInput=Collections.<DumpableConnection<?>>singleton(conn);
      }
      for (      DumpableConnection<?> inConn : inConnsForInput) {
        final DumpableNode<?> source=inConn.getSource();
        writer.print(connNum == 0 ? "String_Node_Str" : "String_Node_Str");
        if (connNum == 0) {
          child1name+=child1name.length() > 0 ? "String_Node_Str" : "String_Node_Str";
          child1name+=source.getOptimizerNode().getPactContract().getName();
        }
 else         if (connNum == 1) {
          child2name+=child2name.length() > 0 ? "String_Node_Str" : "String_Node_Str";
          child2name=source.getOptimizerNode().getPactContract().getName();
        }
        writer.print("String_Node_Str" + this.nodeIds.get(source));
        if (inConns.hasNext()) {
          writer.print("String_Node_Str" + (inputNum == 0 ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str");
        }
        final Channel channel=(inConn instanceof Channel) ? (Channel)inConn : null;
        String shipStrategy=null;
switch (conn.getShipStrategy()) {
case NONE:
          break;
case FORWARD:
        shipStrategy="String_Node_Str";
      break;
case BROADCAST:
    shipStrategy="String_Node_Str";
  break;
case PARTITION_HASH:
shipStrategy="String_Node_Str";
break;
case PARTITION_RANGE:
shipStrategy="String_Node_Str";
break;
case PARTITION_LOCAL_HASH:
shipStrategy="String_Node_Str";
break;
default :
throw new CompilerException("String_Node_Str" + conn.getShipStrategy().name() + "String_Node_Str");
}
if (channel != null && channel.getShipStrategyKeys() != null && channel.getShipStrategyKeys().size() > 0) {
shipStrategy+="String_Node_Str" + (channel.getShipStrategySortOrder() == null ? channel.getShipStrategyKeys().toString() : Utils.createOrdering(channel.getShipStrategyKeys(),channel.getShipStrategySortOrder()).toString());
}
if (shipStrategy != null) {
writer.print("String_Node_Str" + shipStrategy + "String_Node_Str");
}
if (channel != null) {
String localStrategy=null;
switch (channel.getLocalStrategy()) {
case NONE:
break;
case SORT:
localStrategy="String_Node_Str";
break;
case COMBININGSORT:
localStrategy="String_Node_Str";
break;
default :
throw new CompilerException("String_Node_Str" + channel.getLocalStrategy().name());
}
if (channel.getLocalStrategyKeys() != null && channel.getLocalStrategyKeys().size() > 0) {
localStrategy+="String_Node_Str" + (channel.getLocalStrategySortOrder() == null ? channel.getLocalStrategyKeys().toString() : Utils.createOrdering(channel.getLocalStrategyKeys(),channel.getLocalStrategySortOrder()).toString());
}
if (localStrategy != null) {
writer.print("String_Node_Str" + localStrategy + "String_Node_Str");
}
if (channel.getTempMode() != TempMode.NONE) {
String tempMode=channel.getTempMode().toString();
writer.print("String_Node_Str" + tempMode + "String_Node_Str");
}
}
writer.print('}');
connNum++;
}
inputNum++;
}
writer.print("String_Node_Str");
}
final PlanNode p=node.getPlanNode();
if (p == null) {
return;
}
String locString=null;
if (p.getDriverStrategy() != null) {
switch (p.getDriverStrategy()) {
case NONE:
break;
case MAP:
locString="String_Node_Str";
break;
case PARTIAL_GROUP:
locString="String_Node_Str";
break;
case GROUP_OVER_ORDERED:
locString="String_Node_Str";
break;
case HYBRIDHASH_BUILD_FIRST:
locString="String_Node_Str" + child1name + "String_Node_Str";
break;
case HYBRIDHASH_BUILD_SECOND:
locString="String_Node_Str" + child2name + "String_Node_Str";
break;
case NESTEDLOOP_BLOCKED_OUTER_FIRST:
locString="String_Node_Str" + child1name + "String_Node_Str";
break;
case NESTEDLOOP_BLOCKED_OUTER_SECOND:
locString="String_Node_Str" + child2name + "String_Node_Str";
break;
case NESTEDLOOP_STREAMED_OUTER_FIRST:
locString="String_Node_Str" + child1name + "String_Node_Str";
break;
case NESTEDLOOP_STREAMED_OUTER_SECOND:
locString="String_Node_Str" + child2name + "String_Node_Str";
break;
case MERGE:
locString="String_Node_Str";
break;
case CO_GROUP:
locString="String_Node_Str";
break;
default :
throw new CompilerException("String_Node_Str" + p.getDriverStrategy().name() + "String_Node_Str");
}
if (locString != null) {
writer.print("String_Node_Str");
writer.print(locString);
writer.print("String_Node_Str");
}
}
{
final GlobalProperties gp=p.getGlobalProperties();
writer.print("String_Node_Str");
addProperty(writer,"String_Node_Str",gp.getPartitioning().name(),true);
if (gp.getPartitioningFields() != null) {
addProperty(writer,"String_Node_Str",gp.getPartitioningFields().toString(),false);
}
if (gp.getPartitioningOrdering() != null) {
addProperty(writer,"String_Node_Str",gp.getPartitioningOrdering().toString(),false);
}
 else {
addProperty(writer,"String_Node_Str","String_Node_Str",false);
}
if (n.getUniqueFields() == null || n.getUniqueFields().size() == 0) {
addProperty(writer,"String_Node_Str","String_Node_Str",false);
}
 else {
addProperty(writer,"String_Node_Str",n.getUniqueFields().toString(),false);
}
writer.print("String_Node_Str");
}
{
LocalProperties lp=p.getLocalProperties();
writer.print("String_Node_Str");
if (lp.getOrdering() != null) {
addProperty(writer,"String_Node_Str",lp.getOrdering().toString(),true);
}
 else {
addProperty(writer,"String_Node_Str","String_Node_Str",true);
}
if (lp.getGroupedFields() != null && lp.getGroupedFields().size() > 0) {
addProperty(writer,"String_Node_Str",lp.getGroupedFields().toString(),false);
}
 else {
addProperty(writer,"String_Node_Str","String_Node_Str",false);
}
if (n.getUniqueFields() == null || n.getUniqueFields().size() == 0) {
addProperty(writer,"String_Node_Str","String_Node_Str",false);
}
 else {
addProperty(writer,"String_Node_Str",n.getUniqueFields().toString(),false);
}
writer.print("String_Node_Str");
}
writer.print("String_Node_Str");
addProperty(writer,"String_Node_Str",n.getEstimatedNumRecords() == -1 ? "String_Node_Str" : formatNumber(n.getEstimatedNumRecords()),true);
String estCardinality="String_Node_Str";
if (n.getEstimatedCardinalities().size() > 0) {
estCardinality="String_Node_Str";
for (Entry<FieldSet,Long> entry : n.getEstimatedCardinalities().entrySet()) {
estCardinality+="String_Node_Str" + entry.getKey().toString() + "String_Node_Str"+ entry.getValue()+ "String_Node_Str";
}
}
addProperty(writer,"String_Node_Str",estCardinality,false);
addProperty(writer,"String_Node_Str",n.getEstimatedOutputSize() == -1 ? "String_Node_Str" : formatNumber(n.getEstimatedOutputSize(),"String_Node_Str"),false);
writer.print("String_Node_Str");
if (p.getNodeCosts() != null) {
writer.print("String_Node_Str");
addProperty(writer,"String_Node_Str",p.getNodeCosts().getNetworkCost() == -1 ? "String_Node_Str" : formatNumber(p.getNodeCosts().getNetworkCost(),"String_Node_Str"),true);
addProperty(writer,"String_Node_Str",p.getNodeCosts().getDiskCost() == -1 ? "String_Node_Str" : formatNumber(p.getNodeCosts().getDiskCost(),"String_Node_Str"),false);
addProperty(writer,"String_Node_Str",p.getCumulativeCosts().getNetworkCost() == -1 ? "String_Node_Str" : formatNumber(p.getCumulativeCosts().getNetworkCost(),"String_Node_Str"),false);
addProperty(writer,"String_Node_Str",p.getCumulativeCosts().getDiskCost() == -1 ? "String_Node_Str" : formatNumber(p.getCumulativeCosts().getDiskCost(),"String_Node_Str"),false);
writer.print("String_Node_Str");
}
if (n.getPactContract().getCompilerHints() != null) {
CompilerHints hints=n.getPactContract().getCompilerHints();
CompilerHints defaults=new CompilerHints();
writer.print("String_Node_Str");
String hintCardinality;
if (hints.getDistinctCounts().size() > 0) {
hintCardinality="String_Node_Str";
for (Entry<FieldSet,Long> entry : hints.getDistinctCounts().entrySet()) {
hintCardinality+="String_Node_Str" + entry.getKey().toString() + "String_Node_Str"+ entry.getValue()+ "String_Node_Str";
}
}
 else {
hintCardinality="String_Node_Str";
}
addProperty(writer,"String_Node_Str",hintCardinality,true);
addProperty(writer,"String_Node_Str",hints.getAvgRecordsEmittedPerStubCall() == defaults.getAvgRecordsEmittedPerStubCall() ? "String_Node_Str" : String.valueOf(hints.getAvgRecordsEmittedPerStubCall()),false);
String valuesKey;
if (hints.getAvgNumRecordsPerDistinctFields().size() > 0) {
valuesKey="String_Node_Str";
for (Entry<FieldSet,Float> entry : hints.getAvgNumRecordsPerDistinctFields().entrySet()) {
valuesKey+="String_Node_Str" + entry.getKey().toString() + "String_Node_Str"+ entry.getValue()+ "String_Node_Str";
}
}
 else {
valuesKey="String_Node_Str";
}
addProperty(writer,"String_Node_Str",valuesKey,false);
addProperty(writer,"String_Node_Str",hints.getAvgBytesPerRecord() == defaults.getAvgBytesPerRecord() ? "String_Node_Str" : String.valueOf(hints.getAvgBytesPerRecord()),false);
writer.print("String_Node_Str");
}
writer.print("String_Node_Str");
}

Fixed version (ground truth):
private void visit(DumpableNode<?> node,PrintWriter writer){
  if (this.nodeIds.containsKey(node)) {
    return;
  }
  this.nodeIds.put(node,this.nodeCnt++);
  for (Iterator<? extends DumpableNode<?>> children=node.getPredecessors(); children.hasNext(); ) {
    final DumpableNode<?> child=children.next();
    visit(child,writer);
  }
  final OptimizerNode n=node.getOptimizerNode();
  if (this.firstInList) {
    firstInList=false;
  }
 else {
    writer.print("String_Node_Str");
  }
  writer.print("String_Node_Str" + this.nodeIds.get(node));
  final String type;
  final String contents;
  if (n instanceof DataSinkNode) {
    type="String_Node_Str";
    contents=n.getPactContract().toString();
  }
 else   if (n instanceof DataSourceNode) {
    type="String_Node_Str";
    contents=n.getPactContract().toString();
  }
 else   if (n instanceof BinaryUnionNode) {
    type="String_Node_Str";
    contents="String_Node_Str";
  }
 else {
    type="String_Node_Str";
    contents=n.getPactContract().getName();
  }
  writer.print("String_Node_Str" + type + "String_Node_Str");
  writer.print("String_Node_Str" + n.getName() + "String_Node_Str");
  writer.print("String_Node_Str" + contents + "String_Node_Str");
  writer.print("String_Node_Str" + (n.getDegreeOfParallelism() >= 1 ? n.getDegreeOfParallelism() : "String_Node_Str") + "String_Node_Str");
  Iterator<? extends DumpableConnection<?>> inConns=node.getDumpableInputs();
  String child1name="String_Node_Str", child2name="String_Node_Str";
  if (inConns != null && inConns.hasNext()) {
    writer.print("String_Node_Str");
    int connNum=0;
    int inputNum=0;
    while (inConns.hasNext()) {
      final DumpableConnection<?> conn=inConns.next();
      final Collection<DumpableConnection<?>> inConnsForInput;
      if (conn.getSource() instanceof UnionPlanNode) {
        inConnsForInput=new ArrayList<DumpableConnection<?>>();
        for (Iterator<? extends DumpableConnection<?>> inputOfUnion=conn.getSource().getDumpableInputs(); inputOfUnion.hasNext(); ) {
          inConnsForInput.add(inputOfUnion.next());
        }
      }
 else {
        inConnsForInput=Collections.<DumpableConnection<?>>singleton(conn);
      }
      for (      DumpableConnection<?> inConn : inConnsForInput) {
        final DumpableNode<?> source=inConn.getSource();
        writer.print(connNum == 0 ? "String_Node_Str" : "String_Node_Str");
        if (connNum == 0) {
          child1name+=child1name.length() > 0 ? "String_Node_Str" : "String_Node_Str";
          child1name+=source.getOptimizerNode().getPactContract().getName();
        }
 else         if (connNum == 1) {
          child2name+=child2name.length() > 0 ? "String_Node_Str" : "String_Node_Str";
          child2name=source.getOptimizerNode().getPactContract().getName();
        }
        writer.print("String_Node_Str" + this.nodeIds.get(source));
        if (inConns.hasNext() || inputNum > 0) {
          writer.print("String_Node_Str" + (inputNum == 0 ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str");
        }
        final Channel channel=(inConn instanceof Channel) ? (Channel)inConn : null;
        final ShipStrategyType shipType=channel != null ? channel.getShipStrategy() : ((PactConnection)inConn).getShipStrategy();
        String shipStrategy=null;
        if (shipType != null) {
switch (shipType) {
case NONE:
            break;
case FORWARD:
          shipStrategy="String_Node_Str";
        break;
case BROADCAST:
      shipStrategy="String_Node_Str";
    break;
case PARTITION_HASH:
  shipStrategy="String_Node_Str";
break;
case PARTITION_RANGE:
shipStrategy="String_Node_Str";
break;
case PARTITION_LOCAL_HASH:
shipStrategy="String_Node_Str";
break;
default :
throw new CompilerException("String_Node_Str" + conn.getShipStrategy().name() + "String_Node_Str");
}
}
if (channel != null && channel.getShipStrategyKeys() != null && channel.getShipStrategyKeys().size() > 0) {
shipStrategy+="String_Node_Str" + (channel.getShipStrategySortOrder() == null ? channel.getShipStrategyKeys().toString() : Utils.createOrdering(channel.getShipStrategyKeys(),channel.getShipStrategySortOrder()).toString());
}
if (shipStrategy != null) {
writer.print("String_Node_Str" + shipStrategy + "String_Node_Str");
}
if (channel != null) {
String localStrategy=null;
switch (channel.getLocalStrategy()) {
case NONE:
break;
case SORT:
localStrategy="String_Node_Str";
break;
case COMBININGSORT:
localStrategy="String_Node_Str";
break;
default :
throw new CompilerException("String_Node_Str" + channel.getLocalStrategy().name());
}
if (channel != null && channel.getLocalStrategyKeys() != null && channel.getLocalStrategyKeys().size() > 0) {
localStrategy+="String_Node_Str" + (channel.getLocalStrategySortOrder() == null ? channel.getLocalStrategyKeys().toString() : Utils.createOrdering(channel.getLocalStrategyKeys(),channel.getLocalStrategySortOrder()).toString());
}
if (localStrategy != null) {
writer.print("String_Node_Str" + localStrategy + "String_Node_Str");
}
if (channel != null && channel.getTempMode() != TempMode.NONE) {
String tempMode=channel.getTempMode().toString();
writer.print("String_Node_Str" + tempMode + "String_Node_Str");
}
}
writer.print('}');
connNum++;
}
inputNum++;
}
writer.print("String_Node_Str");
}
final PlanNode p=node.getPlanNode();
if (p == null) {
writer.print("String_Node_Str");
return;
}
String locString=null;
if (p.getDriverStrategy() != null) {
switch (p.getDriverStrategy()) {
case NONE:
break;
case MAP:
locString="String_Node_Str";
break;
case PARTIAL_GROUP:
locString="String_Node_Str";
break;
case GROUP_OVER_ORDERED:
locString="String_Node_Str";
break;
case HYBRIDHASH_BUILD_FIRST:
locString="String_Node_Str" + child1name + "String_Node_Str";
break;
case HYBRIDHASH_BUILD_SECOND:
locString="String_Node_Str" + child2name + "String_Node_Str";
break;
case NESTEDLOOP_BLOCKED_OUTER_FIRST:
locString="String_Node_Str" + child1name + "String_Node_Str";
break;
case NESTEDLOOP_BLOCKED_OUTER_SECOND:
locString="String_Node_Str" + child2name + "String_Node_Str";
break;
case NESTEDLOOP_STREAMED_OUTER_FIRST:
locString="String_Node_Str" + child1name + "String_Node_Str";
break;
case NESTEDLOOP_STREAMED_OUTER_SECOND:
locString="String_Node_Str" + child2name + "String_Node_Str";
break;
case MERGE:
locString="String_Node_Str";
break;
case CO_GROUP:
locString="String_Node_Str";
break;
default :
throw new CompilerException("String_Node_Str" + p.getDriverStrategy().name() + "String_Node_Str");
}
if (locString != null) {
writer.print("String_Node_Str");
writer.print(locString);
writer.print("String_Node_Str");
}
}
{
final GlobalProperties gp=p.getGlobalProperties();
writer.print("String_Node_Str");
addProperty(writer,"String_Node_Str",gp.getPartitioning().name(),true);
if (gp.getPartitioningFields() != null) {
addProperty(writer,"String_Node_Str",gp.getPartitioningFields().toString(),false);
}
if (gp.getPartitioningOrdering() != null) {
addProperty(writer,"String_Node_Str",gp.getPartitioningOrdering().toString(),false);
}
 else {
addProperty(writer,"String_Node_Str","String_Node_Str",false);
}
if (n.getUniqueFields() == null || n.getUniqueFields().size() == 0) {
addProperty(writer,"String_Node_Str","String_Node_Str",false);
}
 else {
addProperty(writer,"String_Node_Str",n.getUniqueFields().toString(),false);
}
writer.print("String_Node_Str");
}
{
LocalProperties lp=p.getLocalProperties();
writer.print("String_Node_Str");
if (lp.getOrdering() != null) {
addProperty(writer,"String_Node_Str",lp.getOrdering().toString(),true);
}
 else {
addProperty(writer,"String_Node_Str","String_Node_Str",true);
}
if (lp.getGroupedFields() != null && lp.getGroupedFields().size() > 0) {
addProperty(writer,"String_Node_Str",lp.getGroupedFields().toString(),false);
}
 else {
addProperty(writer,"String_Node_Str","String_Node_Str",false);
}
if (n.getUniqueFields() == null || n.getUniqueFields().size() == 0) {
addProperty(writer,"String_Node_Str","String_Node_Str",false);
}
 else {
addProperty(writer,"String_Node_Str",n.getUniqueFields().toString(),false);
}
writer.print("String_Node_Str");
}
writer.print("String_Node_Str");
addProperty(writer,"String_Node_Str",n.getEstimatedNumRecords() == -1 ? "String_Node_Str" : formatNumber(n.getEstimatedNumRecords()),true);
String estCardinality="String_Node_Str";
if (n.getEstimatedCardinalities().size() > 0) {
estCardinality="String_Node_Str";
for (Entry<FieldSet,Long> entry : n.getEstimatedCardinalities().entrySet()) {
estCardinality+="String_Node_Str" + entry.getKey().toString() + "String_Node_Str"+ entry.getValue()+ "String_Node_Str";
}
}
addProperty(writer,"String_Node_Str",estCardinality,false);
addProperty(writer,"String_Node_Str",n.getEstimatedOutputSize() == -1 ? "String_Node_Str" : formatNumber(n.getEstimatedOutputSize(),"String_Node_Str"),false);
writer.print("String_Node_Str");
if (p.getNodeCosts() != null) {
writer.print("String_Node_Str");
addProperty(writer,"String_Node_Str",p.getNodeCosts().getNetworkCost() == -1 ? "String_Node_Str" : formatNumber(p.getNodeCosts().getNetworkCost(),"String_Node_Str"),true);
addProperty(writer,"String_Node_Str",p.getNodeCosts().getDiskCost() == -1 ? "String_Node_Str" : formatNumber(p.getNodeCosts().getDiskCost(),"String_Node_Str"),false);
addProperty(writer,"String_Node_Str",p.getCumulativeCosts().getNetworkCost() == -1 ? "String_Node_Str" : formatNumber(p.getCumulativeCosts().getNetworkCost(),"String_Node_Str"),false);
addProperty(writer,"String_Node_Str",p.getCumulativeCosts().getDiskCost() == -1 ? "String_Node_Str" : formatNumber(p.getCumulativeCosts().getDiskCost(),"String_Node_Str"),false);
writer.print("String_Node_Str");
}
if (n.getPactContract().getCompilerHints() != null) {
CompilerHints hints=n.getPactContract().getCompilerHints();
CompilerHints defaults=new CompilerHints();
writer.print("String_Node_Str");
String hintCardinality;
if (hints.getDistinctCounts().size() > 0) {
hintCardinality="String_Node_Str";
for (Entry<FieldSet,Long> entry : hints.getDistinctCounts().entrySet()) {
hintCardinality+="String_Node_Str" + entry.getKey().toString() + "String_Node_Str"+ entry.getValue()+ "String_Node_Str";
}
}
 else {
hintCardinality="String_Node_Str";
}
addProperty(writer,"String_Node_Str",hintCardinality,true);
addProperty(writer,"String_Node_Str",hints.getAvgRecordsEmittedPerStubCall() == defaults.getAvgRecordsEmittedPerStubCall() ? "String_Node_Str" : String.valueOf(hints.getAvgRecordsEmittedPerStubCall()),false);
String valuesKey;
if (hints.getAvgNumRecordsPerDistinctFields().size() > 0) {
valuesKey="String_Node_Str";
for (Entry<FieldSet,Float> entry : hints.getAvgNumRecordsPerDistinctFields().entrySet()) {
valuesKey+="String_Node_Str" + entry.getKey().toString() + "String_Node_Str"+ entry.getValue()+ "String_Node_Str";
}
}
 else {
valuesKey="String_Node_Str";
}
addProperty(writer,"String_Node_Str",valuesKey,false);
addProperty(writer,"String_Node_Str",hints.getAvgBytesPerRecord() == defaults.getAvgBytesPerRecord() ? "String_Node_Str" : String.valueOf(hints.getAvgBytesPerRecord()),false);
writer.print("String_Node_Str");
}
writer.print("String_Node_Str");
}