本文整理汇总了Java中org.apache.calcite.plan.RelOptRuleCall类的典型用法代码示例。如果您正苦于以下问题:Java RelOptRuleCall类的具体用法?Java RelOptRuleCall怎么用?Java RelOptRuleCall使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RelOptRuleCall类属于org.apache.calcite.plan包,在下文中一共展示了RelOptRuleCall类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMatch
import org.apache.calcite.plan.RelOptRuleCall; //导入依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
final LogicalAggregate aggregate = (LogicalAggregate) call.rel(0);
final RelNode input = call.rel(1);
if (aggregate.containsDistinctCall()) {
// currently, don't use this rule if any of the aggregates contains DISTINCT
return;
}
final RelTraitSet traits = aggregate.getTraitSet().plus(DrillRel.DRILL_LOGICAL);
final RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL));
try {
call.transformTo(new DrillAggregateRel(aggregate.getCluster(), traits, convertedInput, aggregate.indicator,
aggregate.getGroupSet(), aggregate.getGroupSets(), aggregate.getAggCallList()));
} catch (InvalidRelException e) {
tracer.warning(e.toString());
}
}
示例2: onMatch
import org.apache.calcite.plan.RelOptRuleCall; //导入依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
final UnionRel union = (UnionRel) call.rel(0);
final List<RelNode> inputs = union.getInputs();
List<RelNode> convertedInputList = Lists.newArrayList();
RelTraitSet traits = call.getPlanner().emptyTraitSet().plus(Prel.PHYSICAL);
try {
for (int i = 0; i < inputs.size(); i++) {
RelNode convertedInput = convert(inputs.get(i), PrelUtil.fixTraits(call, traits));
convertedInputList.add(convertedInput);
}
traits = call.getPlanner().emptyTraitSet().plus(Prel.PHYSICAL).plus(DistributionTrait.SINGLETON);
UnionDistinctPrel unionDistinct =
new UnionDistinctPrel(union.getCluster(), traits, convertedInputList,
false /* compatibility already checked during logical phase */);
call.transformTo(unionDistinct);
} catch (InvalidRelException e) {
tracer.warn(e.toString());
}
}
示例3: onMatch
import org.apache.calcite.plan.RelOptRuleCall; //导入依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
final OldScanPrel scan = (OldScanPrel) call.rel(2);
final ProjectPrel project = (ProjectPrel) call.rel(1);
final FilterPrel filter = (FilterPrel) call.rel(0);
HBaseGroupScan groupScan = (HBaseGroupScan)scan.getGroupScan();
if (groupScan.isFilterPushedDown()) {
/*
* The rule can get triggered again due to the transformed "scan => filter" sequence
* created by the earlier execution of this rule when we could not do a complete
* conversion of Optiq Filter's condition to HBase Filter. In such cases, we rely upon
* this flag to not do a re-processing of the rule on the already transformed call.
*/
return;
}
// convert the filter to one that references the child of the project
final RexNode condition = RelOptUtil.pushPastProject(filter.getCondition(), project);
doPushFilterToScan(call, filter, project, scan, groupScan, condition);
}
示例4: onMatch
import org.apache.calcite.plan.RelOptRuleCall; //导入依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
final LimitPrel limit = (LimitPrel) call.rel(0);
final UnionExchangePrel unionExchangePrel = (UnionExchangePrel) call.rel(1);
RelNode child = unionExchangePrel.getInput();
final int offset = limit.getOffset() != null ? Math.max(0, RexLiteral.intValue(limit.getOffset())) : 0;
final int fetch = Math.max(0, RexLiteral.intValue(limit.getFetch()));
// child Limit uses conservative approach: use offset 0 and fetch = parent limit offset + parent limit fetch.
final RexNode childFetch = limit.getCluster().getRexBuilder().makeExactLiteral(BigDecimal.valueOf(offset + fetch));
final RelNode limitUnderExchange = new LimitPrel(child.getCluster(), child.getTraitSet(), child, null, childFetch);
final RelNode newUnionExch = new UnionExchangePrel(unionExchangePrel.getCluster(), unionExchangePrel.getTraitSet(), limitUnderExchange);
final RelNode limitAboveExchange = new LimitPrel(limit.getCluster(), limit.getTraitSet(), newUnionExch, limit.getOffset(), limit.getFetch(), true);
call.transformTo(limitAboveExchange);
}
示例5: onMatch
import org.apache.calcite.plan.RelOptRuleCall; //导入依赖的package包/类
public void onMatch(RelOptRuleCall call) {
Filter filterRel = call.rel(0);
Project projRel = call.rel(1);
// Don't push Filter past Project if the Filter is referencing an ITEM or a FLATTEN expression
// from the Project.
//\TODO: Ideally we should split up the filter conditions into ones that
// reference the ITEM expression and ones that don't and push the latter past the Project
if (findItemOrFlatten(filterRel.getCondition(), projRel.getProjects()) != null) {
return;
}
// convert the filter to one that references the child of the project
RexNode newCondition =
RelOptUtil.pushFilterPastProject(filterRel.getCondition(), projRel);
Filter newFilterRel = LogicalFilter.create(projRel.getInput(), newCondition);
Project newProjRel =
(Project) RelOptUtil.createProject(
newFilterRel,
projRel.getNamedProjects(),
false);
call.transformTo(newProjRel);
}
示例6: create2PhasePlan
import org.apache.calcite.plan.RelOptRuleCall; //导入依赖的package包/类
protected boolean create2PhasePlan(RelOptRuleCall call, DrillAggregateRel aggregate) {
PlannerSettings settings = PrelUtil.getPlannerSettings(call.getPlanner());
RelNode child = call.rel(0).getInputs().get(0);
boolean smallInput = child.getRows() < settings.getSliceTarget();
if (! settings.isMultiPhaseAggEnabled() || settings.isSingleMode() || smallInput) {
return false;
}
for (AggregateCall aggCall : aggregate.getAggCallList()) {
String name = aggCall.getAggregation().getName();
if ( ! (name.equals("SUM") || name.equals("MIN") || name.equals("MAX") || name.equals("COUNT")
|| name.equals("$SUM0")
|| (name.toLowerCase().contains("qdm") && name.toLowerCase().contains("train")))) {
return false;
}
}
return true;
}
示例7: create2PhasePlan
import org.apache.calcite.plan.RelOptRuleCall; //导入依赖的package包/类
protected boolean create2PhasePlan(RelOptRuleCall call, AggregateRel aggregate) {
PlannerSettings settings = PrelUtil.getPlannerSettings(call.getPlanner());
RelNode child = call.rel(0).getInputs().get(0);
boolean smallInput = child.estimateRowCount(DefaultRelMetadataProvider.INSTANCE.getRelMetadataQuery()) < settings.getSliceTarget();
if (! settings.isMultiPhaseAggEnabled() || settings.isSingleMode() || smallInput) {
return false;
}
for (AggregateCall aggCall : aggregate.getAggCallList()) {
String name = aggCall.getAggregation().getName();
if (!twoPhaseFunctions.contains(name)) {
return false;
}
}
return true;
}
示例8: createTransformRequest
import org.apache.calcite.plan.RelOptRuleCall; //导入依赖的package包/类
private void createTransformRequest(RelOptRuleCall call, DrillAggregateRel aggregate,
RelNode input, RelTraitSet traits) throws InvalidRelException {
final RelNode convertedInput = convert(input, traits);
StreamAggPrel newAgg = new StreamAggPrel(
aggregate.getCluster(),
traits,
convertedInput,
aggregate.indicator,
aggregate.getGroupSet(),
aggregate.getGroupSets(),
aggregate.getAggCallList(),
OperatorPhase.PHASE_1of1);
call.transformTo(newAgg);
}
示例9: onMatch
import org.apache.calcite.plan.RelOptRuleCall; //导入依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
ElasticsearchScanDrel logicalScan = call.rel(0);
ElasticIntermediateScanPrel physicalScan = new ElasticIntermediateScanPrel(
logicalScan.getCluster(),
logicalScan.getTraitSet().replace(Prel.PHYSICAL),
logicalScan.getTable(),
logicalScan.getTableMetadata(),
logicalScan.getProjectedColumns(),
logicalScan.getObservedRowcountAdjustment()
);
RelNode converted = new ElasticsearchIntermediatePrel(
physicalScan.getTraitSet(),
physicalScan,
lookupContext);
call.transformTo(converted);
}
示例10: onMatch
import org.apache.calcite.plan.RelOptRuleCall; //导入依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
final FilterRelBase filter = call.rel(0);
final ElasticsearchIntermediatePrel intermediatePrel = call.rel(1);
final ElasticRuleRelVisitor visitor = new FilterConverterVisitor(filter, intermediatePrel.getInput()).go();
final ElasticsearchPrel newInput = visitor.getConvertedTree();
final ElasticsearchIntermediatePrel newInter = intermediatePrel.withNewInput(newInput);
final ElasticsearchFilter newFilter = newInter.get(ElasticsearchFilter.class);
final ElasticIntermediateScanPrel scan = newInter.get(ElasticIntermediateScanPrel.class);
try {
QueryBuilder analyzed = PredicateAnalyzer.analyze(scan, newFilter.getCondition());
PredicateAnalyzer.queryAsJson(analyzed);
call.transformTo(newInter);
return;
} catch (ExpressionNotAnalyzableException | IOException e) {
// Nothing could be transformed or we encountered a fatal error. The query will
// still execute, but it will be slow b/c we can't push the predicate down to elasticsearch.
logger.debug("Failed to push filter into scan/project; falling back to manual filtering", e);
return;
}
}
示例11: createTransformRequest
import org.apache.calcite.plan.RelOptRuleCall; //导入依赖的package包/类
private void createTransformRequest(RelOptRuleCall call, DrillAggregateRel aggregate,
RelNode input, RelTraitSet traits) throws InvalidRelException {
final RelNode convertedInput = convert(input, PrelUtil.fixTraits(call, traits));
HashAggPrel newAgg = new HashAggPrel(
aggregate.getCluster(),
traits,
convertedInput,
aggregate.indicator,
aggregate.getGroupSet(),
aggregate.getGroupSets(),
aggregate.getAggCallList(),
OperatorPhase.PHASE_1of1);
call.transformTo(newAgg);
}
示例12: onMatch
import org.apache.calcite.plan.RelOptRuleCall; //导入依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
final DrillProjectRel project = (DrillProjectRel) call.rel(0);
final RelNode input = project.getInput();
RelTraitSet traits = input.getTraitSet().plus(Prel.DRILL_PHYSICAL);
RelNode convertedInput = convert(input, traits);
// Maintain two different map for distribution trait and collation trait.
// For now, the only difference comes from the way how cast function impacts propagating trait.
final Map<Integer, Integer> distributionMap = getDistributionMap(project);
final Map<Integer, Integer> collationMap = getCollationMap(project);
boolean traitPull = new ProjectTraitPull(call, distributionMap, collationMap).go(project, convertedInput);
if(!traitPull){
call.transformTo(new ProjectPrel(project.getCluster(), convertedInput.getTraitSet(), convertedInput, project.getProjects(), project.getRowType()));
}
}
示例13: onMatch
import org.apache.calcite.plan.RelOptRuleCall; //导入依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
final LogicalUnion union = (LogicalUnion) call.rel(0);
// This rule applies to Union-All only
if(!union.all) {
return;
}
final RelTraitSet traits = union.getTraitSet().plus(Rel.LOGICAL);
final List<RelNode> convertedInputs = new ArrayList<>();
for (RelNode input : union.getInputs()) {
final RelNode convertedInput = convert(input, input.getTraitSet().plus(Rel.LOGICAL).simplify());
convertedInputs.add(convertedInput);
}
try {
call.transformTo(new UnionRel(union.getCluster(), traits, convertedInputs, union.all,
true /* check compatibility */));
} catch (InvalidRelException e) {
tracer.warn(e.toString()) ;
}
}
示例14: createTransformRequest
import org.apache.calcite.plan.RelOptRuleCall; //导入依赖的package包/类
private void createTransformRequest(RelOptRuleCall call, AggregateRel aggregate,
RelNode input, RelTraitSet traits) throws InvalidRelException {
final RelNode convertedInput = convert(input, traits);
StreamAggPrel newAgg = new StreamAggPrel(
aggregate.getCluster(),
traits,
convertedInput,
aggregate.indicator,
aggregate.getGroupSet(),
aggregate.getGroupSets(),
aggregate.getAggCallList(),
OperatorPhase.PHASE_1of1);
call.transformTo(newAgg);
}
示例15: matches
import org.apache.calcite.plan.RelOptRuleCall; //导入依赖的package包/类
@Override
public boolean matches(RelOptRuleCall call) {
try {
final LogicalProject project = (LogicalProject) call.rel(0);
for (RexNode node : project.getChildExps()) {
if (!checkedExpressions.get(node)) {
return false;
}
}
return true;
} catch (ExecutionException e) {
throw new IllegalStateException("Failure while trying to evaluate pushdown.", e);
}
}