mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-12 02:23:14 +00:00
Faster ColumnVector::replicate()
This commit is contained in:
parent
2e8dd9d9fc
commit
1c86a31431
@ -346,18 +346,14 @@ ColumnPtr ColumnVector<T>::replicate(const IColumn::Offsets & offsets) const
|
||||
if (0 == size)
|
||||
return this->create();
|
||||
|
||||
auto res = this->create();
|
||||
typename Self::Container & res_data = res->getData();
|
||||
res_data.reserve(offsets.back());
|
||||
auto res = this->create(offsets.back());
|
||||
|
||||
IColumn::Offset prev_offset = 0;
|
||||
auto it = res->getData().begin();
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
{
|
||||
size_t size_to_replicate = offsets[i] - prev_offset;
|
||||
prev_offset = offsets[i];
|
||||
|
||||
for (size_t j = 0; j < size_to_replicate; ++j)
|
||||
res_data.push_back(data[i]);
|
||||
const auto span_end = res->getData().begin() + offsets[i];
|
||||
for (; it < span_end; ++it)
|
||||
*it = data[i];
|
||||
}
|
||||
|
||||
return res;
|
||||
|
Loading…
Reference in New Issue
Block a user