Update ColumnAggregateFunction.cpp

This commit is contained in:
templarzq 2021-01-07 15:33:42 +08:00 committed by GitHub
parent 5e84769c74
commit 0b6c0d474f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -608,5 +608,36 @@ ColumnAggregateFunction::ColumnAggregateFunction(const ColumnAggregateFunction &
func(src_.func), src(src_.getPtr()), data(src_.data.begin(), src_.data.end()) func(src_.func), src(src_.getPtr()), data(src_.data.begin(), src_.data.end())
{ {
} }
//override method cloneResized
MutableColumnPtr ColumnAggregateFunction::cloneResized(size_t size) const {
//create a new col to return
auto cloneCol = cloneEmpty();
auto res = typeid_cast<ColumnAggregateFunction *>(cloneCol.get());
if (size == 0)
return cloneCol;
size_t from_size = data.size();
auto & res_data = res->data;
//copy data to cloned column
if (size <= from_size)
{
res_data.resize(size);
res->insertRangeFrom(*this, 0, size);
}
else
{
res_data.resize(from_size);
if (from_size > 0)
{
res->insertRangeFrom(*this, 0, from_size);
}
res->ensureOwnership();
for(int i=0;i<size-from_size;++i){
res->insertDefault();
}
}
return cloneCol;
}
} }