Skip to content

Commit

Permalink
Fixed JSON Bug for some plans.
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Metzger <[email protected]>

This closes apache#23.
  • Loading branch information
MoeweX authored and rmetzger committed Jun 18, 2014
1 parent 5484d58 commit b692b04
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,22 @@ private void compilePlanToJSON(List<DumpableNode<?>> nodes, PrintWriter writer)
writer.println("\n\t]\n}");
}

private void visit(DumpableNode<?> node, PrintWriter writer, boolean first) {
private boolean visit(DumpableNode<?> node, PrintWriter writer, boolean first) {
// check for duplicate traversal
if (this.nodeIds.containsKey(node)) {
return;
return false;
}

// assign an id first
this.nodeIds.put(node, this.nodeCnt++);

// then recurse
for (DumpableNode<?> child : node.getPredecessors()) {
visit(child, writer, first);
first = false;
//This is important, because when the node was already in the graph it is not allowed
//to set first to false!
if (visit(child, writer, first)) {
first = false;
};
}

// check if this node should be skipped from the dump
Expand All @@ -153,7 +156,7 @@ private void visit(DumpableNode<?> node, PrintWriter writer, boolean first) {
// ------------------ dump after the ascend ---------------------
// start a new node and output node id
if (!first) {
writer.print(",\n");
writer.print(",\n");
}
// open the node
writer.print("\t{\n");
Expand Down Expand Up @@ -385,7 +388,7 @@ private void visit(DumpableNode<?> node, PrintWriter writer, boolean first) {
if (p == null) {
// finish node
writer.print("\n\t}");
return;
return true;
}
// local strategy
String locString = null;
Expand Down Expand Up @@ -579,6 +582,7 @@ private void visit(DumpableNode<?> node, PrintWriter writer, boolean first) {

// finish node
writer.print("\n\t}");
return true;
}

private void addProperty(PrintWriter writer, String name, String value, boolean first) {
Expand Down

0 comments on commit b692b04

Please sign in to comment.