本文整理汇总了Java中org.apache.calcite.plan.RelOptRuleCall.builder方法的典型用法代码示例。如果您正苦于以下问题:Java RelOptRuleCall.builder方法的具体用法?Java RelOptRuleCall.builder怎么用?Java RelOptRuleCall.builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.plan.RelOptRuleCall
的用法示例。
在下文中一共展示了RelOptRuleCall.builder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMatch
import org.apache.calcite.plan.RelOptRuleCall; //导入方法依赖的package包/类
public void onMatch(RelOptRuleCall call) {
final Project topProject = call.rel(0);
final Project bottomProject = call.rel(1);
final RelBuilder relBuilder = call.builder();
// merge projects assuming it doesn't alter the unique count of flattens.
final FlattenCounter counter = new FlattenCounter();
counter.add(topProject);
counter.add(bottomProject);
final int uniqueFlattens = counter.getCount();
// If one or both projects are permutations, short-circuit the complex logic
// of building a RexProgram.
final Permutation topPermutation = topProject.getPermutation();
if (topPermutation != null) {
if (topPermutation.isIdentity()) {
// Let ProjectRemoveRule handle this.
return;
}
final Permutation bottomPermutation = bottomProject.getPermutation();
if (bottomPermutation != null) {
if (bottomPermutation.isIdentity()) {
// Let ProjectRemoveRule handle this.
return;
}
final Permutation product = topPermutation.product(bottomPermutation);
relBuilder.push(bottomProject.getInput());
List<RexNode> exprs = relBuilder.fields(product);
relBuilder.project(exprs, topProject.getRowType().getFieldNames());
if(FlattenVisitors.count(exprs) == uniqueFlattens){
call.transformTo(relBuilder.build());
}
return;
}
}
final List<RexNode> newProjects =
RelOptUtil.pushPastProject(topProject.getProjects(), bottomProject);
final RelNode input = bottomProject.getInput();
if (RexUtil.isIdentity(newProjects, input.getRowType()) && uniqueFlattens == 0) {
call.transformTo(input);
}
// replace the two projects with a combined projection
relBuilder.push(bottomProject.getInput());
relBuilder.project(newProjects, topProject.getRowType().getFieldNames());
if(FlattenVisitors.count(newProjects) == uniqueFlattens){
call.transformTo(relBuilder.build());
}
}