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

Java RelSubset类代码示例

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

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



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

示例1: go

import org.apache.calcite.plan.volcano.RelSubset; //导入依赖的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


示例2: isScalarSubquery

import org.apache.calcite.plan.volcano.RelSubset; //导入依赖的package包/类
/**
 * Utility method to check if a subquery (represented by its root RelNode) is provably scalar. Currently
 * only aggregates with no group-by are considered scalar. In the future, this method should be generalized
 * to include more cases and reconciled with Calcite's notion of scalar.
 * @param root The root RelNode to be examined
 * @return True if the root rel or its descendant is scalar, False otherwise
 */
public static boolean isScalarSubquery(RelNode root) {
  DrillAggregateRel agg = null;
  RelNode currentrel = root;
  while (agg == null && currentrel != null) {
    if (currentrel instanceof DrillAggregateRel) {
      agg = (DrillAggregateRel)currentrel;
    } else if (currentrel instanceof RelSubset) {
      currentrel = ((RelSubset)currentrel).getBest() ;
    } else if (currentrel.getInputs().size() == 1) {
      // If the rel is not an aggregate or RelSubset, but is a single-input rel (could be Project,
      // Filter, Sort etc.), check its input
      currentrel = currentrel.getInput(0);
    } else {
      break;
    }
  }

  if (agg != null) {
    if (agg.getGroupSet().isEmpty()) {
      return true;
    }
  }
  return false;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:32,代码来源:JoinUtils.java


示例3: go

import org.apache.calcite.plan.volcano.RelSubset; //导入依赖的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


示例4: isScalarSubquery

import org.apache.calcite.plan.volcano.RelSubset; //导入依赖的package包/类
/**
 * Utility method to check if a subquery (represented by its root RelNode) is provably scalar. Currently
 * only aggregates with no group-by are considered scalar. In the future, this method should be generalized
 * to include more cases and reconciled with Calcite's notion of scalar.
 * @param root The root RelNode to be examined
 * @return True if the root rel or its descendant is scalar, False otherwise
 */
public static boolean isScalarSubquery(RelNode root) {
  AggregateRel agg = null;
  RelNode currentrel = root;
  while (agg == null && currentrel != null) {
    if (currentrel instanceof AggregateRel) {
      agg = (AggregateRel)currentrel;
    } else if (currentrel instanceof RelSubset) {
      currentrel = ((RelSubset)currentrel).getBest() ;
    } else if (currentrel.getInputs().size() == 1) {
      // If the rel is not an aggregate or RelSubset, but is a single-input rel (could be Project,
      // Filter, Sort etc.), check its input
      currentrel = currentrel.getInput(0);
    } else {
      break;
    }
  }

  if (agg != null) {
    if (agg.getGroupSet().isEmpty()) {
      return true;
    }
  }
  return false;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:32,代码来源:JoinUtils.java


示例5: getDistinctRowCount

import org.apache.calcite.plan.volcano.RelSubset; //导入依赖的package包/类
public Double getDistinctRowCount(RelSubset rel, RelMetadataQuery mq,
    ImmutableBitSet groupKey, RexNode predicate) {
  final RelNode best = rel.getBest();
  if (best != null) {
    return mq.getDistinctRowCount(best, groupKey, predicate);
  }
  if (!Bug.CALCITE_1048_FIXED) {
    return getDistinctRowCount((RelNode) rel, mq, groupKey, predicate);
  }
  Double d = null;
  for (RelNode r2 : rel.getRels()) {
    try {
      Double d2 = mq.getDistinctRowCount(r2, groupKey, predicate);
      d = NumberUtil.min(d, d2);
    } catch (CyclicMetadataException e) {
      // Ignore this relational expression; there will be non-cyclic ones
      // in this set.
    }
  }
  return d;
}
 
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:RelMdDistinctRowCount.java


示例6: areColumnsUnique

import org.apache.calcite.plan.volcano.RelSubset; //导入依赖的package包/类
public Boolean areColumnsUnique(RelSubset rel, RelMetadataQuery mq,
    ImmutableBitSet columns, boolean ignoreNulls) {
  int nullCount = 0;
  for (RelNode rel2 : rel.getRels()) {
    if (rel2 instanceof Aggregate
        || rel2 instanceof Filter
        || rel2 instanceof Values
        || rel2 instanceof TableScan
        || simplyProjects(rel2, columns)) {
      try {
        final Boolean unique = mq.areColumnsUnique(rel2, columns, ignoreNulls);
        if (unique != null) {
          if (unique) {
            return true;
          }
        } else {
          ++nullCount;
        }
      } catch (CyclicMetadataException e) {
        // Ignore this relational expression; there will be non-cyclic ones
        // in this set.
      }
    }
  }
  return nullCount == 0 ? false : null;
}
 
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:RelMdColumnUniqueness.java


示例7: getPredicates

import org.apache.calcite.plan.volcano.RelSubset; //导入依赖的package包/类
/** @see RelMetadataQuery#getPulledUpPredicates(RelNode) */
public RelOptPredicateList getPredicates(RelSubset r,
    RelMetadataQuery mq) {
  if (!Bug.CALCITE_1048_FIXED) {
    return RelOptPredicateList.EMPTY;
  }
  final RexBuilder rexBuilder = r.getCluster().getRexBuilder();
  RelOptPredicateList list = null;
  for (RelNode r2 : r.getRels()) {
    RelOptPredicateList list2 = mq.getPulledUpPredicates(r2);
    if (list2 != null) {
      list = list == null ? list2 : list.union(rexBuilder, list2);
    }
  }
  return Util.first(list, RelOptPredicateList.EMPTY);
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:RelMdPredicates.java


示例8: visit

import org.apache.calcite.plan.volcano.RelSubset; //导入依赖的package包/类
@Override
public RelNode visit(RelNode other) {
  if (other instanceof RelSubset) {
    return ((RelSubset) other).getBest().accept(this);
  } else {
    return super.visit(other);
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:9,代码来源:JdbcPrel.java


示例9: convertRelSubsets

import org.apache.calcite.plan.volcano.RelSubset; //导入依赖的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


示例10: canConvert

import org.apache.calcite.plan.volcano.RelSubset; //导入依赖的package包/类
@Override
public boolean canConvert(
    RelOptPlanner planner, DistributionTrait fromTrait, DistributionTrait toTrait, RelNode fromRel) {
  if (fromTrait.equals(toTrait)) {
    return true;
  }

  // Source trait is "ANY", which is abstract type of distribution.
  // We do not want to convert from "ANY", since it's abstract.
  // Source trait should be concrete type: SINGLETON, HASH_DISTRIBUTED, etc.
  if (fromTrait.equals(DistributionTrait.DEFAULT) && !(fromRel instanceof RelSubset) ) {
    return false;
  }

  // It is only possible to apply a distribution trait to a PHYSICAL convention.
  if (fromRel.getConvention() != Prel.PHYSICAL) {
    return false;
  }

  if (fromTrait.getType() == DistributionType.HASH_DISTRIBUTED && toTrait.getType() == DistributionType.BROADCAST_DISTRIBUTED) {
    return false;
  }
  if (fromTrait.getType() == DistributionType.BROADCAST_DISTRIBUTED && toTrait.getType() == DistributionType.HASH_DISTRIBUTED) {
    return false;
  }

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


示例11: getDepth

import org.apache.calcite.plan.volcano.RelSubset; //导入依赖的package包/类
/**
 * Computes the height of the rel tree under the input rel node.
 * @param rel RelNode to compute the minimum height of the tree underneath it
 * @return minimum height of the tree under the input rel node
 */
public static int getDepth(RelNode rel) {
  if (rel == null) {
    return 0;
  }
  if (rel instanceof RelSubset) {
    RelSubset subset = (RelSubset) rel;
    return getDepth(subset.getBest());
  }

  if (rel.getInputs() == null || rel.getInputs().size() == 0) {
    return 1;
  }

  int minDepth = Integer.MAX_VALUE;
  for (RelNode node : rel.getInputs()) {
    int nodeDepth = getDepth(node);
    if (nodeDepth > 0) {
      minDepth = Math.min(nodeDepth, minDepth);
    }
  }

  if (minDepth == Integer.MAX_VALUE) {
    return 0;
  }

  return minDepth + 1;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:33,代码来源:MoreRelOptUtil.java


示例12: visit

import org.apache.calcite.plan.volcano.RelSubset; //导入依赖的package包/类
@Override
public RelNode visit(RelNode other) {
  if (other instanceof RelSubset) {
    if (((RelSubset) other).getBest() != null) {
      return ((RelSubset) other).getBest().accept(this);
    }
    if (!needBest && ((RelSubset) other).getRelList().size() == 1) {
      return ((RelSubset) other).getRelList().get(0).accept(this);
    }
    throw UserException.unsupportedError().message("SubsetRemover: found null best, parent " + other).build(logger);
  } else {
    return super.visit(other);
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:15,代码来源:MoreRelOptUtil.java


示例13: getBeamRelInput

import org.apache.calcite.plan.volcano.RelSubset; //导入依赖的package包/类
public static BeamRelNode getBeamRelInput(RelNode input) {
  if (input instanceof RelSubset) {
    // go with known best input
    input = ((RelSubset) input).getBest();
  }
  return (BeamRelNode) input;
}
 
开发者ID:apache,项目名称:beam,代码行数:8,代码来源:BeamSqlRelUtils.java


示例14: go

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

  boolean transform = false;
  Set<RelNode> transformedRels = Sets.newIdentityHashSet();
  Set<RelTraitSet> traitSets = Sets.newHashSet();

  //1, get all the target traitsets from candidateSet's rel list,
  for (RelNode rel : ((RelSubset)candidateSet).getRelList()) {
    if (isPhysical(rel)) {
      final RelTraitSet relTraitSet = rel.getTraitSet();
      if ( !traitSets.contains(relTraitSet) ) {
        traitSets.add(relTraitSet);
        logger.trace("{}.convertChild get traitSet {}", this.getClass().getSimpleName(), relTraitSet);
      }
    }
  }

  //2, convert the candidateSet to targeted taitSets
  for (RelTraitSet traitSet: traitSets) {
    RelNode newRel = RelOptRule.convert(candidateSet, traitSet);
    if(transformedRels.contains(newRel)) {
      continue;
    }
    transformedRels.add(newRel);

    logger.trace("{}.convertChild to convert NODE {} ,AND {}", this.getClass().getSimpleName(), n, newRel);
    RelNode out = convertChild(n, newRel);

    //RelNode out = convertChild(n, rel);
    if (out != null) {
      call.transformTo(out);
      transform = true;
    }
  }

  return transform;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:41,代码来源:SubsetTransformer.java


示例15: shouldIntercept

import org.apache.calcite.plan.volcano.RelSubset; //导入依赖的package包/类
private boolean shouldIntercept(RelNode rel) {
    for (RelNode input : rel.getInputs()) {
        if (input instanceof RelSubset) {
            RelSubset relSubset = (RelSubset) input;
            if (relSubset.getBest() != null
                    && relSubset.getBest().getClass().getCanonicalName().endsWith("OLAPToEnumerableConverter")) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:kylin,代码行数:13,代码来源:OLAPRelMdRowCount.java


示例16: getRowCount

import org.apache.calcite.plan.volcano.RelSubset; //导入依赖的package包/类
@Override
public Double getRowCount(RelSubset subset, RelMetadataQuery mq) {
    if (shouldIntercept(subset))
        return 1E10;

    return super.getRowCount(subset, mq);
}
 
开发者ID:apache,项目名称:kylin,代码行数:8,代码来源:OLAPRelMdRowCount.java


示例17: getMaxRowCount

import org.apache.calcite.plan.volcano.RelSubset; //导入依赖的package包/类
public Double getMaxRowCount(RelSubset rel, RelMetadataQuery mq) {
  // FIXME This is a short-term fix for [CALCITE-1018]. A complete
  // solution will come with [CALCITE-1048].
  Util.discard(Bug.CALCITE_1048_FIXED);
  for (RelNode node : rel.getRels()) {
    if (node instanceof Sort) {
      Sort sort = (Sort) node;
      if (sort.fetch != null) {
        return (double) RexLiteral.intValue(sort.fetch);
      }
    }
  }

  return Double.POSITIVE_INFINITY;
}
 
开发者ID:apache,项目名称:calcite,代码行数:16,代码来源:RelMdMaxRowCount.java


示例18: getMinRowCount

import org.apache.calcite.plan.volcano.RelSubset; //导入依赖的package包/类
public Double getMinRowCount(RelSubset rel, RelMetadataQuery mq) {
  // FIXME This is a short-term fix for [CALCITE-1018]. A complete
  // solution will come with [CALCITE-1048].
  Util.discard(Bug.CALCITE_1048_FIXED);
  for (RelNode node : rel.getRels()) {
    if (node instanceof Sort) {
      Sort sort = (Sort) node;
      if (sort.fetch != null) {
        return (double) RexLiteral.intValue(sort.fetch);
      }
    }
  }

  return 0D;
}
 
开发者ID:apache,项目名称:calcite,代码行数:16,代码来源:RelMdMinRowCount.java


示例19: JoinAssociateRule

import org.apache.calcite.plan.volcano.RelSubset; //导入依赖的package包/类
/**
 * Creates a JoinAssociateRule.
 */
public JoinAssociateRule(RelBuilderFactory relBuilderFactory) {
  super(
      operand(Join.class,
          operand(Join.class, any()),
          operand(RelSubset.class, any())),
      relBuilderFactory, null);
}
 
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:JoinAssociateRule.java


示例20: convert

import org.apache.calcite.plan.volcano.RelSubset; //导入依赖的package包/类
@Override
public RelNode convert(
    RelOptPlanner planner,
    RelNode rel,
    DrillDistributionTrait toDist,
    boolean allowInfiniteCostConverters) {

  DrillDistributionTrait currentDist = rel.getTraitSet().getTrait(DrillDistributionTraitDef.INSTANCE);

  // Source and Target have the same trait.
  if (currentDist.equals(toDist)) {
    return rel;
  }

  // Source trait is "ANY", which is abstract type of distribution.
  // We do not want to convert from "ANY", since it's abstract.
  // Source trait should be concrete type: SINGLETON, HASH_DISTRIBUTED, etc.
  if (currentDist.equals(DrillDistributionTrait.DEFAULT) && !(rel instanceof RelSubset) ) {
      return null;
  }

  // It is only possible to apply a distribution trait to a DRILL_PHYSICAL convention.
  if (rel.getConvention() != Prel.DRILL_PHYSICAL) {
    return null;
  }

  switch(toDist.getType()){
    // UnionExchange, HashToRandomExchange, OrderedPartitionExchange and BroadcastExchange destroy the ordering property,
    // therefore RelCollation is set to default, which is EMPTY.
    case SINGLETON:
      return new UnionExchangePrel(rel.getCluster(), planner.emptyTraitSet().plus(Prel.DRILL_PHYSICAL).plus(toDist), rel);
    case HASH_DISTRIBUTED:
      return new HashToRandomExchangePrel(rel.getCluster(), planner.emptyTraitSet().plus(Prel.DRILL_PHYSICAL).plus(toDist), rel,
                                           toDist.getFields());
    case RANGE_DISTRIBUTED:
      return new OrderedPartitionExchangePrel(rel.getCluster(), planner.emptyTraitSet().plus(Prel.DRILL_PHYSICAL).plus(toDist), rel);
    case BROADCAST_DISTRIBUTED:
      return new BroadcastExchangePrel(rel.getCluster(), planner.emptyTraitSet().plus(Prel.DRILL_PHYSICAL).plus(toDist), rel);
    case ANY:
      // If target is "any", any input would satisfy "any". Return input directly.
      return rel;
    default:
      return null;
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:46,代码来源:DrillDistributionTraitDef.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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