/** Creates a group key with grouping sets, both identified by field positions * in the underlying relational expression. * * <p>This method of creating a group key does not allow you to group on new * expressions, only column projections, but is efficient, especially when you * are coming from an existing {@link Aggregate}. */ public GroupKey groupKey(ImmutableBitSet groupSet, boolean indicator, ImmutableList<ImmutableBitSet> groupSets) { if (groupSet.length() > peek().getRowType().getFieldCount()) { throw new IllegalArgumentException("out of bounds: " + groupSet); } if (groupSets == null) { groupSets = ImmutableList.of(groupSet); } final ImmutableList<RexNode> nodes = fields(ImmutableIntList.of(groupSet.toArray())); final List<ImmutableList<RexNode>> nodeLists = Lists.transform(groupSets, new Function<ImmutableBitSet, ImmutableList<RexNode>>() { public ImmutableList<RexNode> apply(ImmutableBitSet input) { return fields(ImmutableIntList.of(input.toArray())); } }); return groupKey(nodes, indicator, nodeLists); }
/** Creates a group key with grouping sets, both identified by field positions * in the underlying relational expression. * * <p>This method of creating a group key does not allow you to group on new * expressions, only column projections, but is efficient, especially when you * are coming from an existing {@link Aggregate}. */ public GroupKey groupKey(ImmutableBitSet groupSet, boolean indicator, ImmutableList<ImmutableBitSet> groupSets) { if (groupSet.length() > peek().getRowType().getFieldCount()) { throw new IllegalArgumentException("out of bounds: " + groupSet); } if (groupSets == null) { groupSets = ImmutableList.of(groupSet); } final ImmutableList<RexNode> nodes = fields(ImmutableIntList.of(groupSet.toArray())); final List<ImmutableList<RexNode>> nodeLists = Lists.transform(groupSets, new Function<ImmutableBitSet, ImmutableList<RexNode>>() { public ImmutableList<RexNode> apply(ImmutableBitSet input) { return fields(ImmutableIntList.of(input.toArray())); } }); return groupKey(nodes, indicator, nodeLists); }
private GroupKey groupKey_(ImmutableBitSet groupSet, boolean indicator, ImmutableList<ImmutableBitSet> groupSets) { if (groupSet.length() > peek().getRowType().getFieldCount()) { throw new IllegalArgumentException("out of bounds: " + groupSet); } if (groupSets == null) { groupSets = ImmutableList.of(groupSet); } final ImmutableList<RexNode> nodes = fields(ImmutableIntList.of(groupSet.toArray())); final List<ImmutableList<RexNode>> nodeLists = Lists.transform(groupSets, bitSet -> fields(ImmutableIntList.of(bitSet.toArray()))); return groupKey(nodes, indicator, nodeLists); }
private GroupKey groupKey_(ImmutableBitSet groupSet, boolean indicator, @Nonnull ImmutableList<ImmutableBitSet> groupSets) { if (groupSet.length() > peek().getRowType().getFieldCount()) { throw new IllegalArgumentException("out of bounds: " + groupSet); } Objects.requireNonNull(groupSets); final ImmutableList<RexNode> nodes = fields(ImmutableIntList.of(groupSet.toArray())); final List<ImmutableList<RexNode>> nodeLists = Util.transform(groupSets, bitSet -> fields(ImmutableIntList.of(bitSet.toArray()))); return groupKey_(nodes, indicator, nodeLists); }
/** * Tests the method * {@link org.apache.calcite.util.ImmutableBitSet#toArray}. */ @Test public void testToArray() { int[][] arrays = {{}, {0}, {0, 2}, {1, 65}, {100}}; for (int[] array : arrays) { assertThat(ImmutableBitSet.of(array).toArray(), equalTo(array)); } }
/** * Tests the method * {@link org.apache.calcite.util.ImmutableBitSet#toArray}. */ @Test public void testToArray() { int[][] arrays = {{}, {0}, {0, 2}, {1, 65}, {100}}; for (int[] array : arrays) { assertThat(ImmutableBitSet.of(array).toArray(), equalTo(array)); } }
builder.aggregate(builder.groupKey(agg.getGroupSet().toArray()), calls);
factors = bestEdge.factors.toArray();
factors = bestEdge.factors.toArray();
builder.aggregate(builder.groupKey(agg.getGroupSet().toArray()), calls); call.transformTo(builder.build());