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 32551a7263 [bugfix](predicate column) data maybe wrong if not a single page (#12796) 32551a7263 is described below commit 32551a7263369843214a7da02bebe43756183b56 Author: yiguolei <676222...@qq.com> AuthorDate: Thu Sep 22 09:55:31 2022 +0800 [bugfix](predicate column) data maybe wrong if not a single page (#12796) Co-authored-by: yiguolei <yiguo...@gmail.com> --- be/src/vec/columns/column_string.h | 5 ++--- be/src/vec/columns/predicate_column.h | 22 ++++++++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/be/src/vec/columns/column_string.h b/be/src/vec/columns/column_string.h index 783d79cf07..827ec896a7 100644 --- a/be/src/vec/columns/column_string.h +++ b/be/src/vec/columns/column_string.h @@ -168,9 +168,8 @@ public: for (size_t i = 0; i < num; i++) { uint32_t len = len_array[i]; uint32_t start_offset = start_offset_array[i]; - if (len) { - memcpy(data + offset, data_array + start_offset, len); - } + // memcpy will deal len == 0, not do it here + memcpy(data + offset, data_array + start_offset, len); offset += len; offsets.push_back(offset); } diff --git a/be/src/vec/columns/predicate_column.h b/be/src/vec/columns/predicate_column.h index 68a4095450..fd99d4c04b 100644 --- a/be/src/vec/columns/predicate_column.h +++ b/be/src/vec/columns/predicate_column.h @@ -278,15 +278,29 @@ public: } char* destination = (char*)_pool->allocate(total_mem_size); - memcpy(destination, data_array, total_mem_size); - // Resize the underline data to allow data copy directly + char* org_dst = destination; size_t org_elem_num = data.size(); data.resize(org_elem_num + num); + uint32_t fragment_start_offset = start_offset_array[0]; + size_t fragment_len = 0; for (size_t i = 0; i < num; i++) { - data[org_elem_num + i].ptr = destination; + data[org_elem_num + i].ptr = destination + fragment_len; data[org_elem_num + i].len = len_array[i]; - destination += len_array[i]; + fragment_len += len_array[i]; + // Compute the largest continuous memcpy block and copy them. + // If this is the last element in data array, then should copy the current memory block. + if (i == num - 1 || + start_offset_array[i + 1] != start_offset_array[i] + len_array[i]) { + memcpy(destination, data_array + fragment_start_offset, fragment_len); + destination += fragment_len; + fragment_start_offset = (i == num - 1 ? 0 : start_offset_array[i + 1]); + fragment_len = 0; + } } + CHECK(destination - org_dst == total_mem_size) + << "Copied size not equal to expected size"; + } else { + LOG(FATAL) << "Method insert_many_binary_data is not supported"; } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org