Skip to content

Commit

Permalink
[hotfix] Refactor OperatorID compartion in StreamGraph JSONGenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
tisonkun authored and aljoscha committed Jan 8, 2020
1 parent 07ce59e commit efb12fe
Showing 1 changed file with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,14 @@ public String getJSON() {
ObjectNode json = mapper.createObjectNode();
ArrayNode nodes = mapper.createArrayNode();
json.put("nodes", nodes);
List<Integer> operatorIDs = new ArrayList<Integer>(streamGraph.getVertexIDs());
Collections.sort(operatorIDs, new Comparator<Integer>() {
@Override
public int compare(Integer idOne, Integer idTwo) {
boolean isIdOneSinkId = streamGraph.getSinkIDs().contains(idOne);
boolean isIdTwoSinkId = streamGraph.getSinkIDs().contains(idTwo);
// put sinks at the back
if (isIdOneSinkId == isIdTwoSinkId) {
return idOne.compareTo(idTwo);
} else if (isIdOneSinkId) {
return 1;
} else {
return -1;
}
}
});
visit(nodes, operatorIDs, new HashMap<Integer, Integer>());

List<Integer> operatorIDs = new ArrayList<>(streamGraph.getVertexIDs());
Comparator<Integer> operatorIDComparator = Comparator
.comparingInt((Integer id) -> streamGraph.getSinkIDs().contains(id) ? 1 : 0)
.thenComparingInt(id -> id);
operatorIDs.sort(operatorIDComparator);

visit(nodes, operatorIDs, new HashMap<>());

return json.toPrettyString();
}
Expand Down

0 comments on commit efb12fe

Please sign in to comment.