当前位置: 首页>>代码示例>>Java>>正文


Java RelOptUtil.InputFinder方法代码示例

本文整理汇总了Java中org.apache.calcite.plan.RelOptUtil.InputFinder方法的典型用法代码示例。如果您正苦于以下问题:Java RelOptUtil.InputFinder方法的具体用法?Java RelOptUtil.InputFinder怎么用?Java RelOptUtil.InputFinder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.calcite.plan.RelOptUtil的用法示例。


在下文中一共展示了RelOptUtil.InputFinder方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getExpressionLineage

import org.apache.calcite.plan.RelOptUtil; //导入方法依赖的package包/类
/**
 * Expression lineage from {@link TableScan}.
 *
 * <p>We extract the fields referenced by the expression and we express them
 * using {@link RexTableInputRef}.
 */
public Set<RexNode> getExpressionLineage(TableScan rel,
    RelMetadataQuery mq, RexNode outputExpression) {
  final RexBuilder rexBuilder = rel.getCluster().getRexBuilder();

  // Extract input fields referenced by expression
  final Set<RelDataTypeField> inputExtraFields = new LinkedHashSet<>();
  final RelOptUtil.InputFinder inputFinder = new RelOptUtil.InputFinder(inputExtraFields);
  outputExpression.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 RexNode inputRef = RexTableInputRef.of(
        RelTableRef.of(rel.getTable(), 0),
        RexInputRef.of(idx, rel.getRowType().getFieldList()));
    final Set<RexNode> originalExprs = Sets.newHashSet(inputRef);
    final RexInputRef ref = RexInputRef.of(idx, rel.getRowType().getFieldList());
    mapping.put(ref, originalExprs);
  }

  // Return result
  return createAllPossibleExpressions(rexBuilder, outputExpression, mapping);
}
 
开发者ID:apache,项目名称:calcite,代码行数:31,代码来源:RelMdExpressionLineage.java

示例2: createAllPossibleExpressions

import org.apache.calcite.plan.RelOptUtil; //导入方法依赖的package包/类
/**
 * Given an expression, it will create all equivalent expressions resulting
 * from replacing all possible combinations of references in the mapping by
 * the corresponding expressions.
 *
 * @param rexBuilder rexBuilder
 * @param expr expression
 * @param mapping mapping
 * @return set of resulting expressions equivalent to the input expression
 */
protected static Set<RexNode> createAllPossibleExpressions(RexBuilder rexBuilder,
    RexNode expr, Map<RexInputRef, Set<RexNode>> mapping) {
  // Extract input fields referenced by expression
  final Set<RelDataTypeField> inputExtraFields = new LinkedHashSet<>();
  final RelOptUtil.InputFinder inputFinder = new RelOptUtil.InputFinder(inputExtraFields);
  expr.accept(inputFinder);
  final ImmutableBitSet predFieldsUsed = inputFinder.inputBitSet.build();

  if (predFieldsUsed.isEmpty()) {
    // The unique expression is the input expression
    return Sets.newHashSet(expr);
  }

  return createAllPossibleExpressions(rexBuilder, expr, predFieldsUsed, mapping,
      new HashMap<RexInputRef, RexNode>());
}
 
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:RelMdExpressionLineage.java

示例3: getAllPredicates

import org.apache.calcite.plan.RelOptUtil; //导入方法依赖的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)));
}
 
开发者ID:apache,项目名称:calcite,代码行数:38,代码来源:RelMdAllPredicates.java

示例4: fieldBitmap

import org.apache.calcite.plan.RelOptUtil; //导入方法依赖的package包/类
private ImmutableBitSet fieldBitmap(RexNode joinFilter) {
  final RelOptUtil.InputFinder inputFinder = new RelOptUtil.InputFinder();
  joinFilter.accept(inputFinder);
  return inputFinder.inputBitSet.build();
}
 
开发者ID:apache,项目名称:calcite,代码行数:6,代码来源:LoptMultiJoin.java

示例5: trimFields

import org.apache.calcite.plan.RelOptUtil; //导入方法依赖的package包/类
/**
 * Variant of {@link #trimFields(RelNode, ImmutableBitSet, Set)} for
 * {@link org.apache.calcite.rel.logical.LogicalFilter}.
 */
public TrimResult trimFields(
    Filter filter,
    ImmutableBitSet fieldsUsed,
    Set<RelDataTypeField> extraFields) {
  final RelDataType rowType = filter.getRowType();
  final int fieldCount = rowType.getFieldCount();
  final RexNode conditionExpr = filter.getCondition();
  final RelNode input = filter.getInput();

  // We use the fields used by the consumer, plus any fields used in the
  // filter.
  final Set<RelDataTypeField> inputExtraFields =
      new LinkedHashSet<>(extraFields);
  RelOptUtil.InputFinder inputFinder =
      new RelOptUtil.InputFinder(inputExtraFields);
  inputFinder.inputBitSet.addAll(fieldsUsed);
  conditionExpr.accept(inputFinder);
  final ImmutableBitSet inputFieldsUsed = inputFinder.inputBitSet.build();

  // Create input with trimmed columns.
  TrimResult trimResult =
      trimChild(filter, input, inputFieldsUsed, inputExtraFields);
  RelNode newInput = trimResult.left;
  final Mapping inputMapping = trimResult.right;

  // If the input is unchanged, and we need to project all columns,
  // there's nothing we can do.
  if (newInput == input
      && fieldsUsed.cardinality() == fieldCount) {
    return result(filter, Mappings.createIdentity(fieldCount));
  }

  // Build new project expressions, and populate the mapping.
  final RexVisitor<RexNode> shuttle =
      new RexPermuteInputsShuttle(inputMapping, newInput);
  RexNode newConditionExpr =
      conditionExpr.accept(shuttle);

  // Use copy rather than relBuilder so that correlating variables get set.
  relBuilder.push(
      filter.copy(filter.getTraitSet(), newInput, newConditionExpr));

  // The result has the same mapping as the input gave us. Sometimes we
  // return fields that the consumer didn't ask for, because the filter
  // needs them for its condition.
  return result(relBuilder.build(), inputMapping);
}
 
开发者ID:apache,项目名称:calcite,代码行数:52,代码来源:RelFieldTrimmer.java


注:本文中的org.apache.calcite.plan.RelOptUtil.InputFinder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。