mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
optimize insertmanyfrom of nullable(number) or nullable(string)
This commit is contained in:
parent
8e9e162e29
commit
e789d15948
@ -56,6 +56,13 @@ public:
|
|||||||
void shrinkToFit() override { data.shrink_to_fit(); }
|
void shrinkToFit() override { data.shrink_to_fit(); }
|
||||||
|
|
||||||
void insertFrom(const IColumn & src, size_t n) override { data.push_back(static_cast<const Self &>(src).getData()[n]); }
|
void insertFrom(const IColumn & src, size_t n) override { data.push_back(static_cast<const Self &>(src).getData()[n]); }
|
||||||
|
|
||||||
|
void insertManyFrom(const IColumn & src, size_t position, size_t length) override
|
||||||
|
{
|
||||||
|
ValueType v = assert_cast<const Self &>(src).getData()[position];
|
||||||
|
data.resize_fill(data.size() + length, v);
|
||||||
|
}
|
||||||
|
|
||||||
void insertData(const char * src, size_t /*length*/) override;
|
void insertData(const char * src, size_t /*length*/) override;
|
||||||
void insertDefault() override { data.push_back(T()); }
|
void insertDefault() override { data.push_back(T()); }
|
||||||
void insertManyDefaults(size_t length) override { data.resize_fill(data.size() + length); }
|
void insertManyDefaults(size_t length) override { data.resize_fill(data.size() + length); }
|
||||||
|
@ -231,6 +231,14 @@ void ColumnNullable::insertFrom(const IColumn & src, size_t n)
|
|||||||
getNullMapData().push_back(src_concrete.getNullMapData()[n]);
|
getNullMapData().push_back(src_concrete.getNullMapData()[n]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ColumnNullable::insertManyFrom(const IColumn & src, size_t position, size_t length)
|
||||||
|
{
|
||||||
|
const ColumnNullable & src_concrete = assert_cast<const ColumnNullable &>(src);
|
||||||
|
getNestedColumn().insertManyFrom(src_concrete.getNestedColumn(), position, length);
|
||||||
|
getNullMapColumn().insertManyFrom(src_concrete.getNullMapColumn(), position, length);
|
||||||
|
}
|
||||||
|
|
||||||
void ColumnNullable::insertFromNotNullable(const IColumn & src, size_t n)
|
void ColumnNullable::insertFromNotNullable(const IColumn & src, size_t n)
|
||||||
{
|
{
|
||||||
getNestedColumn().insertFrom(src, n);
|
getNestedColumn().insertFrom(src, n);
|
||||||
|
@ -69,6 +69,7 @@ public:
|
|||||||
void insert(const Field & x) override;
|
void insert(const Field & x) override;
|
||||||
bool tryInsert(const Field & x) override;
|
bool tryInsert(const Field & x) override;
|
||||||
void insertFrom(const IColumn & src, size_t n) override;
|
void insertFrom(const IColumn & src, size_t n) override;
|
||||||
|
void insertManyFrom(const IColumn & src, size_t position, size_t length) override;
|
||||||
|
|
||||||
void insertFromNotNullable(const IColumn & src, size_t n);
|
void insertFromNotNullable(const IColumn & src, size_t n);
|
||||||
void insertRangeFromNotNullable(const IColumn & src, size_t start, size_t length);
|
void insertRangeFromNotNullable(const IColumn & src, size_t start, size_t length);
|
||||||
|
@ -38,6 +38,27 @@ ColumnString::ColumnString(const ColumnString & src)
|
|||||||
last_offset, chars.size());
|
last_offset, chars.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ColumnString::insertManyFrom(const IColumn & src, size_t position, size_t length)
|
||||||
|
{
|
||||||
|
const ColumnString & src_concrete = assert_cast<const ColumnString &>(src);
|
||||||
|
const UInt8 * src_buf = &src_concrete.chars[src_concrete.offsets[position - 1]];
|
||||||
|
const size_t src_buf_size
|
||||||
|
= src_concrete.offsets[position] - src_concrete.offsets[position - 1]; /// -1th index is Ok, see PaddedPODArray.
|
||||||
|
|
||||||
|
const size_t old_size = chars.size();
|
||||||
|
const size_t new_size = old_size + src_buf_size * length;
|
||||||
|
chars.resize(new_size);
|
||||||
|
|
||||||
|
const size_t old_rows = offsets.size();
|
||||||
|
offsets.resize(old_rows + length);
|
||||||
|
|
||||||
|
for (size_t current_offset = old_size; current_offset < new_size; current_offset += src_buf_size)
|
||||||
|
memcpySmallAllowReadWriteOverflow15(&chars[current_offset], src_buf, src_buf_size);
|
||||||
|
|
||||||
|
for (size_t i = 0, current_offset = old_size + src_buf_size; i < length; ++i, current_offset += src_buf_size)
|
||||||
|
offsets[old_rows + i] = current_offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MutableColumnPtr ColumnString::cloneResized(size_t to_size) const
|
MutableColumnPtr ColumnString::cloneResized(size_t to_size) const
|
||||||
{
|
{
|
||||||
|
@ -160,6 +160,8 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void insertManyFrom(const IColumn & src, size_t position, size_t length) override;
|
||||||
|
|
||||||
void insertData(const char * pos, size_t length) override
|
void insertData(const char * pos, size_t length) override
|
||||||
{
|
{
|
||||||
const size_t old_size = chars.size();
|
const size_t old_size = chars.size();
|
||||||
|
Loading…
Reference in New Issue
Block a user