org.apache.calcite.rel.externalize.RelWriterImpl Java Examples

The following examples show how to use org.apache.calcite.rel.externalize.RelWriterImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VolcanoPlanner.java    From Bats with Apache License 2.0 6 votes vote down vote up
/**
 * Dumps the internal state of this VolcanoPlanner to a writer.
 *
 * @param pw Print writer
 * @see #normalizePlan(String)
 */
public void dump(PrintWriter pw) {
  pw.println("Root: " + root.getDescription());
  pw.println("Original rel:");

  if (originalRoot != null) {
    originalRoot.explain(
        new RelWriterImpl(pw, SqlExplainLevel.ALL_ATTRIBUTES, false));
  }
  if (CalciteSystemProperty.DUMP_SETS.value()) {
    pw.println();
    pw.println("Sets:");
    dumpSets(pw);
  }
  if (CalciteSystemProperty.DUMP_GRAPHVIZ.value()) {
    pw.println();
    pw.println("Graphviz:");
    dumpGraphviz(pw);
  }
}
 
Example #2
Source File: VolcanoPlanner.java    From calcite with Apache License 2.0 6 votes vote down vote up
/**
 * Dumps the internal state of this VolcanoPlanner to a writer.
 *
 * @param pw Print writer
 * @see #normalizePlan(String)
 */
public void dump(PrintWriter pw) {
  pw.println("Root: " + root);
  pw.println("Original rel:");

  if (originalRoot != null) {
    originalRoot.explain(
        new RelWriterImpl(pw, SqlExplainLevel.ALL_ATTRIBUTES, false));
  }

  try {
    if (CalciteSystemProperty.DUMP_SETS.value()) {
      pw.println();
      pw.println("Sets:");
      Dumpers.dumpSets(this, pw);
    }
    if (CalciteSystemProperty.DUMP_GRAPHVIZ.value()) {
      pw.println();
      pw.println("Graphviz:");
      Dumpers.dumpGraphviz(this, pw);
    }
  } catch (Exception | AssertionError e) {
    pw.println("Error when dumping plan state: \n"
        + e);
  }
}
 
Example #3
Source File: RelOptUtil.java    From Bats with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example #4
Source File: RexProgram.java    From Bats with Apache License 2.0 5 votes vote down vote up
@Override
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();
}
 
Example #5
Source File: RelOptUtil.java    From calcite with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example #6
Source File: RexProgram.java    From calcite with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #7
Source File: SubstitutionUtils.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
public static int hash(RelNode rel) {
  Hasher hasher = new Hasher();
  PrintWriter pw = new PrintWriter(hasher, false);
  rel.explain(new RelWriterImpl(pw, SqlExplainLevel.DIGEST_ATTRIBUTES, false));
  return hasher.hash;
}