本文整理汇总了Java中org.apache.calcite.plan.volcano.RelSubset类的典型用法代码示例。如果您正苦于以下问题:Java RelSubset类的具体用法?Java RelSubset怎么用?Java RelSubset使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RelSubset类属于org.apache.calcite.plan.volcano包,在下文中一共展示了RelSubset类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
});
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}