optimize insertFrom of ColumnAggregateFunction to share Aggregate State in some cases

This commit is contained in:
flynn 2022-09-30 03:11:57 +00:00
parent fb5de73bad
commit d666951cb1
2 changed files with 9 additions and 2 deletions

View File

@ -279,7 +279,7 @@ void ColumnAggregateFunction::insertRangeFrom(const IColumn & from, size_t start
size_t end = start + length;
for (size_t i = start; i < end; ++i)
insertFrom(from, i);
insertFromWithOwnership(from, i);
}
else
{
@ -448,7 +448,7 @@ void ColumnAggregateFunction::insertData(const char * pos, size_t /*length*/)
data.push_back(*reinterpret_cast<const AggregateDataPtr *>(pos));
}
void ColumnAggregateFunction::insertFrom(const IColumn & from, size_t n)
void ColumnAggregateFunction::insertFromWithOwnership(const IColumn & from, size_t n)
{
/// Must create new state of aggregate function and take ownership of it,
/// because ownership of states of aggregate function cannot be shared for individual rows,
@ -458,6 +458,11 @@ void ColumnAggregateFunction::insertFrom(const IColumn & from, size_t n)
insertMergeFrom(from, n);
}
void ColumnAggregateFunction::insertFrom(const IColumn & from, size_t n)
{
insertRangeFrom(from, n, 1);
}
void ColumnAggregateFunction::insertFrom(ConstAggregateDataPtr place)
{
ensureOwnership();

View File

@ -98,6 +98,8 @@ private:
ColumnAggregateFunction(const ColumnAggregateFunction & src_);
void insertFromWithOwnership(const IColumn & from, size_t n);
public:
~ColumnAggregateFunction() override;