@Override public String getStreamingPlanAsJSON() { try { return new JSONGenerator(this).getJSON(); } catch (Exception e) { throw new RuntimeException("JSON plan creation failed", e); } }
decorateNode(vertexID, node); decorateEdge(inputs, inEdge, mappedID); obj.put(PREDECESSORS, iterationInputs); toVisit.remove(iterationHead); visitIteration(iterationSteps, toVisit, iterationHead, edgeRemapings, iterationInputs); jsonArray.add(obj); visit(jsonArray, toVisit, edgeRemapings);
private void visitIteration(ArrayNode jsonArray, List<Integer> toVisit, int headId, Map<Integer, Integer> edgeRemapings, ArrayNode iterationInEdges) { Integer vertexID = toVisit.get(0); StreamNode vertex = streamGraph.getStreamNode(vertexID); toVisit.remove(vertexID); // Ignoring head and tail to avoid redundancy if (!streamGraph.vertexIDtoLoopTimeout.containsKey(vertexID)) { ObjectNode obj = mapper.createObjectNode(); jsonArray.add(obj); decorateNode(vertexID, obj); ArrayNode inEdges = mapper.createArrayNode(); obj.put(PREDECESSORS, inEdges); for (StreamEdge inEdge : vertex.getInEdges()) { int inputID = inEdge.getSourceId(); if (edgeRemapings.keySet().contains(inputID)) { decorateEdge(inEdges, inEdge, inputID); } else if (!streamGraph.vertexIDtoLoopTimeout.containsKey(inputID)) { decorateEdge(iterationInEdges, inEdge, inputID); } } edgeRemapings.put(vertexID, headId); visitIteration(jsonArray, toVisit, headId, edgeRemapings, iterationInEdges); } }
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>()); return json.toString(); }
private void visitIteration(ArrayNode jsonArray, List<Integer> toVisit, int headId, Map<Integer, Integer> edgeRemapings, ArrayNode iterationInEdges) { Integer vertexID = toVisit.get(0); StreamNode vertex = streamGraph.getStreamNode(vertexID); toVisit.remove(vertexID); // Ignoring head and tail to avoid redundancy if (!streamGraph.vertexIDtoLoopTimeout.containsKey(vertexID)) { ObjectNode obj = mapper.createObjectNode(); jsonArray.add(obj); decorateNode(vertexID, obj); ArrayNode inEdges = mapper.createArrayNode(); obj.put(PREDECESSORS, inEdges); for (StreamEdge inEdge : vertex.getInEdges()) { int inputID = inEdge.getSourceId(); if (edgeRemapings.keySet().contains(inputID)) { decorateEdge(inEdges, inEdge, inputID); } else if (!streamGraph.vertexIDtoLoopTimeout.containsKey(inputID)) { decorateEdge(iterationInEdges, inEdge, inputID); } } edgeRemapings.put(vertexID, headId); visitIteration(jsonArray, toVisit, headId, edgeRemapings, iterationInEdges); } }
public String getJSON() throws JSONException { JSONObject json = new JSONObject(); JSONArray nodes = new JSONArray(); json.put("nodes", nodes); List<Integer> operatorIDs = new ArrayList<Integer>(streamGraph.getVertexIDs()); Collections.sort(operatorIDs, new Comparator<Integer>() { @Override public int compare(Integer o1, Integer o2) { // put sinks at the back if (streamGraph.getSinkIDs().contains(o1)) { return 1; } else if (streamGraph.getSinkIDs().contains(o2)) { return -1; } else { return o1 - o2; } } }); visit(nodes, operatorIDs, new HashMap<Integer, Integer>()); return json.toString(); }
decorateNode(vertexID, node); decorateEdge(inputs, inEdge, mappedID); obj.put(PREDECESSORS, iterationInputs); toVisit.remove(iterationHead); visitIteration(iterationSteps, toVisit, iterationHead, edgeRemapings, iterationInputs); jsonArray.add(obj); visit(jsonArray, toVisit, edgeRemapings);
private void visitIteration(ArrayNode jsonArray, List<Integer> toVisit, int headId, Map<Integer, Integer> edgeRemapings, ArrayNode iterationInEdges) { Integer vertexID = toVisit.get(0); StreamNode vertex = streamGraph.getStreamNode(vertexID); toVisit.remove(vertexID); // Ignoring head and tail to avoid redundancy if (!streamGraph.vertexIDtoLoopTimeout.containsKey(vertexID)) { ObjectNode obj = mapper.createObjectNode(); jsonArray.add(obj); decorateNode(vertexID, obj); ArrayNode inEdges = mapper.createArrayNode(); obj.put(PREDECESSORS, inEdges); for (StreamEdge inEdge : vertex.getInEdges()) { int inputID = inEdge.getSourceId(); if (edgeRemapings.keySet().contains(inputID)) { decorateEdge(inEdges, inEdge, inputID); } else if (!streamGraph.vertexIDtoLoopTimeout.containsKey(inputID)) { decorateEdge(iterationInEdges, inEdge, inputID); } } edgeRemapings.put(vertexID, headId); visitIteration(jsonArray, toVisit, headId, edgeRemapings, iterationInEdges); } }
@Override public String getStreamingPlanAsJSON() { try { return new JSONGenerator(this).getJSON(); } catch (Exception e) { throw new RuntimeException("JSON plan creation failed", e); } }
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>()); return json.toString(); }
decorateNode(vertexID, node); decorateEdge(inputs, inEdge, mappedID); obj.put(PREDECESSORS, iterationInputs); toVisit.remove(iterationHead); visitIteration(iterationSteps, toVisit, iterationHead, edgeRemapings, iterationInputs); jsonArray.add(obj); visit(jsonArray, toVisit, edgeRemapings);
private void visitIteration(JSONArray jsonArray, List<Integer> toVisit, int headId, Map<Integer, Integer> edgeRemapings, JSONArray iterationInEdges) throws JSONException { Integer vertexID = toVisit.get(0); StreamNode vertex = streamGraph.getStreamNode(vertexID); toVisit.remove(vertexID); // Ignoring head and tail to avoid redundancy if (!streamGraph.vertexIDtoLoopTimeout.containsKey(vertexID)) { JSONObject obj = new JSONObject(); jsonArray.put(obj); decorateNode(vertexID, obj); JSONArray inEdges = new JSONArray(); obj.put(PREDECESSORS, inEdges); for (StreamEdge inEdge : vertex.getInEdges()) { int inputID = inEdge.getSourceId(); if (edgeRemapings.keySet().contains(inputID)) { decorateEdge(inEdges, inEdge, inputID); } else if (!streamGraph.vertexIDtoLoopTimeout.containsKey(inputID)) { decorateEdge(iterationInEdges, inEdge, inputID); } } edgeRemapings.put(vertexID, headId); visitIteration(jsonArray, toVisit, headId, edgeRemapings, iterationInEdges); } }
@Override public String getStreamingPlanAsJSON() { try { return new JSONGenerator(this).getJSON(); } catch (Exception e) { throw new RuntimeException("JSON plan creation failed", e); } }
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>()); return json.toString(); }
decorateNode(vertexID, node); decorateEdge(inputs, inEdge, mappedID); obj.put(PREDECESSORS, iterationInputs); toVisit.remove(iterationHead); visitIteration(iterationSteps, toVisit, iterationHead, edgeRemapings, iterationInputs); jsonArray.put(obj); visit(jsonArray, toVisit, edgeRemapings);
@Override public String getStreamingPlanAsJSON() { try { return new JSONGenerator(this).getJSON(); } catch (Exception e) { throw new RuntimeException("JSON plan creation failed", e); } }