use of org.apache.hadoop.hive.ql.optimizer.graph.OperatorGraph.OpEdge in project hive by apache.
the class DotExporter method write.
public void write(File outFile) throws Exception {
Map<Operator<?>, Cluster> nodeCluster = operatorGraph.nodeCluster;
DagGraph<Operator<?>, OpEdge> g = operatorGraph.g;
PrintWriter writer = new PrintWriter(outFile);
writer.println("digraph G");
writer.println("{\n");
HashSet<Cluster> clusters = new HashSet<>(nodeCluster.values());
int idx = 0;
for (Cluster cluster : clusters) {
idx++;
writer.printf("subgraph cluster_%d {\n", idx);
for (Operator<?> member : cluster.members) {
writer.printf("%s;\n", nodeName(member));
}
writer.printf("label = \"cluster %d\";\n", idx);
writer.printf("}\n");
}
Set<Operator<?>> nodes = g.nodes();
for (Operator<?> n : nodes) {
writer.printf("%s[shape=record,label=\"%s\",%s];\n", nodeName(n), nodeLabel(n), style(n));
Set<Operator<?>> succ = g.successors(n);
for (Operator<?> s : succ) {
Optional<OpEdge> e = g.getEdge(n, s);
String style = "";
switch(e.get().getEdgeType()) {
case BROADCAST:
style = "[color=blue,label=\"BROADCAST\"]";
break;
case DPP:
style = "[color=green,label=\"DPP\"]";
break;
case SEMIJOIN:
style = "[color=red,label=\"SEMIJOIN\"]";
break;
}
writer.printf("%s->%s%s;\n", nodeName(n), nodeName(s), style);
}
}
writer.println("}\n");
writer.close();
}
Aggregations