This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 266bb971a6 [Enchancement](function) display elements number on
check_chars_length #16570
266bb971a6 is described below
commit 266bb971a6c74d10fb4e906615dd49010f79503f
Author: Pxl <[email protected]>
AuthorDate: Fri Feb 10 08:52:41 2023 +0800
[Enchancement](function) display elements number on check_chars_length
#16570
---
be/src/vec/columns/column_string.cpp | 10 +++++-----
be/src/vec/columns/column_string.h | 27 ++++++++++++++-------------
2 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/be/src/vec/columns/column_string.cpp
b/be/src/vec/columns/column_string.cpp
index 3bada76599..0c0447c341 100644
--- a/be/src/vec/columns/column_string.cpp
+++ b/be/src/vec/columns/column_string.cpp
@@ -83,7 +83,7 @@ void ColumnString::insert_range_from(const IColumn& src,
size_t start, size_t le
size_t nested_length = src_concrete.offsets[start + length - 1] -
nested_offset;
size_t old_chars_size = chars.size();
- check_chars_length(old_chars_size + nested_length);
+ check_chars_length(old_chars_size + nested_length, offsets.size() +
length);
chars.resize(old_chars_size + nested_length);
memcpy(&chars[old_chars_size], &src_concrete.chars[nested_offset],
nested_length);
@@ -219,7 +219,7 @@ const char*
ColumnString::deserialize_and_insert_from_arena(const char* pos) {
const size_t old_size = chars.size();
const size_t new_size = old_size + string_size;
- check_chars_length(new_size);
+ check_chars_length(new_size, offsets.size() + 1);
chars.resize(new_size);
memcpy(chars.data() + old_size, pos, string_size);
@@ -302,7 +302,7 @@ ColumnPtr ColumnString::index_impl(const
PaddedPODArray<Type>& indexes, size_t l
for (size_t i = 0; i < limit; ++i) {
new_chars_size += size_at(indexes[i]);
}
- check_chars_length(new_chars_size);
+ check_chars_length(new_chars_size, limit);
res_chars.resize(new_chars_size);
res_offsets.resize(limit);
@@ -402,7 +402,7 @@ ColumnPtr ColumnString::replicate(const Offsets&
replicate_offsets) const {
prev_string_offset = offsets[i];
}
- check_chars_length(res_chars.size());
+ check_chars_length(res_chars.size(), res_offsets.size());
return res;
}
@@ -441,7 +441,7 @@ void ColumnString::replicate(const uint32_t* counts, size_t
target_size, IColumn
prev_string_offset = offsets[i];
}
- check_chars_length(res_chars.size());
+ check_chars_length(res_chars.size(), res_offsets.size());
}
void ColumnString::reserve(size_t n) {
diff --git a/be/src/vec/columns/column_string.h
b/be/src/vec/columns/column_string.h
index 829a40a2cc..920f480484 100644
--- a/be/src/vec/columns/column_string.h
+++ b/be/src/vec/columns/column_string.h
@@ -61,9 +61,10 @@ private:
/// Size of i-th element, including terminating zero.
size_t ALWAYS_INLINE size_at(ssize_t i) const { return offsets[i] -
offsets[i - 1]; }
- void ALWAYS_INLINE check_chars_length(size_t length) const {
- if (UNLIKELY(length > MAX_STRING_SIZE)) {
- LOG(FATAL) << "string column length is too large: " << length;
+ void ALWAYS_INLINE check_chars_length(size_t total_length, size_t
element_number) const {
+ if (UNLIKELY(total_length > MAX_STRING_SIZE)) {
+ LOG(FATAL) << "string column length is too large: total_length="
<< total_length
+ << " ,element_number=" << element_number;
}
}
@@ -123,7 +124,7 @@ public:
const size_t size_to_append = s.size();
const size_t new_size = old_size + size_to_append;
- check_chars_length(new_size);
+ check_chars_length(new_size, old_size + 1);
chars.resize(new_size);
memcpy(chars.data() + old_size, s.c_str(), size_to_append);
@@ -147,7 +148,7 @@ public:
const size_t offset = src.offsets[n - 1];
const size_t new_size = old_size + size_to_append;
- check_chars_length(new_size);
+ check_chars_length(new_size, offsets.size() + 1);
chars.resize(new_size);
memcpy_small_allow_read_write_overflow15(chars.data() + old_size,
&src.chars[offset],
@@ -161,7 +162,7 @@ public:
const size_t new_size = old_size + length;
if (length) {
- check_chars_length(new_size);
+ check_chars_length(new_size, offsets.size() + 1);
chars.resize(new_size);
memcpy(chars.data() + old_size, pos, length);
}
@@ -173,7 +174,7 @@ public:
const size_t new_size = old_size + length;
if (length) {
- check_chars_length(new_size);
+ check_chars_length(new_size, offsets.size() + 1);
chars.resize(new_size);
memcpy(chars.data() + old_size, pos, length);
}
@@ -204,7 +205,7 @@ public:
length = 0;
}
}
- check_chars_length(offset);
+ check_chars_length(offset, offsets.size());
chars.resize(offset);
}
@@ -218,7 +219,7 @@ public:
const auto begin_offset = offsets_[0];
const size_t total_mem_size = offsets_[num] - begin_offset;
if (LIKELY(total_mem_size > 0)) {
- check_chars_length(total_mem_size + old_size);
+ check_chars_length(total_mem_size + old_size, offsets.size() +
num);
chars.resize(total_mem_size + old_size);
memcpy(chars.data() + old_size, data + begin_offset,
total_mem_size);
}
@@ -242,7 +243,7 @@ public:
}
const size_t old_size = chars.size();
- check_chars_length(old_size + new_size);
+ check_chars_length(old_size + new_size, offsets.size() + num);
chars.resize(old_size + new_size);
Char* data = chars.data();
@@ -264,7 +265,7 @@ public:
}
const size_t old_size = chars.size();
- check_chars_length(old_size + new_size);
+ check_chars_length(old_size + new_size, offsets.size() + num);
chars.resize(old_size + new_size);
Char* data = chars.data();
@@ -292,7 +293,7 @@ public:
offsets[offset_size + i] = new_size;
}
- check_chars_length(new_size);
+ check_chars_length(new_size, offsets.size());
chars.resize(new_size);
for (size_t i = start_index; i < start_index + num; i++) {
@@ -449,8 +450,8 @@ public:
chars.clear();
offsets[self_row] = data.size;
} else {
- check_chars_length(chars.size() + data.size);
offsets[self_row] = offsets[self_row - 1] + data.size;
+ check_chars_length(offsets[self_row], self_row);
}
chars.insert(data.data, data.data + data.size);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]