use of org.apache.calcite.rel.externalize.RelWriterImpl in project calcite by apache.
the class RelOptUtil method toString.
/**
* Converts a relational expression to a string.
*/
public static String toString(final RelNode rel, SqlExplainLevel detailLevel) {
if (rel == null) {
return null;
}
final StringWriter sw = new StringWriter();
final RelWriter planWriter = new RelWriterImpl(new PrintWriter(sw), detailLevel, false);
rel.explain(planWriter);
return sw.toString();
}
use of org.apache.calcite.rel.externalize.RelWriterImpl in project calcite by apache.
the class RexProgram method toString.
// description of this calc, chiefly intended for debugging
public String toString() {
// Intended to produce similar output to explainCalc,
// but without requiring a RelNode or RelOptPlanWriter.
final RelWriterImpl pw = new RelWriterImpl(new PrintWriter(new StringWriter()));
collectExplainTerms("", pw);
return pw.simple();
}
use of org.apache.calcite.rel.externalize.RelWriterImpl in project calcite by apache.
the class RelOptUtil method dumpPlan.
/**
* Dumps a plan as a string.
*
* @param header Header to print before the plan. Ignored if the format
* is XML
* @param rel Relational expression to explain
* @param format Output format
* @param detailLevel Detail level
* @return Plan
*/
public static String dumpPlan(String header, RelNode rel, SqlExplainFormat format, SqlExplainLevel detailLevel) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
if (!header.equals("")) {
pw.println(header);
}
RelWriter planWriter;
switch(format) {
case XML:
planWriter = new RelXmlWriter(pw, detailLevel);
break;
case JSON:
planWriter = new RelJsonWriter();
rel.explain(planWriter);
return ((RelJsonWriter) planWriter).asString();
default:
planWriter = new RelWriterImpl(pw, detailLevel, false);
}
rel.explain(planWriter);
pw.flush();
return sw.toString();
}
use of org.apache.calcite.rel.externalize.RelWriterImpl in project calcite by apache.
the class AbstractRelNode method computeDigest.
/**
* Computes the digest. Does not modify this object.
*
* @return Digest
*/
protected String computeDigest() {
StringWriter sw = new StringWriter();
RelWriter pw = new RelWriterImpl(new PrintWriter(sw), SqlExplainLevel.DIGEST_ATTRIBUTES, false) {
protected void explain_(RelNode rel, List<Pair<String, Object>> values) {
pw.write(getRelTypeName());
for (RelTrait trait : traitSet) {
pw.write(".");
pw.write(trait.toString());
}
pw.write("(");
int j = 0;
for (Pair<String, Object> value : values) {
if (j++ > 0) {
pw.write(",");
}
pw.write(value.left + "=" + value.right);
}
pw.write(")");
}
};
explain(pw);
return sw.toString();
}
Aggregations