本文整理汇总了Java中org.apache.calcite.rex.RexProgramBuilder.mergePrograms方法的典型用法代码示例。如果您正苦于以下问题:Java RexProgramBuilder.mergePrograms方法的具体用法?Java RexProgramBuilder.mergePrograms怎么用?Java RexProgramBuilder.mergePrograms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.rex.RexProgramBuilder
的用法示例。
在下文中一共展示了RexProgramBuilder.mergePrograms方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMatch
import org.apache.calcite.rex.RexProgramBuilder; //导入方法依赖的package包/类
public void onMatch(RelOptRuleCall call) {
Filter topFilter = call.rel(0);
Filter bottomFilter = call.rel(1);
// use RexPrograms to merge the two FilterRels into a single program
// so we can convert the two FilterRel conditions to directly
// reference the bottom FilterRel's child
RexBuilder rexBuilder = topFilter.getCluster().getRexBuilder();
RexProgram bottomProgram = createProgram(bottomFilter);
RexProgram topProgram = createProgram(topFilter);
RexProgram mergedProgram =
RexProgramBuilder.mergePrograms(
topProgram,
bottomProgram,
rexBuilder);
RexNode newCondition =
mergedProgram.expandLocalRef(
mergedProgram.getCondition());
// if(!RexUtil.isFlat(newCondition)){
// RexCall newCall = (RexCall) newCondition;
// newCondition = rexBuilder.makeFlatCall( newCall.getOperator(), newCall.getOperands());
// }
Filter newFilterRel =
(Filter) filterFactory.createFilter(
bottomFilter.getInput(),
RexUtil.flatten(rexBuilder, newCondition));
call.transformTo(newFilterRel);
}
示例2: onMatch
import org.apache.calcite.rex.RexProgramBuilder; //导入方法依赖的package包/类
public void onMatch(RelOptRuleCall call) {
final Filter topFilter = call.rel(0);
final Filter bottomFilter = call.rel(1);
// use RexPrograms to merge the two FilterRels into a single program
// so we can convert the two LogicalFilter conditions to directly
// reference the bottom LogicalFilter's child
RexBuilder rexBuilder = topFilter.getCluster().getRexBuilder();
RexProgram bottomProgram = createProgram(bottomFilter);
RexProgram topProgram = createProgram(topFilter);
RexProgram mergedProgram =
RexProgramBuilder.mergePrograms(
topProgram,
bottomProgram,
rexBuilder);
RexNode newCondition =
mergedProgram.expandLocalRef(
mergedProgram.getCondition());
final RelBuilder relBuilder = call.builder();
relBuilder.push(bottomFilter.getInput())
.filter(newCondition);
call.transformTo(relBuilder.build());
}
示例3: onMatch
import org.apache.calcite.rex.RexProgramBuilder; //导入方法依赖的package包/类
public void onMatch(RelOptRuleCall call) {
final LogicalFilter filter = call.rel(0);
final LogicalCalc calc = call.rel(1);
// Don't merge a filter onto a calc which contains windowed aggregates.
// That would effectively be pushing a multiset down through a filter.
// We'll have chance to merge later, when the over is expanded.
if (calc.getProgram().containsAggs()) {
return;
}
// Create a program containing the filter.
final RexBuilder rexBuilder = filter.getCluster().getRexBuilder();
final RexProgramBuilder progBuilder =
new RexProgramBuilder(
calc.getRowType(),
rexBuilder);
progBuilder.addIdentity();
progBuilder.addCondition(filter.getCondition());
RexProgram topProgram = progBuilder.getProgram();
RexProgram bottomProgram = calc.getProgram();
// Merge the programs together.
RexProgram mergedProgram =
RexProgramBuilder.mergePrograms(
topProgram,
bottomProgram,
rexBuilder);
final LogicalCalc newCalc =
LogicalCalc.create(calc.getInput(), mergedProgram);
call.transformTo(newCalc);
}
示例4: onMatch
import org.apache.calcite.rex.RexProgramBuilder; //导入方法依赖的package包/类
public void onMatch(RelOptRuleCall call) {
final LogicalProject project = call.rel(0);
final LogicalCalc calc = call.rel(1);
// Don't merge a project which contains windowed aggregates onto a
// calc. That would effectively be pushing a windowed aggregate down
// through a filter. Transform the project into an identical calc,
// which we'll have chance to merge later, after the over is
// expanded.
final RelOptCluster cluster = project.getCluster();
RexProgram program =
RexProgram.create(
calc.getRowType(),
project.getProjects(),
null,
project.getRowType(),
cluster.getRexBuilder());
if (RexOver.containsOver(program)) {
LogicalCalc projectAsCalc = LogicalCalc.create(calc, program);
call.transformTo(projectAsCalc);
return;
}
// Create a program containing the project node's expressions.
final RexBuilder rexBuilder = cluster.getRexBuilder();
final RexProgramBuilder progBuilder =
new RexProgramBuilder(
calc.getRowType(),
rexBuilder);
for (Pair<RexNode, String> field : project.getNamedProjects()) {
progBuilder.addProject(field.left, field.right);
}
RexProgram topProgram = progBuilder.getProgram();
RexProgram bottomProgram = calc.getProgram();
// Merge the programs together.
RexProgram mergedProgram =
RexProgramBuilder.mergePrograms(
topProgram,
bottomProgram,
rexBuilder);
final LogicalCalc newCalc =
LogicalCalc.create(calc.getInput(), mergedProgram);
call.transformTo(newCalc);
}
示例5: adjustCondition
import org.apache.calcite.rex.RexProgramBuilder; //导入方法依赖的package包/类
/**
* Pulls the project above the semijoin and returns the resulting semijoin
* condition. As a result, the semijoin condition should be modified such
* that references to the LHS of a semijoin should now reference the
* children of the project that's on the LHS.
*
* @param project LogicalProject on the LHS of the semijoin
* @param semiJoin the semijoin
* @return the modified semijoin condition
*/
private RexNode adjustCondition(LogicalProject project, SemiJoin semiJoin) {
// create two RexPrograms -- the bottom one representing a
// concatenation of the project and the RHS of the semijoin and the
// top one representing the semijoin condition
RexBuilder rexBuilder = project.getCluster().getRexBuilder();
RelDataTypeFactory typeFactory = rexBuilder.getTypeFactory();
RelNode rightChild = semiJoin.getRight();
// for the bottom RexProgram, the input is a concatenation of the
// child of the project and the RHS of the semijoin
RelDataType bottomInputRowType =
SqlValidatorUtil.deriveJoinRowType(
project.getInput().getRowType(),
rightChild.getRowType(),
JoinRelType.INNER,
typeFactory,
null,
semiJoin.getSystemFieldList());
RexProgramBuilder bottomProgramBuilder =
new RexProgramBuilder(bottomInputRowType, rexBuilder);
// add the project expressions, then add input references for the RHS
// of the semijoin
for (Pair<RexNode, String> pair : project.getNamedProjects()) {
bottomProgramBuilder.addProject(pair.left, pair.right);
}
int nLeftFields = project.getInput().getRowType().getFieldCount();
List<RelDataTypeField> rightFields =
rightChild.getRowType().getFieldList();
int nRightFields = rightFields.size();
for (int i = 0; i < nRightFields; i++) {
final RelDataTypeField field = rightFields.get(i);
RexNode inputRef =
rexBuilder.makeInputRef(
field.getType(), i + nLeftFields);
bottomProgramBuilder.addProject(inputRef, field.getName());
}
RexProgram bottomProgram = bottomProgramBuilder.getProgram();
// input rowtype into the top program is the concatenation of the
// project and the RHS of the semijoin
RelDataType topInputRowType =
SqlValidatorUtil.deriveJoinRowType(
project.getRowType(),
rightChild.getRowType(),
JoinRelType.INNER,
typeFactory,
null,
semiJoin.getSystemFieldList());
RexProgramBuilder topProgramBuilder =
new RexProgramBuilder(
topInputRowType,
rexBuilder);
topProgramBuilder.addIdentity();
topProgramBuilder.addCondition(semiJoin.getCondition());
RexProgram topProgram = topProgramBuilder.getProgram();
// merge the programs and expand out the local references to form
// the new semijoin condition; it now references a concatenation of
// the project's child and the RHS of the semijoin
RexProgram mergedProgram =
RexProgramBuilder.mergePrograms(
topProgram,
bottomProgram,
rexBuilder);
return mergedProgram.expandLocalRef(
mergedProgram.getCondition());
}