Search in sources :

Example 1 with OpEdge

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();
}
Also used : FilterOperator(org.apache.hadoop.hive.ql.exec.FilterOperator) TableScanOperator(org.apache.hadoop.hive.ql.exec.TableScanOperator) Operator(org.apache.hadoop.hive.ql.exec.Operator) OpEdge(org.apache.hadoop.hive.ql.optimizer.graph.OperatorGraph.OpEdge) Cluster(org.apache.hadoop.hive.ql.optimizer.graph.OperatorGraph.Cluster) PrintWriter(java.io.PrintWriter) HashSet(java.util.HashSet)

Aggregations

PrintWriter (java.io.PrintWriter)1 HashSet (java.util.HashSet)1 FilterOperator (org.apache.hadoop.hive.ql.exec.FilterOperator)1 Operator (org.apache.hadoop.hive.ql.exec.Operator)1 TableScanOperator (org.apache.hadoop.hive.ql.exec.TableScanOperator)1 Cluster (org.apache.hadoop.hive.ql.optimizer.graph.OperatorGraph.Cluster)1 OpEdge (org.apache.hadoop.hive.ql.optimizer.graph.OperatorGraph.OpEdge)1