Skip to content

Commit

Permalink
Use builderWithExpectedSize in aggregation builder
Browse files Browse the repository at this point in the history
  • Loading branch information
pettyjamesm authored and wendigo committed Jul 18, 2024
1 parent 382ff20 commit 476bcce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public InMemoryHashAggregationBuilder(
UpdateMemory updateMemory)
{
if (hashChannel.isPresent()) {
this.groupByOutputTypes = ImmutableList.<Type>builder()
this.groupByOutputTypes = ImmutableList.<Type>builderWithExpectedSize(groupByTypes.size() + 1)
.addAll(groupByTypes)
.add(BIGINT)
.build();
Expand All @@ -126,8 +126,8 @@ public InMemoryHashAggregationBuilder(
this.updateMemory = requireNonNull(updateMemory, "updateMemory is null");

// wrapper each function with an aggregator
ImmutableList.Builder<GroupedAggregator> builder = ImmutableList.builder();
requireNonNull(aggregatorFactories, "aggregatorFactories is null");
ImmutableList.Builder<GroupedAggregator> builder = ImmutableList.builderWithExpectedSize(aggregatorFactories.size());
for (int i = 0; i < aggregatorFactories.size(); i++) {
AggregatorFactory accumulatorFactory = aggregatorFactories.get(i);
if (unspillIntermediateChannelOffset.isPresent()) {
Expand Down Expand Up @@ -333,7 +333,7 @@ public int nextInt()

public static List<Type> toTypes(List<? extends Type> groupByType, List<AggregatorFactory> factories, Optional<Integer> hashChannel)
{
ImmutableList.Builder<Type> types = ImmutableList.builder();
ImmutableList.Builder<Type> types = ImmutableList.builderWithExpectedSize(groupByType.size() + (hashChannel.isPresent() ? 1 : 0) + factories.size());
types.addAll(groupByType);
if (hashChannel.isPresent()) {
types.add(BIGINT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public MergingHashAggregationBuilder(
int overwriteIntermediateChannelOffset,
FlatHashStrategyCompiler hashStrategyCompiler)
{
ImmutableList.Builder<Integer> groupByPartialChannels = ImmutableList.builder();
ImmutableList.Builder<Integer> groupByPartialChannels = ImmutableList.builderWithExpectedSize(groupByTypes.size());
for (int i = 0; i < groupByTypes.size(); i++) {
groupByPartialChannels.add(i);
}
Expand Down

0 comments on commit 476bcce

Please sign in to comment.