mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 09:32:01 +00:00
ClickHouse: fixed FixedString. [#METR-9372]
This commit is contained in:
parent
6f46eb052c
commit
d2010d7876
@ -15,7 +15,6 @@ namespace DB
|
||||
class ColumnFixedString : public IColumn
|
||||
{
|
||||
public:
|
||||
//typedef std::vector<UInt8> Chars_t;
|
||||
typedef PODArray<UInt8> Chars_t;
|
||||
|
||||
private:
|
||||
@ -78,7 +77,7 @@ public:
|
||||
throw Exception("Too large string '" + s + "' for FixedString column", ErrorCodes::TOO_LARGE_STRING_SIZE);
|
||||
|
||||
size_t old_size = chars.size();
|
||||
chars.resize(old_size + n);
|
||||
chars.resize_fill(old_size + n);
|
||||
memcpy(&chars[old_size], s.data(), s.size());
|
||||
}
|
||||
|
||||
@ -103,7 +102,7 @@ public:
|
||||
|
||||
void insertDefault()
|
||||
{
|
||||
chars.resize(chars.size() + n);
|
||||
chars.resize_fill(chars.size() + n);
|
||||
}
|
||||
|
||||
int compareAt(size_t p1, size_t p2, const IColumn & rhs_, int nan_direction_hint) const
|
||||
|
@ -208,6 +208,18 @@ public:
|
||||
c_end = c_start + byte_size(n);
|
||||
}
|
||||
|
||||
/// Как resize, но обнуляет новые элементы.
|
||||
void resize_fill(size_t n)
|
||||
{
|
||||
size_t old_size = size();
|
||||
if (n > old_size)
|
||||
{
|
||||
reserve(n);
|
||||
memset(c_end, 0, n - old_size);
|
||||
}
|
||||
c_end = c_start + byte_size(n);
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
c_end = c_start;
|
||||
|
@ -45,7 +45,7 @@ template <> ColumnPtr ColumnConst<String>::convertToFullColumn() const
|
||||
ColumnPtr res_ptr = res;
|
||||
ColumnFixedString::Chars_t & vec = res->getChars();
|
||||
|
||||
vec.resize(n * s);
|
||||
vec.resize_fill(n * s);
|
||||
size_t offset = 0;
|
||||
|
||||
for (size_t i = 0; i < s; ++i)
|
||||
|
Loading…
Reference in New Issue
Block a user