• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SqlExplainLevel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.calcite.sql.SqlExplainLevel的典型用法代码示例。如果您正苦于以下问题:Java SqlExplainLevel类的具体用法?Java SqlExplainLevel怎么用?Java SqlExplainLevel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SqlExplainLevel类属于org.apache.calcite.sql包,在下文中一共展示了SqlExplainLevel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setPlansWithIds

import org.apache.calcite.sql.SqlExplainLevel; //导入依赖的package包/类
/**
 * Generate readable text and json plans and set them in <code>planHolder</code>
 * @param rel
 * @param explainlevel explain plan level.
 * @param observer
 */
public static String setPlansWithIds(final Prel rel, final SqlExplainLevel explainlevel, final AttemptObserver observer, final long millisTaken) {
  if (rel == null) {
    return null;
  }

  Map<Prel, OpId> relIdMap = getIdMap(rel);
  final StringWriter sw = new StringWriter();
  final RelWriter textPlanWriter = new NumberingRelWriter(relIdMap, new PrintWriter(sw), explainlevel);
  rel.explain(textPlanWriter);

  final String textPlan = sw.toString();
  observer.planText(sw.toString(), millisTaken);
  final RelJsonWriter jsonPlanWriter = new RelJsonWriter(getIdMap(rel), explainlevel);
  rel.explain(jsonPlanWriter);
  observer.planJsonPlan(jsonPlanWriter.asString());
  return textPlan;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:24,代码来源:PrelSequencer.java


示例2: trimUnusedFields

import org.apache.calcite.sql.SqlExplainLevel; //导入依赖的package包/类
/**
 * Walks over a tree of relational expressions, replacing each
 * {@link RelNode} with a 'slimmed down' relational expression that projects
 * only the fields required by its consumer.
 *
 * <p>This may make things easier for the optimizer, by removing crud that
 * would expand the search space, but is difficult for the optimizer itself
 * to do it, because optimizer rules must preserve the number and type of
 * fields. Hence, this transform that operates on the entire tree, similar
 * to the {@link RelStructuredTypeFlattener type-flattening transform}.
 *
 * <p>Currently this functionality is disabled in farrago/luciddb; the
 * default implementation of this method does nothing.
 *
 * @param ordered Whether the relational expression must produce results in
 * a particular order (typically because it has an ORDER BY at top level)
 * @param rootRel Relational expression that is at the root of the tree
 * @return Trimmed relational expression
 */
public RelNode trimUnusedFields(boolean ordered, RelNode rootRel) {
	// Trim fields that are not used by their consumer.
	if (isTrimUnusedFields()) {
		final RelFieldTrimmer trimmer = newFieldTrimmer();
		final List<RelCollation> collations =
			rootRel.getTraitSet().getTraits(RelCollationTraitDef.INSTANCE);
		rootRel = trimmer.trim(rootRel);
		if (!ordered
			&& collations != null
			&& !collations.isEmpty()
			&& !collations.equals(ImmutableList.of(RelCollations.EMPTY))) {
			final RelTraitSet traitSet = rootRel.getTraitSet()
				.replace(RelCollationTraitDef.INSTANCE, collations);
			rootRel = rootRel.copy(traitSet, rootRel.getInputs());
		}
		if (SQL2REL_LOGGER.isDebugEnabled()) {
			SQL2REL_LOGGER.debug(
				RelOptUtil.dumpPlan("Plan after trimming unused fields", rootRel,
					SqlExplainFormat.TEXT, SqlExplainLevel.EXPPLAN_ATTRIBUTES));
		}
	}
	return rootRel;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:43,代码来源:SqlToRelConverter.java


示例3: decorrelateQuery

import org.apache.calcite.sql.SqlExplainLevel; //导入依赖的package包/类
/**
 * Decorrelates a query.
 * <p>
 * <p>This is the main entry point to {@code FlinkRelDecorrelator}.
 *
 * @param rootRel Root node of the query
 * @return Equivalent query with all
 * {@link LogicalCorrelate} instances removed
 */
public static RelNode decorrelateQuery(RelNode rootRel) {
	final CorelMap corelMap = new CorelMapBuilder().build(rootRel);
	if (!corelMap.hasCorrelation()) {
		return rootRel;
	}

	final RelOptCluster cluster = rootRel.getCluster();
	final FlinkRelDecorrelator decorrelator = new FlinkRelDecorrelator(cluster, corelMap, cluster.getPlanner().getContext());

	RelNode newRootRel = decorrelator.removeCorrelationViaRule(rootRel);

	if (SQL2REL_LOGGER.isDebugEnabled()) {
		SQL2REL_LOGGER.debug(RelOptUtil.dumpPlan("Plan after removing Correlator", newRootRel, false, SqlExplainLevel.EXPPLAN_ATTRIBUTES));
	}

	if (!decorrelator.cm.mapCorVarToCorRel.isEmpty()) {
		newRootRel = decorrelator.decorrelate(newRootRel);
	}

	return newRootRel;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:31,代码来源:FlinkRelDecorrelator.java


示例4: trimUnusedFields

import org.apache.calcite.sql.SqlExplainLevel; //导入依赖的package包/类
/**
 * Walks over a tree of relational expressions, replacing each
 * {@link RelNode} with a 'slimmed down' relational expression that projects
 * only the fields required by its consumer.
 *
 * <p>This may make things easier for the optimizer, by removing crud that
 * would expand the search space, but is difficult for the optimizer itself
 * to do it, because optimizer rules must preserve the number and type of
 * fields. Hence, this transform that operates on the entire tree, similar
 * to the {@link RelStructuredTypeFlattener type-flattening transform}.
 *
 * <p>Currently this functionality is disabled in farrago/luciddb; the
 * default implementation of this method does nothing.
 *
 * @param ordered Whether the relational expression must produce results in
 * a particular order (typically because it has an ORDER BY at top level)
 * @param rootRel Relational expression that is at the root of the tree
 * @return Trimmed relational expression
 */
public RelNode trimUnusedFields(boolean ordered, RelNode rootRel) {
  // Trim fields that are not used by their consumer.
  if (isTrimUnusedFields()) {
    final RelFieldTrimmer trimmer = newFieldTrimmer();
    final List<RelCollation> collations =
        rootRel.getTraitSet().getTraits(RelCollationTraitDef.INSTANCE);
    rootRel = trimmer.trim(rootRel);
    if (!ordered
        && collations != null
        && !collations.isEmpty()
        && !collations.equals(ImmutableList.of(RelCollations.EMPTY))) {
      final RelTraitSet traitSet = rootRel.getTraitSet()
          .replace(RelCollationTraitDef.INSTANCE, collations);
      rootRel = rootRel.copy(traitSet, rootRel.getInputs());
    }
    if (SQL2REL_LOGGER.isDebugEnabled()) {
      SQL2REL_LOGGER.debug(
          RelOptUtil.dumpPlan("Plan after trimming unused fields", rootRel,
              SqlExplainFormat.TEXT, SqlExplainLevel.EXPPLAN_ATTRIBUTES));
    }
  }
  return rootRel;
}
 
开发者ID:apache,项目名称:kylin,代码行数:43,代码来源:SqlToRelConverter.java


示例5: decorrelateQuery

import org.apache.calcite.sql.SqlExplainLevel; //导入依赖的package包/类
/** Decorrelates a query.
 *
 * <p>This is the main entry point to {@code RelDecorrelator}.
 *
 * @param rootRel Root node of the query
 *
 * @return Equivalent query with all
 * {@link org.apache.calcite.rel.logical.LogicalCorrelate} instances removed
 */
public static RelNode decorrelateQuery(RelNode rootRel) {
  final CorelMap corelMap = new CorelMapBuilder().build(rootRel);
  if (!corelMap.hasCorrelation()) {
    return rootRel;
  }

  final RelOptCluster cluster = rootRel.getCluster();
  final RelDecorrelator decorrelator =
      new RelDecorrelator(cluster, corelMap,
          cluster.getPlanner().getContext());

  RelNode newRootRel = decorrelator.removeCorrelationViaRule(rootRel);

  if (SQL2REL_LOGGER.isDebugEnabled()) {
    SQL2REL_LOGGER.debug(
        RelOptUtil.dumpPlan("Plan after removing Correlator", newRootRel,
            SqlExplainFormat.TEXT, SqlExplainLevel.EXPPLAN_ATTRIBUTES));
  }

  if (!decorrelator.cm.mapCorToCorRel.isEmpty()) {
    newRootRel = decorrelator.decorrelate(newRootRel);
  }

  return newRootRel;
}
 
开发者ID:apache,项目名称:calcite,代码行数:35,代码来源:RelDecorrelator.java


示例6: trim

import org.apache.calcite.sql.SqlExplainLevel; //导入依赖的package包/类
/**
 * Trims unused fields from a relational expression.
 *
 * <p>We presume that all fields of the relational expression are wanted by
 * its consumer, so only trim fields that are not used within the tree.
 *
 * @param root Root node of relational expression
 * @return Trimmed relational expression
 */
public RelNode trim(RelNode root) {
  final int fieldCount = root.getRowType().getFieldCount();
  final ImmutableBitSet fieldsUsed = ImmutableBitSet.range(fieldCount);
  final Set<RelDataTypeField> extraFields = Collections.emptySet();
  final TrimResult trimResult =
      dispatchTrimFields(root, fieldsUsed, extraFields);
  if (!trimResult.right.isIdentity()) {
    throw new IllegalArgumentException();
  }
  if (SqlToRelConverter.SQL2REL_LOGGER.isDebugEnabled()) {
    SqlToRelConverter.SQL2REL_LOGGER.debug(
        RelOptUtil.dumpPlan("Plan after trimming unused fields",
            trimResult.left, SqlExplainFormat.TEXT,
            SqlExplainLevel.EXPPLAN_ATTRIBUTES));
  }
  return trimResult.left;
}
 
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:RelFieldTrimmer.java


示例7: setRoot

import org.apache.calcite.sql.SqlExplainLevel; //导入依赖的package包/类
public void setRoot(RelNode rel) {
  // We're registered all the rules, and therefore RelNode classes,
  // we're interested in, and have not yet started calling metadata providers.
  // So now is a good time to tell the metadata layer what to expect.
  registerMetadataRels();

  this.root = registerImpl(rel, null);
  if (this.originalRoot == null) {
    this.originalRoot = rel;
  }
  this.originalRootString =
      RelOptUtil.toString(root, SqlExplainLevel.ALL_ATTRIBUTES);

  // Making a node the root changes its importance.
  this.ruleQueue.recompute(this.root);
  ensureRootConverters();
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:VolcanoPlanner.java


示例8: toLeafJoinForm

import org.apache.calcite.sql.SqlExplainLevel; //导入依赖的package包/类
/**
 * Converts a relational expression to a form where
 * {@link org.apache.calcite.rel.logical.LogicalJoin}s are
 * as close to leaves as possible.
 */
public static RelNode toLeafJoinForm(RelNode rel) {
  final Program program = Programs.hep(
      ImmutableList.of(
          JoinProjectTransposeRule.RIGHT_PROJECT,
          JoinProjectTransposeRule.LEFT_PROJECT,
          FilterJoinRule.FilterIntoJoinRule.FILTER_ON_JOIN,
          ProjectRemoveRule.INSTANCE,
          ProjectMergeRule.INSTANCE),
      false,
      DefaultRelMetadataProvider.INSTANCE);
  if (CalcitePrepareImpl.DEBUG) {
    System.out.println(
        RelOptUtil.dumpPlan("before", rel, SqlExplainFormat.TEXT,
            SqlExplainLevel.DIGEST_ATTRIBUTES));
  }
  final RelNode rel2 = program.run(null, rel, null,
      ImmutableList.<RelOptMaterialization>of(),
      ImmutableList.<RelOptLattice>of());
  if (CalcitePrepareImpl.DEBUG) {
    System.out.println(
        RelOptUtil.dumpPlan("after", rel2, SqlExplainFormat.TEXT,
            SqlExplainLevel.DIGEST_ATTRIBUTES));
  }
  return rel2;
}
 
开发者ID:apache,项目名称:calcite,代码行数:31,代码来源:RelOptMaterialization.java


示例9: testExplainAsXml

import org.apache.calcite.sql.SqlExplainLevel; //导入依赖的package包/类
@Test public void testExplainAsXml() {
  String sql = "select 1 + 2, 3 from (values (true))";
  final RelNode rel = tester.convertSqlToRel(sql).rel;
  StringWriter sw = new StringWriter();
  PrintWriter pw = new PrintWriter(sw);
  RelXmlWriter planWriter =
      new RelXmlWriter(pw, SqlExplainLevel.EXPPLAN_ATTRIBUTES);
  rel.explain(planWriter);
  pw.flush();
  TestUtil.assertEqualsVerbose(
      "<RelNode type=\"LogicalProject\">\n"
          + "\t<Property name=\"EXPR$0\">\n"
          + "\t\t+(1, 2)\t</Property>\n"
          + "\t<Property name=\"EXPR$1\">\n"
          + "\t\t3\t</Property>\n"
          + "\t<Inputs>\n"
          + "\t\t<RelNode type=\"LogicalValues\">\n"
          + "\t\t\t<Property name=\"tuples\">\n"
          + "\t\t\t\t[{ true }]\t\t\t</Property>\n"
          + "\t\t\t<Inputs/>\n"
          + "\t\t</RelNode>\n"
          + "\t</Inputs>\n"
          + "</RelNode>\n",
      Util.toLinux(sw.toString()));
}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:SqlToRelConverterTest.java


示例10: explainTerms

import org.apache.calcite.sql.SqlExplainLevel; //导入依赖的package包/类
public RelWriter explainTerms(RelWriter pw) {
  return super.explainTerms(pw)
      .itemIf("type", this.rowType, pw.getDetailLevel() == SqlExplainLevel.DIGEST_ATTRIBUTES)
      .itemIf("type", this.rowType.getFieldList(), pw.nest())
      .itemIf("tuplesCount", rowCount, pw.getDetailLevel() != SqlExplainLevel.ALL_ATTRIBUTES)
      .itemIf("tuples", options.asNode(), pw.getDetailLevel() == SqlExplainLevel.ALL_ATTRIBUTES);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:8,代码来源:DrillValuesRel.java


示例11: printWithIds

import org.apache.calcite.sql.SqlExplainLevel; //导入依赖的package包/类
public static String printWithIds(final Prel rel, SqlExplainLevel explainlevel) {
    if (rel == null) {
      return null;
    }
    final StringWriter sw = new StringWriter();
    final RelWriter planWriter = new NumberingRelWriter(getIdMap(rel), new PrintWriter(sw), explainlevel);
    rel.explain(planWriter);
    return sw.toString();

}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:11,代码来源:PrelSequencer.java


示例12: log

import org.apache.calcite.sql.SqlExplainLevel; //导入依赖的package包/类
protected void log(final String name, final Prel node, final Logger logger) {
  String plan = PrelSequencer.printWithIds(node, SqlExplainLevel.ALL_ATTRIBUTES);
  if(textPlan != null){
    textPlan.value = plan;
  }

  if (logger.isDebugEnabled()) {
    logger.debug(name + " : \n" + plan);
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:11,代码来源:DefaultSqlHandler.java


示例13: LogicalExplain

import org.apache.calcite.sql.SqlExplainLevel; //导入依赖的package包/类
public LogicalExplain(RelNode node, SqlExplainLevel level, QueryContext context) {
  this.text = RelOptUtil.toString(node, level);
  DrillImplementor implementor = new DrillImplementor(new DrillParseContext(context.getPlannerSettings()), ResultMode.LOGICAL);
  implementor.go( (DrillRel) node);
  LogicalPlan plan = implementor.getPlan();
  this.json = plan.unparse(context.getConfig());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:8,代码来源:ExplainHandler.java


示例14: testRelLogicalJoinOrder

import org.apache.calcite.sql.SqlExplainLevel; //导入依赖的package包/类
/**
 * This method will take a SQL string statement, get the LOGICAL plan in Optiq
 * RelNode format. Then check the physical plan against the list expected
 * substrs. Verify all the expected strings are contained in the physical plan
 * string.
 */
public static void testRelLogicalJoinOrder(String sql, String... expectedSubstrs) throws Exception {
  final String planStr = getDrillRelPlanInString(sql, SqlExplainLevel.EXPPLAN_ATTRIBUTES, Depth.LOGICAL);
  final String prefixJoinOrder = getLogicalPrefixJoinOrderFromPlan(planStr);
  System.out.println(" prefix Join order = \n" + prefixJoinOrder);
  for (final String substr : expectedSubstrs) {
    assertTrue(String.format("Expected string %s is not in the prefixJoinOrder %s!", substr, prefixJoinOrder),
        prefixJoinOrder.contains(substr));
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:16,代码来源:PlanTestBase.java


示例15: testRelPhysicalJoinOrder

import org.apache.calcite.sql.SqlExplainLevel; //导入依赖的package包/类
/**
 * This method will take a SQL string statement, get the LOGICAL plan in Optiq
 * RelNode format. Then check the physical plan against the list expected
 * substrs. Verify all the expected strings are contained in the physical plan
 * string.
 */
public static void testRelPhysicalJoinOrder(String sql, String... expectedSubstrs) throws Exception {
  final String planStr = getDrillRelPlanInString(sql, SqlExplainLevel.EXPPLAN_ATTRIBUTES, Depth.PHYSICAL);
  final String prefixJoinOrder = getPhysicalPrefixJoinOrderFromPlan(planStr);
  System.out.println(" prefix Join order = \n" + prefixJoinOrder);
  for (final String substr : expectedSubstrs) {
    assertTrue(String.format("Expected string %s is not in the prefixJoinOrder %s!", substr, prefixJoinOrder),
        prefixJoinOrder.contains(substr));
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:16,代码来源:PlanTestBase.java


示例16: testRelPhysicalPlanLevDigest

import org.apache.calcite.sql.SqlExplainLevel; //导入依赖的package包/类
/**
 * This method will take a SQL string statement, get the PHYSICAL plan in
 * Optiq RelNode format. Then check the physical plan against the list
 * expected substrs. Verify all the expected strings are contained in the
 * physical plan string.
 */
public static void testRelPhysicalPlanLevDigest(String sql, String... expectedSubstrs)
    throws Exception {
  final String planStr = getDrillRelPlanInString(sql, SqlExplainLevel.DIGEST_ATTRIBUTES, Depth.PHYSICAL);
  for (final String substr : expectedSubstrs) {
    assertTrue(planStr.contains(substr));
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:14,代码来源:PlanTestBase.java


示例17: testRelLogicalPlanLevDigest

import org.apache.calcite.sql.SqlExplainLevel; //导入依赖的package包/类
/**
 * This method will take a SQL string statement, get the LOGICAL plan in Optiq
 * RelNode format. Then check the physical plan against the list expected
 * substrs. Verify all the expected strings are contained in the physical plan
 * string.
 */
public static void testRelLogicalPlanLevDigest(String sql, String... expectedSubstrs)
    throws Exception {
  final String planStr = getDrillRelPlanInString(sql,
      SqlExplainLevel.DIGEST_ATTRIBUTES, Depth.LOGICAL);

  for (final String substr : expectedSubstrs) {
    assertTrue(planStr.contains(substr));
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:16,代码来源:PlanTestBase.java


示例18: testRelPhysicalPlanLevExplain

import org.apache.calcite.sql.SqlExplainLevel; //导入依赖的package包/类
/**
 * This method will take a SQL string statement, get the PHYSICAL plan in
 * Optiq RelNode format. Then check the physical plan against the list
 * expected substrs. Verify all the expected strings are contained in the
 * physical plan string.
 */
public static void testRelPhysicalPlanLevExplain(String sql, String... expectedSubstrs) throws Exception {
  final String planStr = getDrillRelPlanInString(sql, SqlExplainLevel.EXPPLAN_ATTRIBUTES, Depth.PHYSICAL);

  for (final String substr : expectedSubstrs) {
    assertTrue(planStr.contains(substr));
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:14,代码来源:PlanTestBase.java


示例19: testRelLogicalPlanLevExplain

import org.apache.calcite.sql.SqlExplainLevel; //导入依赖的package包/类
/**
 * This method will take a SQL string statement, get the LOGICAL plan in Optiq
 * RelNode format. Then check the physical plan against the list expected
 * substrs. Verify all the expected strings are contained in the physical plan
 * string.
 */
public static void testRelLogicalPlanLevExplain(String sql, String... expectedSubstrs) throws Exception {
  final String planStr = getDrillRelPlanInString(sql, SqlExplainLevel.EXPPLAN_ATTRIBUTES, Depth.LOGICAL);

  for (final String substr : expectedSubstrs) {
    assertTrue(planStr.contains(substr));
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:14,代码来源:PlanTestBase.java


示例20: getDrillRelPlanInString

import org.apache.calcite.sql.SqlExplainLevel; //导入依赖的package包/类
private static String getDrillRelPlanInString(String sql, SqlExplainLevel level,
    Depth depth) throws Exception {
  String levelStr = " ", depthStr = " ";

  switch (level) {
  case NO_ATTRIBUTES:
    levelStr = "EXCLUDING ATTRIBUTES";
    break;
  case EXPPLAN_ATTRIBUTES:
    levelStr = "INCLUDING ATTRIBUTES";
    break;
  case ALL_ATTRIBUTES:
    levelStr = "INCLUDING ALL ATTRIBUTES";
    break;
  default:
    break;
  }

  switch (depth) {
  case TYPE:
    depthStr = "WITH TYPE";
    break;
  case LOGICAL:
    depthStr = "WITHOUT IMPLEMENTATION";
    break;
  case PHYSICAL:
    depthStr = "WITH IMPLEMENTATION";
    break;
  default:
    throw new UnsupportedOperationException();
  }

  sql = "EXPLAIN PLAN " + levelStr + " " + depthStr + "  for "
      + QueryTestUtil.normalizeQuery(sql);

  return getPlanInString(sql, OPTIQ_FORMAT);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:38,代码来源:PlanTestBase.java



注:本文中的org.apache.calcite.sql.SqlExplainLevel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PsiElementProcessor类代码示例发布时间:2022-05-21
下一篇:
Java Example类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap