本文整理汇总了Java中org.apache.calcite.util.ImmutableBitSet.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableBitSet.Builder方法的具体用法?Java ImmutableBitSet.Builder怎么用?Java ImmutableBitSet.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.util.ImmutableBitSet
的用法示例。
在下文中一共展示了ImmutableBitSet.Builder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TableImpl
import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
private TableImpl(AbstractTableManager tableManager) {
this.tableManager = tableManager;
ImmutableBitSet.Builder builder = ImmutableBitSet.builder();
Table table = tableManager.getTable();
int index = 0;
for (Column c : table.getColumns()) {
if (table.isPrimaryKeyColumn(c.name)) {
builder.set(index);
}
index++;
}
keys = ImmutableList.of(builder.build());
}
示例2: remap
import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
private static ImmutableBitSet remap(ImmutableBitSet groupSet,
ImmutableBitSet bitSet) {
final ImmutableBitSet.Builder builder = ImmutableBitSet.builder();
for (Integer bit : bitSet) {
builder.set(remap(groupSet, bit));
}
return builder.build();
}
示例3: mergeAggregate
import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
private Aggregate mergeAggregate(Aggregate aggregate1, Aggregate aggregate2) {
//Support only simple groups
if (aggregate1.getGroupType() != Aggregate.Group.SIMPLE
|| aggregate2.getGroupType() != Aggregate.Group.SIMPLE) {
return null;
}
final int callLen1 = aggregate1.getAggCallList().size();
final int callLen2 = aggregate2.getAggCallList().size();
final List<AggregateCall> newAggCalls = Lists.newArrayList();
if (callLen1 <= callLen2) {
//Create new Call list
for (AggregateCall call : aggregate1.getAggCallList()) {
AggregateCall newAggCall = getMergedAggCall(aggregate2, call);
if (newAggCall == null) {
return null;
} else {
newAggCalls.add(newAggCall);
}
}
//Create new groupSets
ImmutableBitSet.Builder groupSetsBuilder = ImmutableBitSet.builder();
for (int key : aggregate1.getGroupSet()) {
try {
groupSetsBuilder.set(aggregate2.getGroupSet().nth(key));
} catch (IndexOutOfBoundsException e) {
return null;
}
}
final ImmutableBitSet newGroupSets = groupSetsBuilder.build();
return aggregate1.copy(aggregate1.getTraitSet(), aggregate2.getInput(),
aggregate1.indicator, newGroupSets, ImmutableList.of(newGroupSets), newAggCalls);
} else {
return null;
}
}
示例4: factorBitmap
import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
/**
* Sets the bitmap indicating which factors a filter references based on
* which fields it references
*
* @param fieldRefBitmap bitmap representing fields referenced
* @return bitmap representing factors referenced that will
* be set by this method
*/
private ImmutableBitSet factorBitmap(ImmutableBitSet fieldRefBitmap) {
ImmutableBitSet.Builder factorRefBitmap = ImmutableBitSet.builder();
for (int field : fieldRefBitmap) {
int factor = findRef(field);
factorRefBitmap.set(factor);
}
return factorRefBitmap.build();
}
示例5: toOrdinals
import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
static ImmutableBitSet toOrdinals(Iterable<Column> columns) {
final ImmutableBitSet.Builder builder = ImmutableBitSet.builder();
for (Column column : columns) {
builder.set(column.ordinal);
}
return builder.build();
}
示例6: toBitSet
import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
/** Converts a list of columns to a bit set of their ordinals. */
static ImmutableBitSet toBitSet(List<Column> columns) {
final ImmutableBitSet.Builder builder = ImmutableBitSet.builder();
for (Column column : columns) {
builder.set(column.ordinal);
}
return builder.build();
}
示例7: 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;
}
}
// determine which predicates can be applied on the child of the
// aggregate
final List<RexNode> notPushable = new ArrayList<>();
final List<RexNode> pushable = new ArrayList<>();
RelOptUtil.splitFilters(
rel.getGroupSet(),
predicate,
pushable,
notPushable);
final RexBuilder rexBuilder = rel.getCluster().getRexBuilder();
RexNode childPreds =
RexUtil.composeConjunction(rexBuilder, pushable, true);
// set the bits as they correspond to the child input
ImmutableBitSet.Builder childKey = ImmutableBitSet.builder();
RelMdUtil.setAggChildKeys(groupKey, rel, childKey);
Double distinctRowCount =
mq.getDistinctRowCount(rel.getInput(), childKey.build(), childPreds);
if (distinctRowCount == null) {
return null;
} else if (notPushable.isEmpty()) {
return distinctRowCount;
} else {
RexNode preds =
RexUtil.composeConjunction(rexBuilder, notPushable, true);
return distinctRowCount * RelMdUtil.guessSelectivity(preds);
}
}
示例8: trimChild
import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
/**
* Trims the fields of an input relational expression.
*
* @param rel Relational expression
* @param input Input relational expression, whose fields to trim
* @param fieldsUsed Bitmap of fields needed by the consumer
* @return New relational expression and its field mapping
*/
protected TrimResult trimChild(
RelNode rel,
RelNode input,
final ImmutableBitSet fieldsUsed,
Set<RelDataTypeField> extraFields) {
final ImmutableBitSet.Builder fieldsUsedBuilder = fieldsUsed.rebuild();
// Fields that define the collation cannot be discarded.
final RelMetadataQuery mq = rel.getCluster().getMetadataQuery();
final ImmutableList<RelCollation> collations = mq.collations(input);
for (RelCollation collation : collations) {
for (RelFieldCollation fieldCollation : collation.getFieldCollations()) {
fieldsUsedBuilder.set(fieldCollation.getFieldIndex());
}
}
// Correlating variables are a means for other relational expressions to use
// fields.
for (final CorrelationId correlation : rel.getVariablesSet()) {
rel.accept(
new CorrelationReferenceFinder() {
protected RexNode handle(RexFieldAccess fieldAccess) {
final RexCorrelVariable v =
(RexCorrelVariable) fieldAccess.getReferenceExpr();
if (v.id.equals(correlation)) {
fieldsUsedBuilder.set(fieldAccess.getField().getIndex());
}
return fieldAccess;
}
});
}
return dispatchTrimFields(input, fieldsUsedBuilder.build(), extraFields);
}
示例9: correlationColumns
import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
/** Finds which columns of a correlation variable are used within a
* relational expression. */
public static ImmutableBitSet correlationColumns(CorrelationId id,
RelNode rel) {
final CorrelationCollector collector = new CorrelationCollector();
rel.accept(collector);
final ImmutableBitSet.Builder builder = ImmutableBitSet.builder();
for (int field : collector.vuv.variableFields.get(id)) {
if (field >= 0) {
builder.set(field);
}
}
return builder.build();
}
示例10: setLeftRightBitmaps
import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
/**
* Separates a bit-mask representing a join into masks representing the left
* and right inputs into the join.
*
* @param groupKey original bit-mask
* @param leftMask left bit-mask to be set
* @param rightMask right bit-mask to be set
* @param nFieldsOnLeft number of fields in the left input
*/
public static void setLeftRightBitmaps(
ImmutableBitSet groupKey,
ImmutableBitSet.Builder leftMask,
ImmutableBitSet.Builder rightMask,
int nFieldsOnLeft) {
for (int bit : groupKey) {
if (bit < nFieldsOnLeft) {
leftMask.set(bit);
} else {
rightMask.set(bit - nFieldsOnLeft);
}
}
}
示例11: 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);
}
}
}
}
示例12: splitCols
import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
/**
* Forms two bitmaps by splitting the columns in a bitmap according to
* whether or not the column references the child input or is an expression
* @param projExprs Project expressions
* @param groupKey Bitmap whose columns will be split
* @param baseCols Bitmap representing columns from the child input
* @param projCols Bitmap representing non-child columns
*/
public static void splitCols(
List<RexNode> projExprs,
ImmutableBitSet groupKey,
ImmutableBitSet.Builder baseCols,
ImmutableBitSet.Builder projCols) {
for (int bit : groupKey) {
final RexNode e = projExprs.get(bit);
if (e instanceof RexInputRef) {
baseCols.set(((RexInputRef) e).getIndex());
} else {
projCols.set(bit);
}
}
}
示例13: getChildFactors
import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
/**
* Sets a bitmap indicating all child RelNodes in a join tree
*
* @param joinTree join tree to be examined
* @param childFactors bitmap to be set
*/
@Deprecated // to be removed before 2.0
public void getChildFactors(LoptJoinTree joinTree,
ImmutableBitSet.Builder childFactors) {
for (int child : joinTree.getTreeOrder()) {
childFactors.set(child);
}
}
示例14: getPopulationSize
import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
public Double getPopulationSize(Project rel, RelMetadataQuery mq,
ImmutableBitSet groupKey) {
ImmutableBitSet.Builder baseCols = ImmutableBitSet.builder();
ImmutableBitSet.Builder projCols = ImmutableBitSet.builder();
List<RexNode> projExprs = rel.getProjects();
RelMdUtil.splitCols(projExprs, groupKey, baseCols, projCols);
Double population =
mq.getPopulationSize(rel.getInput(), baseCols.build());
if (population == null) {
return null;
}
// No further computation required if the projection expressions are
// all column references
if (projCols.cardinality() == 0) {
return population;
}
for (int bit : projCols.build()) {
Double subRowCount =
RelMdUtil.cardOfProjExpr(mq, rel, projExprs.get(bit));
if (subRowCount == null) {
return null;
}
population *= subRowCount;
}
// REVIEW zfong 6/22/06 - Broadbase did not have the call to
// numDistinctVals. This is needed; otherwise, population can be
// larger than the number of rows in the RelNode.
return RelMdUtil.numDistinctVals(population, mq.getRowCount(rel));
}
示例15: splitLeftAndRightColumns
import org.apache.calcite.util.ImmutableBitSet; //导入方法依赖的package包/类
/** Splits a column set between left and right sets. */
private static Pair<ImmutableBitSet, ImmutableBitSet>
splitLeftAndRightColumns(int leftCount, final ImmutableBitSet columns) {
ImmutableBitSet.Builder leftBuilder = ImmutableBitSet.builder();
ImmutableBitSet.Builder rightBuilder = ImmutableBitSet.builder();
for (int bit : columns) {
if (bit < leftCount) {
leftBuilder.set(bit);
} else {
rightBuilder.set(bit - leftCount);
}
}
return Pair.of(leftBuilder.build(), rightBuilder.build());
}