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


Java ImmutableBitSet.contains方法代码示例

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


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

示例1: canPush

import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
private boolean canPush(Aggregate aggregate, ImmutableBitSet rCols) {
  // If the filter references columns not in the group key, we cannot push
  final ImmutableBitSet groupKeys =
      ImmutableBitSet.range(0, aggregate.getGroupSet().cardinality());
  if (!groupKeys.contains(rCols)) {
    return false;
  }

  if (aggregate.indicator) {
    // If grouping sets are used, the filter can be pushed if
    // the columns referenced in the predicate are present in
    // all the grouping sets.
    for (ImmutableBitSet groupingSet : aggregate.getGroupSets()) {
      if (!groupingSet.contains(rCols)) {
        return false;
      }
    }
  }
  return true;
}
 
开发者ID:qubole,项目名称:quark,代码行数:21,代码来源:FilterAggStarRule.java

示例2: infer

import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
private void infer(RexNode predicates, Set<String> allExprsDigests,
    List<RexNode> inferedPredicates, boolean includeEqualityInference,
    ImmutableBitSet inferringFields) {
  for (RexNode r : RelOptUtil.conjunctions(predicates)) {
    if (!includeEqualityInference
        && equalityPredicates.contains(r.toString())) {
      continue;
    }
    for (Mapping m : mappings(r)) {
      RexNode tr = r.accept(
          new RexPermuteInputsShuttle(m, joinRel.getInput(0),
              joinRel.getInput(1)));
      if (inferringFields.contains(RelOptUtil.InputFinder.bits(tr))
          && !allExprsDigests.contains(tr.toString())
          && !isAlwaysTrue(tr)) {
        inferedPredicates.add(tr);
        allExprsDigests.add(tr.toString());
      }
    }
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:RelMdPredicates.java

示例3: canPush

import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
private boolean canPush(Aggregate aggregate, ImmutableBitSet rCols) {
  // If the filter references columns not in the group key, we cannot push
  final ImmutableBitSet groupKeys =
      ImmutableBitSet.range(0, aggregate.getGroupSet().cardinality());
  if (!groupKeys.contains(rCols)) {
    return false;
  }

  if (aggregate.getGroupType() != Group.SIMPLE) {
    // If grouping sets are used, the filter can be pushed if
    // the columns referenced in the predicate are present in
    // all the grouping sets.
    for (ImmutableBitSet groupingSet : aggregate.getGroupSets()) {
      if (!groupingSet.contains(rCols)) {
        return false;
      }
    }
  }
  return true;
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:FilterAggregateTransposeRule.java

示例4: splitFilters

import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
/**
 * Splits a filter into two lists, depending on whether or not the filter
 * only references its child input
 *
 * @param childBitmap Fields in the child
 * @param predicate   filters that will be split
 * @param pushable    returns the list of filters that can be pushed to the
 *                    child input
 * @param notPushable returns the list of filters that cannot be pushed to
 *                    the child input
 */
public static void splitFilters(
    ImmutableBitSet childBitmap,
    RexNode predicate,
    List<RexNode> pushable,
    List<RexNode> notPushable) {
  // for each filter, if the filter only references the child inputs,
  // then it can be pushed
  for (RexNode filter : conjunctions(predicate)) {
    ImmutableBitSet filterRefs = InputFinder.bits(filter);
    if (childBitmap.contains(filterRefs)) {
      pushable.add(filter);
    } else {
      notPushable.add(filter);
    }
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:28,代码来源:RelOptUtil.java

示例5: validateCubeLatticeFilter

import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
private void validateCubeLatticeFilter(Lattice.Builder latticeBuilder) {
  if (latticeBuilder.filter != null) {
    ImmutableBitSet rCols = RelOptUtil.InputFinder.bits(latticeBuilder.filter);
    Set<Integer> dimSet = new HashSet<>();
    for (Dimension dimension : dimensions) {
      dimSet.add(latticeBuilder.resolveColumn(dimension.qualifiedCol).ordinal);
    }
    ImmutableBitSet dims = ImmutableBitSet.of(dimSet);
    if (!dims.contains(rCols)) {
      throw new RuntimeException("Cube filter is only allowed on dimensions");
    }
  }
}
 
开发者ID:qubole,项目名称:quark,代码行数:14,代码来源:QuarkCube.java

示例6: getPredicates

import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
/**
 * Infers predicates for an Aggregate.
 *
 * <p>Pulls up predicates that only contains references to columns in the
 * GroupSet. For e.g.
 *
 * <blockquote><pre>
 * inputPullUpExprs : { a &gt; 7, b + c &lt; 10, a + e = 9}
 * groupSet         : { a, b}
 * pulledUpExprs    : { a &gt; 7}
 * </pre></blockquote>
 */
public RelOptPredicateList getPredicates(Aggregate agg, RelMetadataQuery mq) {
  final RelNode input = agg.getInput();
  final RexBuilder rexBuilder = agg.getCluster().getRexBuilder();
  final RelOptPredicateList inputInfo = mq.getPulledUpPredicates(input);
  final List<RexNode> aggPullUpPredicates = new ArrayList<>();

  ImmutableBitSet groupKeys = agg.getGroupSet();
  if (groupKeys.isEmpty()) {
    // "GROUP BY ()" can convert an empty relation to a non-empty relation, so
    // it is not valid to pull up predicates. In particular, consider the
    // predicate "false": it is valid on all input rows (trivially - there are
    // no rows!) but not on the output (there is one row).
    return RelOptPredicateList.EMPTY;
  }
  Mapping m = Mappings.create(MappingType.PARTIAL_FUNCTION,
      input.getRowType().getFieldCount(), agg.getRowType().getFieldCount());

  int i = 0;
  for (int j : groupKeys) {
    m.set(j, i++);
  }

  for (RexNode r : inputInfo.pulledUpPredicates) {
    ImmutableBitSet rCols = RelOptUtil.InputFinder.bits(r);
    if (groupKeys.contains(rCols)) {
      r = r.accept(new RexPermuteInputsShuttle(m, input));
      aggPullUpPredicates.add(r);
    }
  }
  return RelOptPredicateList.of(rexBuilder, aggPullUpPredicates);
}
 
开发者ID:apache,项目名称:calcite,代码行数:44,代码来源:RelMdPredicates.java

示例7: setFactorJoinKeys

import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
/**
 * Locates from a list of filters those that correspond to a particular join
 * tree. Then, for each of those filters, extracts the fields corresponding
 * to a particular factor, setting them in a bitmap.
 *
 * @param multiJoin join factors being optimized
 * @param filters list of join filters
 * @param joinFactors bitmap containing the factors in a particular join
 * tree
 * @param factorStart the initial offset of the factor whose join keys will
 * be extracted
 * @param nFields the number of fields in the factor whose join keys will be
 * extracted
 * @param joinKeys the bitmap that will be set with the join keys
 */
private void setFactorJoinKeys(
    LoptMultiJoin multiJoin,
    List<RexNode> filters,
    ImmutableBitSet joinFactors,
    int factorStart,
    int nFields,
    ImmutableBitSet.Builder joinKeys) {
  for (RexNode joinFilter : filters) {
    ImmutableBitSet filterFactors =
        multiJoin.getFactorsRefByJoinFilter(joinFilter);

    // if all factors in the join filter are in the bitmap containing
    // the factors in a join tree, then from that filter, add the
    // fields corresponding to the specified factor to the join key
    // bitmap; in doing so, adjust the join keys so they start at
    // offset 0
    if (joinFactors.contains(filterFactors)) {
      ImmutableBitSet joinFields =
          multiJoin.getFieldsRefByJoinFilter(joinFilter);
      for (int field = joinFields.nextSetBit(factorStart);
           (field >= 0)
               && (field < (factorStart + nFields));
           field = joinFields.nextSetBit(field + 1)) {
        joinKeys.set(field - factorStart);
      }
    }
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:44,代码来源:LoptOptimizeJoinRule.java

示例8: containsKey

import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
/** Returns whether a set of column ordinals
 * matches or contains a unique key.
 * If {@code strict}, it must contain a unique key. */
private boolean containsKey(ImmutableBitSet ordinals, boolean strict) {
  for (ImmutableBitSet keyOrdinals : keyOrdinalLists) {
    if (ordinals.contains(keyOrdinals)) {
      return !(strict && keyOrdinals.equals(ordinals));
    }
  }
  return false;
}
 
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:SimpleProfiler.java

示例9: containsKey

import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
private boolean containsKey(ImmutableBitSet ordinals) {
  for (ImmutableBitSet keyOrdinals : keyOrdinalLists) {
    if (ordinals.contains(keyOrdinals)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:apache,项目名称:calcite,代码行数:9,代码来源:ProfilerImpl.java

示例10: of

import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
/** Returns a statistic with a given row count, set of unique keys,
 * referential constraints, and collations. */
public static Statistic of(final Double rowCount,
    final List<ImmutableBitSet> keys,
    final List<RelReferentialConstraint> referentialConstraints,
    final List<RelCollation> collations) {
  return new Statistic() {
    public Double getRowCount() {
      return rowCount;
    }

    public boolean isKey(ImmutableBitSet columns) {
      for (ImmutableBitSet key : keys) {
        if (columns.contains(key)) {
          return true;
        }
      }
      return false;
    }

    public List<RelReferentialConstraint> getReferentialConstraints() {
      return referentialConstraints;
    }

    public List<RelCollation> getCollations() {
      return collations;
    }

    public RelDistribution getDistribution() {
      return RelDistributionTraitDef.INSTANCE.getDefault();
    }
  };
}
 
开发者ID:apache,项目名称:calcite,代码行数:34,代码来源:Statistics.java

示例11: isUnique

import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
/** Returns whether {@code keys} is unique, that is, whether it or a superset
 * is in {@code keySets}. */
private boolean isUnique(Set<ImmutableBitSet> uniqueKeys, ImmutableBitSet key) {
  for (ImmutableBitSet uniqueKey : uniqueKeys) {
    if (key.contains(uniqueKey)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:RelMetadataTest.java

示例12: areColumnsUnique

import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
public Boolean areColumnsUnique(Aggregate rel, RelMetadataQuery mq,
    ImmutableBitSet columns, boolean ignoreNulls) {
  // group by keys form a unique key
  ImmutableBitSet groupKey = ImmutableBitSet.range(rel.getGroupCount());
  return columns.contains(groupKey);
}
 
开发者ID:apache,项目名称:calcite,代码行数:7,代码来源:RelMdColumnUniqueness.java

示例13: projectPredicate

import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
/** Converts a predicate on a particular set of columns into a predicate on
 * a subset of those columns, weakening if necessary.
 *
 * <p>If not possible to simplify, returns {@code true}, which is the weakest
 * possible predicate.
 *
 * <p>Examples:<ol>
 * <li>The predicate {@code $7 = $9} on columns [7]
 *     becomes {@code $7 is not null}
 * <li>The predicate {@code $7 = $9 + $11} on columns [7, 9]
 *     becomes {@code $7 is not null or $9 is not null}
 * <li>The predicate {@code $7 = $9 and $9 = 5} on columns [7] becomes
 *   {@code $7 = 5}
 * <li>The predicate
 *   {@code $7 = $9 and ($9 = $1 or $9 = $2) and $1 > 3 and $2 > 10}
 *   on columns [7] becomes {@code $7 > 3}
 * </ol>
 *
 * <p>We currently only handle examples 1 and 2.
 *
 * @param rexBuilder Rex builder
 * @param input Input relational expression
 * @param r Predicate expression
 * @param columnsMapped Columns which the final predicate can reference
 * @return Predicate expression narrowed to reference only certain columns
 */
private RexNode projectPredicate(final RexBuilder rexBuilder, RelNode input,
    RexNode r, ImmutableBitSet columnsMapped) {
  ImmutableBitSet rCols = RelOptUtil.InputFinder.bits(r);
  if (columnsMapped.contains(rCols)) {
    // All required columns are present. No need to weaken.
    return r;
  }
  if (columnsMapped.intersects(rCols)) {
    final List<RexNode> list = new ArrayList<>();
    for (int c : columnsMapped.intersect(rCols)) {
      if (input.getRowType().getFieldList().get(c).getType().isNullable()
          && Strong.isNull(r, ImmutableBitSet.of(c))) {
        list.add(
            rexBuilder.makeCall(SqlStdOperatorTable.IS_NOT_NULL,
                rexBuilder.makeInputRef(input, c)));
      }
    }
    if (!list.isEmpty()) {
      return RexUtil.composeDisjunction(rexBuilder, list);
    }
  }
  // Cannot weaken to anything non-trivial
  return rexBuilder.makeLiteral(true);
}
 
开发者ID:apache,项目名称:calcite,代码行数:51,代码来源:RelMdPredicates.java

示例14: removeJoin

import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
/**
 * Determines whether a join of the dimension table in a semijoin can be
 * removed. It can be if the dimension keys are unique and the only fields
 * referenced from the dimension table are its semijoin keys. The semijoin
 * keys can be mapped to the corresponding keys from the fact table (because
 * of the equality condition associated with the semijoin keys). Therefore,
 * that's why the dimension table can be removed even though those fields
 * are referenced elsewhere in the query tree.
 *
 * @param multiJoin join factors being optimized
 * @param semiJoin semijoin under consideration
 * @param factIdx id of the fact table in the semijoin
 * @param dimIdx id of the dimension table in the semijoin
 */
private void removeJoin(
    LoptMultiJoin multiJoin,
    SemiJoin semiJoin,
    int factIdx,
    int dimIdx) {
  // if the dimension can be removed because of another semijoin, then
  // no need to proceed any further
  if (multiJoin.getJoinRemovalFactor(dimIdx) != null) {
    return;
  }

  // Check if the semijoin keys corresponding to the dimension table
  // are unique.  The semijoin will filter out the nulls.
  final ImmutableBitSet dimKeys = ImmutableBitSet.of(semiJoin.getRightKeys());
  final RelNode dimRel = multiJoin.getJoinFactor(dimIdx);
  if (!RelMdUtil.areColumnsDefinitelyUniqueWhenNullsFiltered(mq, dimRel,
      dimKeys)) {
    return;
  }

  // check that the only fields referenced from the dimension table
  // in either its projection or join conditions are the dimension
  // keys
  ImmutableBitSet dimProjRefs = multiJoin.getProjFields(dimIdx);
  if (dimProjRefs == null) {
    int nDimFields = multiJoin.getNumFieldsInJoinFactor(dimIdx);
    dimProjRefs = ImmutableBitSet.range(0, nDimFields);
  }
  if (!dimKeys.contains(dimProjRefs)) {
    return;
  }
  int [] dimJoinRefCounts = multiJoin.getJoinFieldRefCounts(dimIdx);
  for (int i = 0; i < dimJoinRefCounts.length; i++) {
    if (dimJoinRefCounts[i] > 0) {
      if (!dimKeys.get(i)) {
        return;
      }
    }
  }

  // criteria met; keep track of the fact table and the semijoin that
  // allow the join of this dimension table to be removed
  multiJoin.setJoinRemovalFactor(dimIdx, factIdx);
  multiJoin.setJoinRemovalSemiJoin(dimIdx, semiJoin);

  // if the dimension table doesn't reference anything in its projection
  // and the only fields referenced in its joins are the dimension keys
  // of this semijoin, then we can decrement the join reference counts
  // corresponding to the fact table's semijoin keys, since the
  // dimension table doesn't need to use those keys
  if (dimProjRefs.cardinality() != 0) {
    return;
  }
  for (int i = 0; i < dimJoinRefCounts.length; i++) {
    if (dimJoinRefCounts[i] > 1) {
      return;
    } else if (dimJoinRefCounts[i] == 1) {
      if (!dimKeys.get(i)) {
        return;
      }
    }
  }
  int [] factJoinRefCounts = multiJoin.getJoinFieldRefCounts(factIdx);
  for (Integer key : semiJoin.getLeftKeys()) {
    factJoinRefCounts[key]--;
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:82,代码来源:LoptSemiJoinOptimizer.java

示例15: isKey

import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
public boolean isKey(ImmutableBitSet columns) {
  return !keyList.isEmpty()
      && columns.contains(ImmutableBitSet.of(keyList));
}
 
开发者ID:apache,项目名称:calcite,代码行数:5,代码来源:MockCatalogReader.java


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