当前位置: 首页>>代码示例>>Java>>正文


Java RelOptRule类代码示例

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


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


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