use of org.apache.drill.exec.planner.physical.explain.PrelSequencer.OpId in project drill by apache.
the class NumberingRelWriter method explain_.
//~ Methods ----------------------------------------------------------------
protected void explain_(RelNode rel, List<Pair<String, Object>> values) {
List<RelNode> inputs = rel.getInputs();
if (rel instanceof HashJoinPrel && ((HashJoinPrel) rel).isSwapped()) {
HashJoinPrel joinPrel = (HashJoinPrel) rel;
inputs = FlatLists.of(joinPrel.getRight(), joinPrel.getLeft());
}
RelMetadataQuery mq = RelMetadataQuery.instance();
if (!mq.isVisibleInExplain(rel, detailLevel)) {
// render children in place of this, at same level
explainInputs(inputs);
return;
}
StringBuilder s = new StringBuilder();
OpId id = ids.get(rel);
if (id != null) {
s.append(String.format("%02d-%02d", id.fragmentId, id.opId));
} else {
s.append(" ");
}
s.append(" ");
if (id != null && id.opId == 0) {
for (int i = 0; i < spacer.get(); i++) {
s.append('-');
}
} else {
spacer.spaces(s);
}
s.append(" ");
s.append(rel.getRelTypeName().replace("Prel", ""));
if (detailLevel != SqlExplainLevel.NO_ATTRIBUTES) {
int j = 0;
for (Pair<String, Object> value : values) {
if (value.right instanceof RelNode) {
continue;
}
if (j++ == 0) {
s.append("(");
} else {
s.append(", ");
}
s.append(value.left).append("=[").append(value.right).append("]");
}
if (j > 0) {
s.append(")");
}
}
if (detailLevel == SqlExplainLevel.ALL_ATTRIBUTES) {
s.append(" : rowType = ").append(rel.getRowType()).append(": rowcount = ").append(mq.getRowCount(rel)).append(", cumulative cost = ").append(mq.getCumulativeCost(rel)).append(", id = ").append(rel.getId());
}
pw.println(s);
spacer.add(2);
explainInputs(inputs);
spacer.subtract(2);
}
Aggregations