本文整理汇总了Java中org.apache.calcite.rel.RelNode.getInputs方法的典型用法代码示例。如果您正苦于以下问题:Java RelNode.getInputs方法的具体用法?Java RelNode.getInputs怎么用?Java RelNode.getInputs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.rel.RelNode
的用法示例。
在下文中一共展示了RelNode.getInputs方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: replace
import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
private RelNode replace(RelNode original, ForcedRule[] rules, JdbcRelBuilderFactory relBuilderFactory) {
RelNode p = original;
for (ForcedRule rule : rules) {
RelNode updated = rule.apply(p, relBuilderFactory);
if (updated != null) {
logger.trace("Rule: " + rule.toString() +
"\nReplacing:\n" + RelOptUtil.toString(p) +
"\nWith:\n" + RelOptUtil.toString(updated)
);
// Must maintain row types so that nothing explodes
RelOptUtil.equal(
"RowType of original", p.getRowType(),
"RowType of replaced", updated.getRowType(),
Litmus.THROW
);
p = updated;
break;
}
}
List<RelNode> oldInputs = p.getInputs();
for (int i = 0; i < oldInputs.size(); i++) {
RelNode originalInput = oldInputs.get(i);
RelNode replacedInput = replace(originalInput, rules, relBuilderFactory);
if (replacedInput != originalInput) {
p.replaceInput(i, replacedInput);
}
}
return p;
}
示例4: checkCartesianJoin
import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
/**
* Check if the given RelNode contains any Cartesian join.
* Return true if find one. Otherwise, return false.
*
* @param relNode the RelNode to be inspected.
* @param leftKeys a list used for the left input into the join which has
* equi-join keys. It can be empty or not (but not null),
* this method will clear this list before using it.
* @param rightKeys a list used for the right input into the join which has
* equi-join keys. It can be empty or not (but not null),
* this method will clear this list before using it.
* @return Return true if the given relNode contains Cartesian join.
* Otherwise, return false
*/
public static boolean checkCartesianJoin(RelNode relNode, List<Integer> leftKeys, List<Integer> rightKeys) {
if (relNode instanceof Join) {
leftKeys.clear();
rightKeys.clear();
Join joinRel = (Join) relNode;
RelNode left = joinRel.getLeft();
RelNode right = joinRel.getRight();
RexNode remaining = RelOptUtil.splitJoinCondition(left, right, joinRel.getCondition(), leftKeys, rightKeys);
if(joinRel.getJoinType() == JoinRelType.INNER) {
if(leftKeys.isEmpty() || rightKeys.isEmpty()) {
return true;
}
} else {
if(!remaining.isAlwaysTrue() || leftKeys.isEmpty() || rightKeys.isEmpty()) {
return true;
}
}
}
for (RelNode child : relNode.getInputs()) {
if(checkCartesianJoin(child, leftKeys, rightKeys)) {
return true;
}
}
return false;
}
示例5: 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;
}
示例6: getDepth
import org.apache.calcite.rel.RelNode; //导入方法依赖的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;
}
示例7: containsHashAggregate
import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
private static boolean containsHashAggregate(final RelNode relNode) {
if (relNode instanceof HashAggPrel) {
return true;
}
else {
for (final RelNode child : relNode.getInputs()) {
if (containsHashAggregate(child)) {
return true;
} // else, continue
}
}
return false;
}
示例8: checkCartesianJoin
import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
/**
* Check if the given RelNode contains any Cartesian join.
* Return true if find one. Otherwise, return false.
*
* @param relNode the RelNode to be inspected.
* @param leftKeys a list used for the left input into the join which has
* equi-join keys. It can be empty or not (but not null),
* this method will clear this list before using it.
* @param rightKeys a list used for the right input into the join which has
* equi-join keys. It can be empty or not (but not null),
* this method will clear this list before using it.
* @param filterNulls The join key positions for which null values will not
* match. null values only match for the "is not distinct
* from" condition.
* @return Return true if the given relNode contains Cartesian join.
* Otherwise, return false
*/
public static boolean checkCartesianJoin(RelNode relNode, List<Integer> leftKeys, List<Integer> rightKeys, List<Boolean> filterNulls) {
if (relNode instanceof Join) {
leftKeys.clear();
rightKeys.clear();
Join joinRel = (Join) relNode;
RelNode left = joinRel.getLeft();
RelNode right = joinRel.getRight();
RexNode remaining = RelOptUtil.splitJoinCondition(left, right, joinRel.getCondition(), leftKeys, rightKeys, filterNulls);
if(joinRel.getJoinType() == JoinRelType.INNER) {
if(leftKeys.isEmpty() || rightKeys.isEmpty()) {
return true;
}
} else {
if(!remaining.isAlwaysTrue() || leftKeys.isEmpty() || rightKeys.isEmpty()) {
return true;
}
}
}
for (RelNode child : relNode.getInputs()) {
if(checkCartesianJoin(child, leftKeys, rightKeys, filterNulls)) {
return true;
}
}
return false;
}
示例9: explain_
import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
protected void explain_(
RelNode rel,
List<Pair<String, Object>> values) {
List<RelNode> inputs = rel.getInputs();
if (rel instanceof HashJoinPrel && ((HashJoinPrel) rel).isSwapped()) {
HashJoinPrel joinPrel = (HashJoinPrel) rel;
inputs = FlatLists.of(joinPrel.getRight(), joinPrel.getLeft());
}
if (!RelMetadataQuery.isVisibleInExplain(
rel,
detailLevel)) {
// render children in place of this, at same level
explainInputs(inputs);
return;
}
StringBuilder s = new StringBuilder();
OpId id = ids.get(rel);
if (id != null) {
s.append(String.format("%02d-%02d", id.fragmentId, id.opId));
}else{
s.append(" ");
}
s.append(" ");
if (id != null && id.opId == 0) {
for(int i =0; i < spacer.get(); i++){ s.append('-');}
}else{
spacer.spaces(s);
}
s.append(" ");
s.append(rel.getRelTypeName().replace("Prel", ""));
if (detailLevel != SqlExplainLevel.NO_ATTRIBUTES) {
int j = 0;
for (Pair<String, Object> value : values) {
if (value.right instanceof RelNode) {
continue;
}
if (j++ == 0) {
s.append("(");
} else {
s.append(", ");
}
s.append(value.left)
.append("=[")
.append(value.right)
.append("]");
}
if (j > 0) {
s.append(")");
}
}
if (detailLevel == SqlExplainLevel.ALL_ATTRIBUTES) {
s.append(" : rowType = " + rel.getRowType().toString());
s.append(": rowcount = ")
.append(RelMetadataQuery.getRowCount(rel))
.append(", cumulative cost = ")
.append(RelMetadataQuery.getCumulativeCost(rel));
s.append(", id = ").append(rel.getId());
}
pw.println(s);
spacer.add(2);
explainInputs(inputs);
spacer.subtract(2);
}
示例10: explain_
import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
protected void explain_(
RelNode rel,
List<Pair<String, Object>> values) {
List<RelNode> inputs = rel.getInputs();
RelMetadataQuery mq = RelMetadataQuery.instance(DefaultRelMetadataProvider.INSTANCE);
if (rel instanceof HashJoinPrel && ((HashJoinPrel) rel).isSwapped()) {
HashJoinPrel joinPrel = (HashJoinPrel) rel;
inputs = FlatLists.of(joinPrel.getRight(), joinPrel.getLeft());
}
if (!mq.isVisibleInExplain(rel, detailLevel)) {
// render children in place of this, at same level
explainInputs(inputs);
return;
}
StringBuilder s = new StringBuilder();
OpId id = ids.get(rel);
if (id != null) {
s.append(String.format("%02d-%02d", id.fragmentId, id.opId));
}else{
s.append(" ");
}
s.append(" ");
if (id != null && id.opId == 0) {
for(int i =0; i < spacer.get(); i++){ s.append('-');}
}else{
spacer.spaces(s);
}
s.append(" ");
s.append(rel.getRelTypeName().replace("Prel", ""));
if (detailLevel != SqlExplainLevel.NO_ATTRIBUTES) {
int j = 0;
for (Pair<String, Object> value : values) {
if (value.right instanceof RelNode) {
continue;
}
if (j++ == 0) {
s.append("(");
} else {
s.append(", ");
}
s.append(value.left)
.append("=[")
.append(value.right)
.append("]");
}
if (j > 0) {
s.append(")");
}
}
if (detailLevel == SqlExplainLevel.ALL_ATTRIBUTES) {
s.append(" : rowType = " + rel.getRowType().toString());
s.append(": rowcount = ")
.append(mq.getRowCount(rel))
.append(", cumulative cost = ")
.append(mq.getCumulativeCost(rel));
s.append(", id = ").append(rel.getId());
}
pw.println(s);
spacer.add(2);
explainInputs(inputs);
spacer.subtract(2);
}