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

Java RelOptRule类代码示例

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

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



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

示例1: getDrillUserConfigurableLogicalRules

import org.apache.calcite.plan.RelOptRule; //导入依赖的package包/类
/**
 * Get a list of logical rules that can be turned on or off by session/system options.
 *
 * If a rule is intended to always be included with the logical set, it should be added
 * to the immutable list created in the getDrillBasicRules() method below.
 *
 * @param optimizerRulesContext - used to get the list of planner settings, other rules may
 *                                also in the future need to get other query state from this,
 *                                such as the available list of UDFs (as is used by the
 *                                DrillMergeProjectRule created in getDrillBasicRules())
 * @return - a list of rules that have been filtered to leave out
 *         rules that have been turned off by system or session settings
 */
public static RuleSet getDrillUserConfigurableLogicalRules(OptimizerRulesContext optimizerRulesContext) {
  final PlannerSettings ps = optimizerRulesContext.getPlannerSettings();

  // This list is used to store rules that can be turned on an off
  // by user facing planning options
  final Builder<RelOptRule> userConfigurableRules = ImmutableSet.<RelOptRule>builder();

  if (ps.isConstantFoldingEnabled()) {
    // TODO - DRILL-2218
    userConfigurableRules.add(ReduceExpressionsRule.PROJECT_INSTANCE);

    userConfigurableRules.add(DrillReduceExpressionsRule.FILTER_INSTANCE_DRILL);
    userConfigurableRules.add(DrillReduceExpressionsRule.CALC_INSTANCE_DRILL);
  }

  return new DrillRuleSet(userConfigurableRules.build());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:31,代码来源:DrillRuleSets.java


示例2: getDrillBasicRules

import org.apache.calcite.plan.RelOptRule; //导入依赖的package包/类
/**
 * Get an immutable list of rules that will always be used when running
 * logical planning.
 *
 * This cannot be a static singleton because some of the rules need to
 * reference state owned by the current query (including its allocator).
 *
 * If a logical rule needs to be user configurable, such as turning
 * it on and off with a system/session option, add it in the
 * getDrillUserConfigurableLogicalRules() method instead of here.
 *
 * @param optimizerRulesContext - shared state used during planning, currently used here
 *                                to gain access to the function registry described above.
 * @return - a RuleSet containing the logical rules that will always
 *           be used, either by VolcanoPlanner directly, or
 *           used VolcanoPlanner as pre-processing for LOPTPlanner.
 *
 * Note : Join permutation rule is excluded here.
 */
public static RuleSet getDrillBasicRules(OptimizerRulesContext optimizerRulesContext) {
  /*
   * We have to create another copy of the ruleset with the context dependent elements;
   * this cannot be reused across queries.
   */
  final ImmutableSet<RelOptRule> basicRules = ImmutableSet.<RelOptRule>builder()
      .addAll(staticRuleSet)
      .add(
          DrillMergeProjectRule.getInstance(true, RelFactories.DEFAULT_PROJECT_FACTORY,
              optimizerRulesContext.getFunctionRegistry()),

          PruneScanRule.getFilterOnProject(optimizerRulesContext),
          PruneScanRule.getFilterOnScan(optimizerRulesContext),
          ParquetPruneScanRule.getFilterOnProjectParquet(optimizerRulesContext),
          ParquetPruneScanRule.getFilterOnScanParquet(optimizerRulesContext)
          )
      .build();

  return new DrillRuleSet(basicRules);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:40,代码来源:DrillRuleSets.java


示例3: go

import org.apache.calcite.plan.RelOptRule; //导入依赖的package包/类
boolean go(T n, RelNode candidateSet) throws E {
  if ( !(candidateSet instanceof RelSubset) ) {
    return false;
  }

  boolean transform = false;
  for (RelNode rel : ((RelSubset)candidateSet).getRelList()) {
    if (isPhysical(rel)) {
      RelNode newRel = RelOptRule.convert(candidateSet, rel.getTraitSet().plus(Prel.DRILL_PHYSICAL));
      RelNode out = convertChild(n, newRel);
      if (out != null) {
        call.transformTo(out);
        transform = true;
      }
    }
  }


  return transform;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:21,代码来源:SubsetTransformer.java


示例4: go

import org.apache.calcite.plan.RelOptRule; //导入依赖的package包/类
boolean go(T n, RelNode candidateSet) throws E {
  if ( !(candidateSet instanceof RelSubset) ) {
    return false;
  }

  boolean transform = false;
  for (RelNode rel : ((RelSubset)candidateSet).getRelList()) {
    if (isPhysical(rel)) {
      RelNode newRel = RelOptRule.convert(candidateSet, rel.getTraitSet().plus(Prel.PHYSICAL).simplify());
      RelNode out = convertChild(n, newRel);
      if (out != null) {
        call.transformTo(out);
        transform = true;
      }
    }
  }


  return transform;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:21,代码来源:SubsetTransformer.java


示例5: getRules

import org.apache.calcite.plan.RelOptRule; //导入依赖的package包/类
@Override
public Set<RelOptRule> getRules(OptimizerRulesContext optimizerContext, PlannerPhase phase,
    StoragePluginType pluginType) {
  switch(phase){
  case LOGICAL:
    ImmutableSet.Builder<RelOptRule> builder = ImmutableSet.builder();
    builder.add(new HiveScanDrule(pluginType));
    builder.add(EliminateEmptyScans.INSTANCE);

    if(optimizerContext.getPlannerSettings().isPartitionPruningEnabled()){
      builder.add(new PruneScanRuleFilterOnProject<HiveScanDrel>(pluginType, HiveScanDrel.class, optimizerContext));
      builder.add(new PruneScanRuleFilterOnScan<HiveScanDrel>(pluginType, HiveScanDrel.class, optimizerContext));
    }

    return builder.build();

  case PHYSICAL:
    return ImmutableSet.<RelOptRule>of(
        new HiveScanPrule(pluginType)
        );

  default:
    return ImmutableSet.<RelOptRule>of();

  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:27,代码来源:HiveRulesFactory.java


示例6: run

import org.apache.calcite.plan.RelOptRule; //导入依赖的package包/类
public RelNode run(RelOptPlanner planner, RelNode rel,
                   RelTraitSet requiredOutputTraits,
                   List<RelOptMaterialization> materializations,
                   List<RelOptLattice> lattices) {
  planner.clear();
  for (RelOptRule rule : ruleSet) {
    planner.addRule(rule);
  }
  for (RelOptMaterialization materialization : materializations) {
    planner.addMaterialization(materialization);
  }
  for (RelOptLattice lattice : lattices) {
    planner.addLattice(lattice);
  }
  if (!rel.getTraitSet().equals(requiredOutputTraits)) {
    rel = planner.changeTraits(rel, requiredOutputTraits);
  }
  planner.setRoot(rel);
  return planner.findBestExp();

}
 
开发者ID:apache,项目名称:kylin,代码行数:22,代码来源:Programs.java


示例7: run

import org.apache.calcite.plan.RelOptRule; //导入依赖的package包/类
public RelNode run(RelOptPlanner planner, RelNode rel,
    RelTraitSet requiredOutputTraits,
    List<RelOptMaterialization> materializations,
    List<RelOptLattice> lattices) {
  planner.clear();
  for (RelOptRule rule : ruleSet) {
    planner.addRule(rule);
  }
  for (RelOptMaterialization materialization : materializations) {
    planner.addMaterialization(materialization);
  }
  for (RelOptLattice lattice : lattices) {
    planner.addLattice(lattice);
  }
  if (!rel.getTraitSet().equals(requiredOutputTraits)) {
    rel = planner.changeTraits(rel, requiredOutputTraits);
  }
  planner.setRoot(rel);
  return planner.findBestExp();

}
 
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:Programs.java


示例8: executeInstruction

import org.apache.calcite.plan.RelOptRule; //导入依赖的package包/类
void executeInstruction(
    HepInstruction.RuleClass<?> instruction) {
  if (skippingGroup()) {
    return;
  }
  LOGGER.trace("Applying rule class {}", instruction.ruleClass);
  if (instruction.ruleSet == null) {
    instruction.ruleSet = new LinkedHashSet<>();
    for (RelOptRule rule : allRules) {
      if (instruction.ruleClass.isInstance(rule)) {
        instruction.ruleSet.add(rule);
      }
    }
  }
  applyRules(instruction.ruleSet, true);
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:HepPlanner.java


示例9: depthFirstApply

import org.apache.calcite.plan.RelOptRule; //导入依赖的package包/类
private int depthFirstApply(Iterator<HepRelVertex> iter,
    Collection<RelOptRule> rules,
    boolean forceConversions, int nMatches) {
  while (iter.hasNext()) {
    HepRelVertex vertex = iter.next();
    for (RelOptRule rule : rules) {
      HepRelVertex newVertex =
          applyRule(rule, vertex, forceConversions);
      if (newVertex != null) {
        ++nMatches;
        if (nMatches >= currentProgram.matchLimit) {
          return nMatches;
        }

        // To the extent possible, pick up where we left
        // off; have to create a new iterator because old
        // one was invalidated by transformation.
        Iterator<HepRelVertex> depthIter = getGraphIterator(newVertex);
        nMatches = depthFirstApply(depthIter, rules, forceConversions,
            nMatches);
        break;
      }
    }
  }
  return nMatches;
}
 
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:HepPlanner.java


示例10: checkThatMaterialize

import org.apache.calcite.plan.RelOptRule; //导入依赖的package包/类
/** Checks that a given query can use a materialized view with a given
 * definition. */
private CalciteAssert.AssertQuery checkThatMaterialize(String materialize,
    String query, String name, boolean existing, String model,
    Function<ResultSet, Void> explainChecker, final RuleSet rules) {
  try (final TryThreadLocal.Memo ignored = Prepare.THREAD_TRIM.push(true)) {
    MaterializationService.setThreadLocal();
    CalciteAssert.AssertQuery that = CalciteAssert.that()
        .withMaterializations(model, existing, name, materialize)
        .query(query)
        .enableMaterializations(true);

    // Add any additional rules required for the test
    if (rules.iterator().hasNext()) {
      that.withHook(Hook.PLANNER, new Function<RelOptPlanner, Void>() {
        public Void apply(RelOptPlanner planner) {
          for (RelOptRule rule : rules) {
            planner.addRule(rule);
          }
          return null;
        }
      });
    }

    return that.explainMatches("", explainChecker);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:28,代码来源:MaterializationTest.java


示例11: testViewMaterialization

import org.apache.calcite.plan.RelOptRule; //导入依赖的package包/类
@Test public void testViewMaterialization() {
  checkThatMaterialize(
      "select \"depts\".\"name\"\n"
          + "from \"emps\"\n"
          + "join \"depts\" on (\"emps\".\"deptno\" = \"depts\".\"deptno\")",
      "select \"depts\".\"name\"\n"
          + "from \"depts\"\n"
          + "join \"emps\" on (\"emps\".\"deptno\" = \"depts\".\"deptno\")",
      "matview",
      true,
      HR_FKUK_MODEL,
      CalciteAssert.checkResultContains(
          "EnumerableValues(tuples=[[{ 'noname' }]])"),
      RuleSets.ofList(ImmutableList.<RelOptRule>of()))
      .returnsValue("noname");
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:MaterializationTest.java


示例12: checkEvent

import org.apache.calcite.plan.RelOptRule; //导入依赖的package包/类
private void checkEvent(
    List<RelOptListener.RelEvent> eventList,
    int iEvent,
    Class expectedEventClass,
    RelNode expectedRel,
    Class<? extends RelOptRule> expectedRuleClass) {
  assertTrue(iEvent < eventList.size());
  RelOptListener.RelEvent event = eventList.get(iEvent);
  assertSame(
      expectedEventClass,
      event.getClass());
  if (expectedRel != null) {
    assertSame(
        expectedRel,
        event.getRel());
  }
  if (expectedRuleClass != null) {
    RelOptListener.RuleEvent ruleEvent =
        (RelOptListener.RuleEvent) event;
    assertSame(
        expectedRuleClass,
        ruleEvent.getRuleCall().getRule().getClass());
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:VolcanoPlannerTest.java


示例13: mergedRuleSets

import org.apache.calcite.plan.RelOptRule; //导入依赖的package包/类
public static RuleSet mergedRuleSets(RuleSet...ruleSets) {
  final Builder<RelOptRule> relOptRuleSetBuilder = ImmutableSet.builder();
  for (final RuleSet ruleSet : ruleSets) {
    for (final RelOptRule relOptRule : ruleSet) {
      relOptRuleSetBuilder.add(relOptRule);
    }
  }
  return new DrillRuleSet(relOptRuleSetBuilder.build());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:10,代码来源:DrillRuleSets.java


示例14: convert

import org.apache.calcite.plan.RelOptRule; //导入依赖的package包/类
public static RelNode convert(RelNode rel, RelTraitSet toTraits){
  toTraits = toTraits.simplify();

  PlannerSettings settings = PrelUtil.getSettings(rel.getCluster());
  if(settings.isSingleMode()){
    toTraits = toTraits.replace(DrillDistributionTrait.ANY);
  }

  return RelOptRule.convert(rel, toTraits);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:11,代码来源:Prule.java


示例15: getStoragePluginRuleSet

import org.apache.calcite.plan.RelOptRule; //导入依赖的package包/类
public RuleSet getStoragePluginRuleSet(OptimizerRulesContext optimizerRulesContext) {
  // query registered engines for optimizer rules and build the storage plugin RuleSet
  Builder<RelOptRule> setBuilder = ImmutableSet.builder();
  for (StoragePlugin plugin : this.plugins.values()) {
    Set<? extends RelOptRule> rules = plugin.getOptimizerRules(optimizerRulesContext);
    if (rules != null && rules.size() > 0) {
      setBuilder.addAll(rules);
    }
  }

  return DrillRuleSets.create(setBuilder.build());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:13,代码来源:StoragePluginRegistry.java


示例16: DrillJdbcConvention

import org.apache.calcite.plan.RelOptRule; //导入依赖的package包/类
public DrillJdbcConvention(SqlDialect dialect, String name) {
  super(dialect, ConstantUntypedNull.INSTANCE, name);


  // build rules for this convention.
  ImmutableSet.Builder<RelOptRule> builder = ImmutableSet.builder();

  builder.add(JDBC_PRULE_INSTANCE);
  builder.add(new JdbcDrelConverterRule(this));
  builder.add(new DrillJdbcProjectRule(this));
  builder.add(new DrillJdbcFilterRule(this));

  outside: for (RelOptRule rule : JdbcRules.rules(this)) {
    final String description = rule.toString();

    // we want to black list some rules but the parent Calcite package is all or none.
    // Therefore, we remove rules with names we don't like.
    for(String black : RULES_TO_AVOID){
      if(description.equals(black)){
        continue outside;
      }

    }

    builder.add(rule);
  }

  builder.add(FilterSetOpTransposeRule.INSTANCE);
  builder.add(ProjectRemoveRule.INSTANCE);

  rules = builder.build();
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:33,代码来源:JdbcStoragePlugin.java


示例17: createProject

import org.apache.calcite.plan.RelOptRule; //导入依赖的package包/类
@Override
public RelNode createProject(RelNode child,
                             List<? extends RexNode> childExprs, List<String> fieldNames) {
  final RelOptCluster cluster = child.getCluster();
  final RelDataType rowType = RexUtil.createStructType(cluster.getTypeFactory(), childExprs, fieldNames, SqlValidatorUtil.F_SUGGESTER);
  final RelNode project = ProjectRel.create(
      cluster,
      child.getTraitSet().plus(Rel.LOGICAL),
      RelOptRule.convert(child, child.getTraitSet().plus(Rel.LOGICAL).simplify()),
      childExprs,
      rowType);

  return project;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:15,代码来源:DremioRelFactories.java


示例18: createJoin

import org.apache.calcite.plan.RelOptRule; //导入依赖的package包/类
@Override
public RelNode createJoin(RelNode left, RelNode right,
                          RexNode condition,
                          Set<CorrelationId> variablesSet,
                          JoinRelType joinType, boolean semiJoinDone) {
  return new JoinRel(
      left.getCluster(),
      left.getTraitSet().plus(Rel.LOGICAL),
      RelOptRule.convert(left, left.getTraitSet().plus(Rel.LOGICAL).simplify()),
      RelOptRule.convert(right, right.getTraitSet().plus(Rel.LOGICAL).simplify()),
      condition,
      joinType);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:14,代码来源:DremioRelFactories.java


示例19: convert

import org.apache.calcite.plan.RelOptRule; //导入依赖的package包/类
public static RelNode convert(RelNode rel, RelTraitSet toTraits){
  toTraits = toTraits.simplify();

  PlannerSettings settings = PrelUtil.getSettings(rel.getCluster());
  if(settings.isSingleMode()){
    toTraits = toTraits.replace(DistributionTrait.ANY);
  }

  return RelOptRule.convert(rel, toTraits.simplify());
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:11,代码来源:Prule.java


示例20: getRules

import org.apache.calcite.plan.RelOptRule; //导入依赖的package包/类
@Override
public Set<RelOptRule> getRules(OptimizerRulesContext optimizerContext, PlannerPhase phase, StoragePluginType pluginType) {

  switch(phase){
    case LOGICAL:
      ImmutableSet.Builder<RelOptRule> builder = ImmutableSet.builder();
      builder.add(new FileSystemDrule(pluginType));

      if(optimizerContext.getPlannerSettings().isPartitionPruningEnabled()){
        builder.add(new PruneScanRuleFilterOnProject<FilesystemScanDrel>(pluginType, FilesystemScanDrel.class, optimizerContext));
        builder.add(new PruneScanRuleFilterOnScan<FilesystemScanDrel>(pluginType, FilesystemScanDrel.class, optimizerContext));
      }

      return builder.build();

    case PHYSICAL:
      return ImmutableSet.<RelOptRule>of(
          new EasyFilesystemScanPrule(pluginType),
          new ParquetFilesystemScanPrule(pluginType),
          ConvertCountToDirectScan.getAggOnScan(pluginType),
          ConvertCountToDirectScan.getAggProjOnScan(pluginType)
          );

    default:
      return ImmutableSet.<RelOptRule>of();

  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:29,代码来源:FileSystemRulesFactory.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java EObjectDescription类代码示例发布时间:2022-05-21
下一篇:
Java PEMDecryptorProvider类代码示例发布时间: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