Allocates arena for SimpleAggregateFunction only if IAggregateFunction requires

This commit is contained in:
Azat Khuzhin 2019-05-18 17:29:33 +03:00
parent 2f471d6ea3
commit db274bf516
No known key found for this signature in database
GPG Key ID: B86086848EF8686D
2 changed files with 9 additions and 2 deletions

View File

@ -47,6 +47,9 @@ AggregatingSortedBlockInputStream::AggregatingSortedBlockInputStream(
{ {
// simple aggregate function // simple aggregate function
SimpleAggregateDescription desc{simple_aggr->getFunction(), i}; SimpleAggregateDescription desc{simple_aggr->getFunction(), i};
if (desc.function->allocatesMemoryInArena())
allocatesMemoryInArena = true;
columns_to_simple_aggregate.emplace_back(std::move(desc)); columns_to_simple_aggregate.emplace_back(std::move(desc));
} }
else else
@ -135,7 +138,8 @@ void AggregatingSortedBlockInputStream::merge(MutableColumns & merged_columns, s
for (auto & desc : columns_to_simple_aggregate) for (auto & desc : columns_to_simple_aggregate)
desc.createState(); desc.createState();
arena = std::make_unique<Arena>(); if (allocatesMemoryInArena)
arena = std::make_unique<Arena>();
++merged_rows; ++merged_rows;
} }

View File

@ -66,7 +66,10 @@ private:
*/ */
void insertSimpleAggregationResult(MutableColumns & merged_columns); void insertSimpleAggregationResult(MutableColumns & merged_columns);
/// Memory pool for SimpleAggregateFunction. /// Does SimpleAggregateFunction allocates memory in arena?
bool allocatesMemoryInArena = false;
/// Memory pool for SimpleAggregateFunction
/// (only when allocatesMemoryInArena == true).
std::unique_ptr<Arena> arena; std::unique_ptr<Arena> arena;
/// Stores information for aggregation of SimpleAggregateFunction columns /// Stores information for aggregation of SimpleAggregateFunction columns