Skip to content

Commit

Permalink
Rename getSizeInMemory to getSizeInMemoryWhenUnspilling
Browse files Browse the repository at this point in the history
  • Loading branch information
sopel39 committed Mar 12, 2019
1 parent 627d631 commit fe4271c
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,6 @@ public void updateMemory()
}
}

public long getSizeInMemory()
{
// TODO: we could skip memory reservation for hashAggregationBuilder.getGroupIdsSortingSize()
// if before building result from hashAggregationBuilder we would convert it to "read only" version.
// Read only version of GroupByHash from hashAggregationBuilder could be compacted by dropping
// most of it's field, freeing up some memory that could be used for sorting.
return hashAggregationBuilder.getSizeInMemory() + hashAggregationBuilder.getGroupIdsSortingSize();
}

@Override
public void recordHashCollisions(HashCollisionsCounter hashCollisionsCounter)
{
Expand Down Expand Up @@ -210,7 +201,7 @@ public WorkProcessor<Page> buildResult()
return hashAggregationBuilder.buildResult();
}

if (shouldMergeWithMemory(getSizeInMemory())) {
if (shouldMergeWithMemory(getSizeInMemoryWhenUnspilling())) {
return mergeFromDiskAndMemory();
}
else {
Expand All @@ -219,6 +210,18 @@ public WorkProcessor<Page> buildResult()
}
}

/**
* Estimates future memory usage, during unspilling.
*/
private long getSizeInMemoryWhenUnspilling()
{
// TODO: we could skip memory reservation for hashAggregationBuilder.getGroupIdsSortingSize()
// if before building result from hashAggregationBuilder we would convert it to "read only" version.
// Read only version of GroupByHash from hashAggregationBuilder could be compacted by dropping
// most of it's field, freeing up some memory that could be used for sorting.
return hashAggregationBuilder.getSizeInMemory() + hashAggregationBuilder.getGroupIdsSortingSize();
}

@Override
public void close()
{
Expand Down

0 comments on commit fe4271c

Please sign in to comment.