本文整理汇总了Java中org.apache.calcite.util.ImmutableBitSet.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableBitSet.isEmpty方法的具体用法?Java ImmutableBitSet.isEmpty怎么用?Java ImmutableBitSet.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.util.ImmutableBitSet
的用法示例。
在下文中一共展示了ImmutableBitSet.isEmpty方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAllPossibleExpressions
import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的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>());
}
示例2: getDistinctRowCount
import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
public Double getDistinctRowCount(Filter rel, RelMetadataQuery mq,
ImmutableBitSet groupKey, RexNode predicate) {
if (predicate == null || predicate.isAlwaysTrue()) {
if (groupKey.isEmpty()) {
return 1D;
}
}
// REVIEW zfong 4/18/06 - In the Broadbase code, duplicates are not
// removed from the two filter lists. However, the code below is
// doing so.
RexNode unionPreds =
RelMdUtil.unionPreds(
rel.getCluster().getRexBuilder(),
predicate,
rel.getCondition());
return mq.getDistinctRowCount(rel.getInput(), groupKey, unionPreds);
}
示例3: getRowCount
import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
@Override
public Double getRowCount(Aggregate rel) {
ImmutableBitSet groupKey = ImmutableBitSet.range(rel.getGroupCount());
if (groupKey.isEmpty()) {
return 1.0;
} else {
return super.getRowCount(rel);
}
}
示例4: getDistinctRowCount
import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
public Double getDistinctRowCount(Aggregate rel, RelMetadataQuery mq,
ImmutableBitSet groupKey, RexNode predicate) {
if (predicate == null || predicate.isAlwaysTrue()) {
if (groupKey.isEmpty()) {
return 1D;
}
}
final ImmutableBitSet allGroupSet = rel.getGroupSet().union(groupKey);
return getDistinctRowCountFromEstimateRowCount(rel.getInput(), mq, allGroupSet, predicate);
}
示例5: getRowCount
import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
@Override
public Double getRowCount(Aggregate rel, RelMetadataQuery mq) {
ImmutableBitSet groupKey = ImmutableBitSet.range(rel.getGroupCount());
if (groupKey.isEmpty()) {
return 1.0;
} else {
return rel.estimateRowCount(mq);
}
}
示例6: getRowCount
import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
@Override
public Double getRowCount(Aggregate rel, RelMetadataQuery mq) {
ImmutableBitSet groupKey = ImmutableBitSet.range(rel.getGroupCount());
if (groupKey.isEmpty()) {
return 1.0;
} else {
return super.getRowCount(rel, mq);
}
}
示例7: 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 > 7, b + c < 10, a + e = 9}
* groupSet : { a, b}
* pulledUpExprs : { a > 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);
}
示例8: rollup
import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
/** Computes the rollup of bit sets.
*
* <p>For example, <code>rollup({0}, {1})</code>
* returns <code>({0, 1}, {0}, {})</code>.
*
* <p>Bit sets are not necessarily singletons:
* <code>rollup({0, 2}, {3, 5})</code>
* returns <code>({0, 2, 3, 5}, {0, 2}, {})</code>. */
@VisibleForTesting
public static ImmutableList<ImmutableBitSet> rollup(
List<ImmutableBitSet> bitSets) {
Set<ImmutableBitSet> builder = Sets.newLinkedHashSet();
for (;;) {
final ImmutableBitSet union = ImmutableBitSet.union(bitSets);
builder.add(union);
if (union.isEmpty()) {
break;
}
bitSets = bitSets.subList(0, bitSets.size() - 1);
}
return ImmutableList.copyOf(builder);
}
示例9: pushPredicateIntoCase
import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
/** Pushes predicates into a CASE.
*
* <p>We have a loose definition of 'predicate': any boolean expression will
* do, except CASE. For example '(CASE ...) = 5' or '(CASE ...) IS NULL'.
*/
public static RexCall pushPredicateIntoCase(RexCall call) {
if (call.getType().getSqlTypeName() != SqlTypeName.BOOLEAN) {
return call;
}
switch (call.getKind()) {
case CASE:
case AND:
case OR:
return call; // don't push CASE into CASE!
case EQUALS: {
// checks that the EQUALS operands may be splitted and
// doesn't push EQUALS into CASE
List<RexNode> equalsOperands = call.getOperands();
ImmutableBitSet left = RelOptUtil.InputFinder.bits(equalsOperands.get(0));
ImmutableBitSet right = RelOptUtil.InputFinder.bits(equalsOperands.get(1));
if (!left.isEmpty() && !right.isEmpty() && left.intersect(right).isEmpty()) {
return call;
}
}
}
int caseOrdinal = -1;
final List<RexNode> operands = call.getOperands();
for (int i = 0; i < operands.size(); i++) {
RexNode operand = operands.get(i);
switch (operand.getKind()) {
case CASE:
caseOrdinal = i;
}
}
if (caseOrdinal < 0) {
return call;
}
// Convert
// f(CASE WHEN p1 THEN v1 ... END, arg)
// to
// CASE WHEN p1 THEN f(v1, arg) ... END
final RexCall case_ = (RexCall) operands.get(caseOrdinal);
final List<RexNode> nodes = new ArrayList<>();
for (int i = 0; i < case_.getOperands().size(); i++) {
RexNode node = case_.getOperands().get(i);
if (!RexUtil.isCasePredicate(case_, i)) {
node = substitute(call, caseOrdinal, node);
}
nodes.add(node);
}
return case_.clone(call.getType(), nodes);
}