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


Java RelNode.accept方法代码示例

本文整理汇总了Java中org.apache.calcite.rel.RelNode.accept方法的典型用法代码示例。如果您正苦于以下问题:Java RelNode.accept方法的具体用法?Java RelNode.accept怎么用?Java RelNode.accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.calcite.rel.RelNode的用法示例。


在下文中一共展示了RelNode.accept方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertToRel

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
private RelNode convertToRel(SqlNode node) throws RelConversionException {
  final RelNode convertedNode = planner.convert(node);

  final RelMetadataProvider provider = convertedNode.getCluster().getMetadataProvider();

  // Register RelMetadataProvider with HepPlanner.
  final List<RelMetadataProvider> list = Lists.newArrayList(provider);
  hepPlanner.registerMetadataProviders(list);
  final RelMetadataProvider cachingMetaDataProvider = new CachingRelMetadataProvider(ChainedRelMetadataProvider.of(list), hepPlanner);
  convertedNode.accept(new MetaDataProviderModifier(cachingMetaDataProvider));

  // HepPlanner is specifically used for Window Function planning only.
  hepPlanner.setRoot(convertedNode);
  RelNode rel = hepPlanner.findBestExp();

  rel.accept(new MetaDataProviderModifier(provider));
  return rel;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:19,代码来源:DefaultSqlHandler.java

示例2: preprocessNode

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
private RelNode preprocessNode(RelNode rel) throws SqlUnsupportedException {
  /*
   * Traverse the tree to do the following pre-processing tasks: 1. replace the convert_from, convert_to function to
   * actual implementations Eg: convert_from(EXPR, 'JSON') be converted to convert_fromjson(EXPR); TODO: Ideally all
   * function rewrites would move here instead of DrillOptiq.
   *
   * 2. see where the tree contains unsupported functions; throw SqlUnsupportedException if there is any.
   */

  PreProcessLogicalRel visitor = PreProcessLogicalRel.createVisitor(planner.getTypeFactory(),
      context.getDrillOperatorTable());
  try {
    rel = rel.accept(visitor);
  } catch (UnsupportedOperationException ex) {
    visitor.convertException();
    throw ex;
  }

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

示例3: getStack

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
public static List<ElasticsearchPrel> getStack(RelNode rel){
  rel = rel.accept(new MoreRelOptUtil.SubsetRemover(false));
  List<ElasticsearchPrel> stack = new ArrayList<>();
  outside: while(rel != null){
    if( !(rel instanceof ElasticsearchPrel) ){
      throw new IllegalStateException("Stack should only include ElasticPrels, but actually included " + rel.getClass().getName());
    }
    stack.add((ElasticsearchPrel) rel);
    List<RelNode> nodes = rel.getInputs();
    switch(nodes.size()){
    case 0:
      break outside;
    case 1:
      rel = nodes.get(0);
      break;
    default:
      throw new IllegalStateException("Elastic rels should be single input or no input.");
    }
  }

  return ImmutableList.copyOf(stack);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:StackFinder.java

示例4: findRefreshField

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
public static String findRefreshField(RelNode plan, final NamespaceService namespaceService) {
  final Pointer<String> refreshField = new Pointer<>();
  plan.accept(new StatelessRelShuttleImpl() {
    @Override
    public RelNode visit(TableScan tableScan) {
      List<String> tablePath = tableScan.getTable().getQualifiedName();
      try {
        String field = namespaceService.getDataset(new NamespaceKey(tablePath)).getPhysicalDataset().getAccelerationSettings().getRefreshField();
        refreshField.value = field;
      } catch (NamespaceException e) {
        throw new RuntimeException(e);
      }
      return tableScan;
    }
  });
  return refreshField.value;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:18,代码来源:IncrementalUpdateUtils.java

示例5: visit

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
public boolean visit(final RelNode node) {
  for (RelNode input : node.getInputs()) {
    if (visit(input)) {
      return true;
    }
  }

  if (node.getConvention() instanceof JdbcConventionIndicator) {
    return false;
  }

  final RexSubQueryFinder subQueryFinder = new RexSubQueryFinder();
  node.accept(subQueryFinder);
  if (subQueryFinder.getFoundSubQuery()) {
    return true;
  }
  return false;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:19,代码来源:RexSubQueryUtils.java

示例6: getLoptJoinOrderTree

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
/**
 * Appy Join Order Optimizations using Hep Planner.
 */
private RelNode getLoptJoinOrderTree(RelNode root,
                                    Class<? extends Join> joinClass,
                                           RelFactories.JoinFactory joinFactory,
                                           RelFactories.FilterFactory filterFactory,
                                           RelFactories.ProjectFactory projectFactory) {
  final HepProgramBuilder hepPgmBldr = new HepProgramBuilder()
      .addMatchOrder(HepMatchOrder.BOTTOM_UP)
      .addRuleInstance(new JoinToMultiJoinRule(joinClass))
      .addRuleInstance(new LoptOptimizeJoinRule(joinFactory, projectFactory, filterFactory))
      .addRuleInstance(ProjectRemoveRule.INSTANCE);
      // .addRuleInstance(new ProjectMergeRule(true, projectFactory));

      // .addRuleInstance(DrillMergeProjectRule.getInstance(true, projectFactory, this.context.getFunctionRegistry()));


  final HepProgram hepPgm = hepPgmBldr.build();
  final HepPlanner hepPlanner = new HepPlanner(hepPgm);

  final List<RelMetadataProvider> list = Lists.newArrayList();
  list.add(DrillDefaultRelMetadataProvider.INSTANCE);
  hepPlanner.registerMetadataProviders(list);
  final RelMetadataProvider cachingMetaDataProvider = new CachingRelMetadataProvider(ChainedRelMetadataProvider.of(list), hepPlanner);

  // Modify RelMetaProvider for every RelNode in the SQL operator Rel tree.
  root.accept(new MetaDataProviderModifier(cachingMetaDataProvider));

  hepPlanner.setRoot(root);

  RelNode calciteOptimizedPlan = hepPlanner.findBestExp();

  return calciteOptimizedPlan;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:36,代码来源:DefaultSqlHandler.java

示例7: visitChild

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
@Override
protected RelNode visitChild(RelNode parent, int i, RelNode child) {
  RelNode child2 = child.accept(this);
  if (child2 != child) {
    final List<RelNode> newInputs = new ArrayList<>(parent.getInputs());
    newInputs.set(i, child2);
    return parent.copy(parent.getTraitSet(), newInputs);
  }
  return parent;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:11,代码来源:StatelessRelShuttleImpl.java

示例8: convertRelSubsets

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
private RelNode convertRelSubsets(RelNode root) {
  return root.accept(new RoutingShuttle() {
    @Override
    public RelNode visit(RelNode other) {
      if (other instanceof RelSubset) {
        return visit(((RelSubset) other).getBest());
      }
      return super.visit(other);
    }
  });
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:12,代码来源:CheapestPlanWithReflectionVisitor.java

示例9: testDistributionInPlan

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
@Test
public void testDistributionInPlan() {
  String query = String.format("create table %s.\"%s\" hash partition by (\"position\") as select \"position\", isFte, " +
    "count(rating) as \"agg-7-0\", " +
    "sum(rating) as \"agg-7-1\", " +
    "min(rating) as \"agg-7-2\", " +
    "max(rating) as \"agg-7-3\", " +
    "count(1) as convert_count_star " +
    "from cp.acceleration.\"employees.json\" " +
    "group by \"position\", isFte", DFS_TEST_PLUGIN_NAME, "hashDistribute");
  final RelNode physical = getPlan(query);

  final AtomicBoolean hashDistributedWriter = new AtomicBoolean(false);
  physical.accept(new StatelessRelShuttleImpl() {

    @Override
    public RelNode visit(final RelNode other) {
      if (other instanceof WriterPrel) {
        for (RelTrait trait : other.getTraitSet()) {
          if (trait instanceof DistributionTrait) {
            List<DistributionField> distributionFieldList = ((DistributionTrait) trait).getFields();
            if (distributionFieldList.size() != 1) {
              continue;
            }
            int fieldId = distributionFieldList.get(0).getFieldId();
            String fieldName = ((WriterPrel) other).getInput().getRowType().getFieldNames().get(fieldId);
            if ("position".equals(fieldName)) {
              hashDistributedWriter.set(true);
            }
          }
        }
      }
      return super.visit(other);
    }
  });

  Assert.assertTrue("Physical plan must have a HashExchange", hashDistributedWriter.get());
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:39,代码来源:TestWriter.java

示例10: visitSubQuery

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
@Override
public RexNode visitSubQuery(RexSubQuery subQuery) {
  RelNode transformed;
  try {
    final RelNode convertedSubquery = subQuery.rel.accept(new InjectSampleAndJdbcLogical(false, true));
    transformed = PrelTransformer.transform(config, PlannerType.VOLCANO, PlannerPhase.JDBC_PUSHDOWN, convertedSubquery, traitSet, false);

    // We may need to run the planner again on the sub-queries in the sub-tree this produced.
    transformed = transformed.accept(new RelsWithRexSubQueryTransformer(config));
  } catch (Throwable t) {
    failed = true;
    return subQuery;
  }
  return subQuery.clone(transformed);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:16,代码来源:RexSubQueryUtils.java

示例11: visitChild

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
@Override
protected RelNode visitChild(RelNode parent, int i, RelNode child) {
  if(!predicate.apply(parent)){
    return child.accept(this);
  }

  return super.visitChild(parent, i, child);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:9,代码来源:MoreRelOptUtil.java

示例12: containsLimit0

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
public static boolean containsLimit0(RelNode rel) {
  FindLimit0Visitor visitor = new FindLimit0Visitor();
  rel.accept(visitor);
  return visitor.isContains();
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:6,代码来源:FindLimit0Visitor.java

示例13: newAttempt

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
@Override
public AttemptObserver newAttempt(AttemptId attemptId, AttemptReason reason) {
  return new AbstractAttemptObserver() {
    @Override
    public void execDataArrived(RpcOutcomeListener<Ack> outcomeListener, QueryWritableBatch result) {
      try {
        AutoCloseables.close(
        FluentIterable.of(result.getBuffers()).transform(new Function<ByteBuf, AutoCloseable>(){
          @Override
          public AutoCloseable apply(ByteBuf input) {
            return new CloseableByteBuf(input);
          }}).toList());
      } catch (Exception e) {
        exception.addException(e);
      }
      outcomeListener.success(Acks.OK, null);
    }

    @Override
    public void planRelTransform(PlannerPhase phase, RelOptPlanner planner, RelNode before, RelNode after, long millisTaken) {
      if (phase == PlannerPhase.PHYSICAL) {
        if (checkPlanWriterDistribution) {
          // Visit the tree and check that all the WriterCommitter is a singleton and its input is also singleton
          // We check here in PHYSCIAL right before the visitors in convertToPrel since convertToPrel might get rid of unnecessary exchanges
          after.accept(new StatelessRelShuttleImpl() {
            @Override
            public RelNode visit(RelNode other) {
              if (other instanceof WriterCommitterPrel) {
                if ( (other.getTraitSet().getTrait(DistributionTraitDef.INSTANCE) != DistributionTrait.SINGLETON)
                  || ((WriterCommitterPrel) other).getInput().getTraitSet().getTrait(DistributionTraitDef.INSTANCE) != DistributionTrait.SINGLETON) {
                  exception.addException(new IllegalStateException(other + "(" + other.getTraitSet()+ ") and/or its child "
                    + ((WriterCommitterPrel) other).getInput() + "(" + ((WriterCommitterPrel) other).getInput().getTraitSet() + ") are not SINGLETON"));
                }
              }
              return visitChildren(other);
            }
          });
        }
      }
    }
  };
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:43,代码来源:TestStoreQueryResults.java

示例14: uniqifyGraph

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
public static RelNode uniqifyGraph(RelNode rel) {
  CrelUniqifier u = new CrelUniqifier();
  return rel.accept(u);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:5,代码来源:CrelUniqifier.java

示例15: expand

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
public Optional<DremioRelOptMaterialization> expand(MaterializationDescriptor descriptor) {

    final RelNode deserializedPlan = deserializePlan(descriptor.getPlan());

    RelNode queryRel = deserializedPlan.accept(ScanConverter.INSTANCE);

    // for incremental update, we need to rewrite the queryRel so that it propogates the UPDATE_COLUMN and
    // adds it as a grouping key in aggregates
    if (descriptor.getIncrementalUpdateSettings().isIncremental()) {
      RelShuttle shuttle;
      if (descriptor.getIncrementalUpdateSettings().getUpdateField() == null) {
        shuttle = IncrementalUpdateUtils.FILE_BASED_SUBSTITUTION_SHUTTLE;
      } else {
        shuttle = new SubstitutionShuttle(descriptor.getIncrementalUpdateSettings().getUpdateField());
      }
      queryRel = queryRel.accept(shuttle);
    }


    RelNode tableRel = expandSchemaPath(descriptor.getPath());

    if (tableRel == null) {
      return Optional.absent();
    }

    BatchSchema schema = ((ScanCrel) tableRel).getBatchSchema();

    tableRel = tableRel.accept(ScanConverter.INSTANCE);
    tableRel = tableRel.accept(new IncrementalUpdateUtils.RemoveDirColumn(queryRel.getRowType()));

    // Namespace table removes UPDATE_COLUMN from scans, but for incremental materializations, we need to add it back
    // to the table scan
    if (descriptor.getIncrementalUpdateSettings().isIncremental()) {
      tableRel = tableRel.accept(IncrementalUpdateUtils.ADD_MOD_TIME_SHUTTLE);
    }

    // Check that the table rel row type matches that of the query rel,
    // if so, cast the table rel row types to the query rel row types.
    tableRel = MoreRelOptUtil.createCastRel(tableRel, queryRel.getRowType());

    return Optional.of(new DremioRelOptMaterialization(
      tableRel,
      queryRel,
      descriptor.getIncrementalUpdateSettings(),
      descriptor.getLayoutInfo(),
      descriptor.getMaterializationId(),
      schema,
      descriptor.getExpirationTimestamp()
    ));
  }
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:51,代码来源:MaterializationExpander.java


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