mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-19 14:11:58 +00:00
30 lines
623 B
C++
30 lines
623 B
C++
|
#include <DB/Columns/ColumnString.h>
|
||
|
#include <DB/Columns/ColumnConst.h>
|
||
|
|
||
|
|
||
|
namespace DB
|
||
|
{
|
||
|
|
||
|
template <> ColumnPtr ColumnConst<String>::convertToFullColumn() const
|
||
|
{
|
||
|
ColumnString * res = new ColumnString;
|
||
|
ColumnString::Offsets_t & offsets = res->getOffsets();
|
||
|
ColumnUInt8::Container_t & vec = dynamic_cast<ColumnVector<UInt8> &>(res->getData()).getData();
|
||
|
|
||
|
size_t string_size = data.size() + 1;
|
||
|
size_t offset = 0;
|
||
|
offsets.resize(s);
|
||
|
vec.resize(s * string_size);
|
||
|
|
||
|
for (size_t i = 0; i < s; ++i)
|
||
|
{
|
||
|
memcpy(&vec[offset], data.data(), string_size);
|
||
|
offset += string_size;
|
||
|
offsets[i] = offset;
|
||
|
}
|
||
|
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
}
|