org.apache.calcite.rel.core.Filter.getCluster()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(241)

本文整理了Java中org.apache.calcite.rel.core.Filter.getCluster()方法的一些代码示例,展示了Filter.getCluster()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Filter.getCluster()方法的具体详情如下:
包路径:org.apache.calcite.rel.core.Filter
类名称:Filter
方法名:getCluster

Filter.getCluster介绍

暂无

代码示例

代码示例来源:origin: apache/hive

public static RexNode splitCorrelatedFilterCondition(
  Filter filter,
  List<RexNode> joinKeys,
  List<RexNode> correlatedJoinKeys,
  boolean extractCorrelatedFieldAccess) {
 final List<RexNode> nonEquiList = new ArrayList<>();
 splitCorrelatedFilterCondition(
   filter,
   filter.getCondition(),
   joinKeys,
   correlatedJoinKeys,
   nonEquiList,
   extractCorrelatedFieldAccess);
 // Convert the remainders into a list that are AND'ed together.
 return RexUtil.composeConjunction(
   filter.getCluster().getRexBuilder(), nonEquiList, true);
}

代码示例来源:origin: apache/drill

protected void perform(RelOptRuleCall call, Filter filter,
   HiveTableScan tScan) {

  RelOptHiveTable hiveTable = (RelOptHiveTable) tScan.getTable();
  RexNode predicate = filter.getCondition();

  Pair<RexNode, RexNode> predicates = PartitionPrune
    .extractPartitionPredicates(filter.getCluster(), hiveTable, predicate);
  RexNode partColExpr = predicates.left;
  hiveTable.computePartitionList(conf, partColExpr, tScan.getPartOrVirtualCols());
 }
}

代码示例来源:origin: apache/storm

@Override
  public RelNode convert(RelNode rel) {
    final Filter filter = (Filter) rel;
    final RelNode input = filter.getInput();

    return new StreamsFilterRel(filter.getCluster(),
                  filter.getTraitSet().replace(StreamsLogicalConvention.INSTANCE),
                  convert(input, input.getTraitSet().replace(StreamsLogicalConvention.INSTANCE)),
                  filter.getCondition());
  }
}

代码示例来源:origin: apache/hive

filterCondToPushBelowProj = RexUtil.composeConjunction(filter.getCluster().getRexBuilder(),
       newPartKeyFilConds, true);
   unPushedFilCondAboveProj = RexUtil.composeConjunction(filter.getCluster().getRexBuilder(),
       unpushedFilConds, true);
RelNode newProjRel = getNewProject(filterCondToPushBelowProj, unPushedFilCondAboveProj, origproject, filter.getCluster()
  .getTypeFactory(), call.builder());
call.transformTo(newProjRel);

代码示例来源:origin: apache/drill

filterCondToPushBelowProj = RexUtil.composeConjunction(filter.getCluster().getRexBuilder(),
       newPartKeyFilConds, true);
   unPushedFilCondAboveProj = RexUtil.composeConjunction(filter.getCluster().getRexBuilder(),
       unpushedFilConds, true);
RelNode newProjRel = getNewProject(filterCondToPushBelowProj, unPushedFilCondAboveProj, origproject, filter.getCluster()
  .getTypeFactory(), call.builder());
call.transformTo(newProjRel);

代码示例来源:origin: apache/hive

@Override
 public void onMatch(RelOptRuleCall call) {
  final Filter filter = call.rel(0);
  final RexBuilder rexBuilder = filter.getCluster().getRexBuilder();
  final RexNode condition = RexUtil.pullFactors(rexBuilder, filter.getCondition());
  RexNode newCondition = analyzeRexNode(rexBuilder, condition);
  // If we could not transform anything, we bail out
  if (newCondition.toString().equals(condition.toString())) {
   return;
  }
  RelNode newNode = filter.copy(filter.getTraitSet(), filter.getInput(), newCondition);
  call.transformTo(newNode);
 }
}

代码示例来源:origin: apache/hive

protected void perform(RelOptRuleCall call, Filter filter,
   HiveTableScan tScan) {
  // Original table
  RelOptHiveTable hiveTable = (RelOptHiveTable) tScan.getTable();

  // Copy original table scan and table
  HiveTableScan tScanCopy = tScan.copyIncludingTable(tScan.getRowType());
  RelOptHiveTable hiveTableCopy = (RelOptHiveTable) tScanCopy.getTable();

  // Execute partition pruning
  RexNode predicate = filter.getCondition();
  Pair<RexNode, RexNode> predicates = PartitionPrune
    .extractPartitionPredicates(filter.getCluster(), hiveTableCopy, predicate);
  RexNode partColExpr = predicates.left;
  hiveTableCopy.computePartitionList(conf, partColExpr, tScanCopy.getPartOrVirtualCols());

  if (StringUtils.equals(hiveTableCopy.getPartitionListKey(), hiveTable.getPartitionListKey())) {
   // Nothing changed, we do not need to produce a new expression
   return;
  }

  call.transformTo(filter.copy(
    filter.getTraitSet(), Collections.singletonList(tScanCopy)));
 }
}

代码示例来源:origin: apache/hive

RexBuilder rexBuilder = filterRel.getCluster().getRexBuilder();
final RelBuilder relBuilder = call.builder();
List<RelDataTypeField> origFields = setOp.getRowType().getFieldList();
   listBuilder.add(newCondition);
   RexExecutor executor =
     Util.first(filterRel.getCluster().getPlanner().getExecutor(), RexUtil.EXECUTOR);
   final RexSimplify simplify =
     new RexSimplify(rexBuilder, true, executor);

代码示例来源:origin: apache/hive

final RexBuilder rexBuilder = filter.getCluster().getRexBuilder();

代码示例来源:origin: apache/hive

@Override
public void onMatch(RelOptRuleCall call) {
 final Filter filter = call.rel(0);
 final RexBuilder rexBuilder = filter.getCluster().getRexBuilder();
 final RelMetadataQuery metadataProvider = call.getMetadataQuery();
 // 1. Recompose filter possibly by pulling out common elements from DNF
 // expressions
 RexNode newFilterCondition = RexUtil.pullFactors(rexBuilder, filter.getCondition());
 // 2. Reduce filter with stats information
 RexReplacer replacer = new RexReplacer(filter, rexBuilder, metadataProvider);
 newFilterCondition = replacer.apply(newFilterCondition);
 // 3. Transform if we have created a new filter operator
 if (!filter.getCondition().toString().equals(newFilterCondition.toString())) {
  Filter newFilter = filter.copy(filter.getTraitSet(), filter.getInput(), newFilterCondition);
  call.transformTo(newFilter);
 }
}

代码示例来源:origin: apache/drill

final RexBuilder rexBuilder = filter.getCluster().getRexBuilder();

代码示例来源:origin: apache/drill

@Override
public void onMatch(RelOptRuleCall call) {
 final Filter filter = call.rel(0);
 final RexBuilder rexBuilder = filter.getCluster().getRexBuilder();
 final RelMetadataQuery metadataProvider = RelMetadataQuery.instance();
 // 1. Recompose filter possibly by pulling out common elements from DNF
 // expressions
 RexNode newFilterCondition = RexUtil.pullFactors(rexBuilder, filter.getCondition());
 // 2. Reduce filter with stats information
 RexReplacer replacer = new RexReplacer(filter, rexBuilder, metadataProvider);
 newFilterCondition = replacer.apply(newFilterCondition);
 // 3. Transform if we have created a new filter operator
 if (!filter.getCondition().toString().equals(newFilterCondition.toString())) {
  Filter newFilter = filter.copy(filter.getTraitSet(), filter.getInput(), newFilterCondition);
  call.transformTo(newFilter);
 }
}

代码示例来源:origin: apache/drill

public void onMatch(RelOptRuleCall call) {
  final Filter filter = call.rel(0);
  final Project project = call.rel(1);
  final List<RexNode> newProjects = new ArrayList<>(project.getProjects());
  newProjects.add(filter.getCondition());
  final RelOptCluster cluster = filter.getCluster();
  RelDataType newRowType =
    cluster.getTypeFactory().builder()
      .addAll(project.getRowType().getFieldList())
      .add("condition", Util.last(newProjects).getType())
      .build();
  final RelNode newProject =
    project.copy(project.getTraitSet(),
      project.getInput(),
      newProjects,
      newRowType);
  final RexInputRef newCondition =
    cluster.getRexBuilder().makeInputRef(newProject,
      newProjects.size() - 1);
  call.transformTo(filter.copy(filter.getTraitSet(), newProject, newCondition));
 }
}

代码示例来源:origin: apache/drill

public void onMatch(RelOptRuleCall call) {
 final Filter filter = call.rel(0);
 final RexBuilder rexBuilder = filter.getCluster().getRexBuilder();
 final RexNode condition = RexUtil.pullFactors(rexBuilder, filter.getCondition());
 // 1. We try to transform possible candidates
 RexTransformIntoInClause transformIntoInClause = new RexTransformIntoInClause(rexBuilder, filter,
     minNumORClauses);
 RexNode newCondition = transformIntoInClause.apply(condition);
 // 2. We merge IN expressions
 RexMergeInClause mergeInClause = new RexMergeInClause(rexBuilder);
 newCondition = mergeInClause.apply(newCondition);
 // 3. If we could not transform anything, we bail out
 if (newCondition.toString().equals(condition.toString())) {
  return;
 }
 // 4. We create the filter with the new condition
 RelNode newFilter = filter.copy(filter.getTraitSet(), filter.getInput(), newCondition);
 call.transformTo(newFilter);
}

代码示例来源:origin: apache/hive

filter.getInput());
} else if (reduced) {
 if (RexUtil.isNullabilityCast(filter.getCluster().getTypeFactory(),
   newConditionExp)) {
  newConditionExp = ((RexCall) newConditionExp).getOperands().get(0);

代码示例来源:origin: apache/drill

filter.getInput());
} else if (reduced) {
 if (RexUtil.isNullabilityCast(filter.getCluster().getTypeFactory(),
   newConditionExp)) {
  newConditionExp = ((RexCall) newConditionExp).getOperands().get(0);

代码示例来源:origin: apache/hive

final RelDataTypeFactory typeFactory = filter.getCluster().getTypeFactory();
if (RexUtil.isNullabilityCast(typeFactory, newCondition)) {
 newCondition = ((RexCall) newCondition).getOperands().get(0);

代码示例来源:origin: apache/drill

public void onMatch(RelOptRuleCall call) {
    final Filter filter = call.rel(0);
    //final RelBuilder builder = call.builder();
    //TODO: replace HiveSubQRemoveRelBuilder with calcite's once calcite 1.11.0 is released
    final HiveSubQRemoveRelBuilder builder = new HiveSubQRemoveRelBuilder(null, call.rel(0).getCluster(), null);
    final RexSubQuery e =
        RexUtil.SubQueryFinder.find(filter.getCondition());
    assert e != null;
    final RelOptUtil.Logic logic =
        LogicVisitor.find(RelOptUtil.Logic.TRUE,
            ImmutableList.of(filter.getCondition()), e);
    builder.push(filter.getInput());
    final int fieldCount = builder.peek().getRowType().getFieldCount();
    assert(filter instanceof HiveFilter);
    Set<RelNode> corrScalarQueries = filter.getCluster().getPlanner().getContext().unwrap(Set.class);
    boolean isCorrScalarQuery = corrScalarQueries.contains(e.rel);
    final RexNode target = apply(e, HiveFilter.getVariablesSet(e), logic,
        builder, 1, fieldCount, isCorrScalarQuery);
    final RexShuttle shuttle = new ReplaceSubQueryShuttle(e, target);
    builder.filter(shuttle.apply(filter.getCondition()));
    builder.project(fields(builder, filter.getRowType().getFieldCount()));
    call.transformTo(builder.build());
  }
};

代码示例来源:origin: apache/hive

SubqueryConf subqueryConfig = filter.getCluster().getPlanner().
  getContext().unwrap(SubqueryConf.class);
boolean isCorrScalarQuery = subqueryConfig.getCorrScalarRexSQWithAgg().contains(e.rel);

代码示例来源:origin: apache/drill

final RelDataTypeFactory typeFactory = filter.getCluster().getTypeFactory();
if (RexUtil.isNullabilityCast(typeFactory, newCondition)) {
 newCondition = ((RexCall) newCondition).getOperands().get(0);

相关文章