本文整理汇总了Java中org.apache.calcite.plan.RelOptPredicateList.union方法的典型用法代码示例。如果您正苦于以下问题:Java RelOptPredicateList.union方法的具体用法?Java RelOptPredicateList.union怎么用?Java RelOptPredicateList.union使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.plan.RelOptPredicateList
的用法示例。
在下文中一共展示了RelOptPredicateList.union方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPredicates
import org.apache.calcite.plan.RelOptPredicateList; //导入方法依赖的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);
}
示例2: getAllPredicates
import org.apache.calcite.plan.RelOptPredicateList; //导入方法依赖的package包/类
/**
* Add the Filter condition to the list obtained from the input.
*/
public RelOptPredicateList getAllPredicates(Filter filter, RelMetadataQuery mq) {
final RelNode input = filter.getInput();
final RexBuilder rexBuilder = filter.getCluster().getRexBuilder();
final RexNode pred = filter.getCondition();
final RelOptPredicateList predsBelow = mq.getAllPredicates(input);
if (predsBelow == null) {
// Safety check
return null;
}
// Extract input fields referenced by Filter condition
final Set<RelDataTypeField> inputExtraFields = new LinkedHashSet<>();
final RelOptUtil.InputFinder inputFinder = new RelOptUtil.InputFinder(inputExtraFields);
pred.accept(inputFinder);
final ImmutableBitSet inputFieldsUsed = inputFinder.inputBitSet.build();
// Infer column origin expressions for given references
final Map<RexInputRef, Set<RexNode>> mapping = new LinkedHashMap<>();
for (int idx : inputFieldsUsed) {
final RexInputRef ref = RexInputRef.of(idx, filter.getRowType().getFieldList());
final Set<RexNode> originalExprs = mq.getExpressionLineage(filter, ref);
if (originalExprs == null) {
// Bail out
return null;
}
mapping.put(ref, originalExprs);
}
// Replace with new expressions and return union of predicates
return predsBelow.union(rexBuilder,
RelOptPredicateList.of(rexBuilder,
RelMdExpressionLineage.createAllPossibleExpressions(rexBuilder, pred, mapping)));
}
示例3: onMatch
import org.apache.calcite.plan.RelOptPredicateList; //导入方法依赖的package包/类
@Override public void onMatch(RelOptRuleCall call) {
final Join join = call.rel(0);
final List<RexNode> expList = Lists.newArrayList(join.getCondition());
final int fieldCount = join.getLeft().getRowType().getFieldCount();
final RelMetadataQuery mq = call.getMetadataQuery();
final RelOptPredicateList leftPredicates =
mq.getPulledUpPredicates(join.getLeft());
final RelOptPredicateList rightPredicates =
mq.getPulledUpPredicates(join.getRight());
final RexBuilder rexBuilder = join.getCluster().getRexBuilder();
final RelOptPredicateList predicates =
leftPredicates.union(rexBuilder,
rightPredicates.shift(rexBuilder, fieldCount));
if (!reduceExpressions(join, expList, predicates, true,
matchNullability)) {
return;
}
if (join instanceof EquiJoin) {
final JoinInfo joinInfo =
JoinInfo.of(join.getLeft(), join.getRight(), expList.get(0));
if (!joinInfo.isEqui()) {
// This kind of join must be an equi-join, and the condition is
// no longer an equi-join. SemiJoin is an example of this.
return;
}
}
call.transformTo(
join.copy(
join.getTraitSet(),
expList.get(0),
join.getLeft(),
join.getRight(),
join.getJoinType(),
join.isSemiJoinDone()));
// New plan is absolutely better than old plan.
call.getPlanner().setImportance(join, 0.0);
}