This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch branch-1.2-lts in repository https://gitbox.apache.org/repos/asf/doris.git
commit c8ba5a7996f3a8cdf46577263876a50200484e7c Author: camby <104178...@qq.com> AuthorDate: Tue Dec 6 09:06:57 2022 +0800 [fix](ColumnVector) ColumnVector::insert_date_column crashed #14839 ColumnVector::insert_date_column make BE crashed with large data(>512 rows). Co-authored-by: cambyzju <zhuxiaol...@baidu.com> --- be/src/vec/columns/column_vector.h | 2 ++ be/test/CMakeLists.txt | 1 + be/test/vec/core/column_vector_test.cpp | 41 +++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/be/src/vec/columns/column_vector.h b/be/src/vec/columns/column_vector.h index 211e225e07..c944827fbc 100644 --- a/be/src/vec/columns/column_vector.h +++ b/be/src/vec/columns/column_vector.h @@ -166,6 +166,7 @@ public: } void insert_date_column(const char* data_ptr, size_t num) { + data.reserve(data.size() + num); size_t input_value_size = sizeof(uint24_t); for (int i = 0; i < num; i++) { @@ -180,6 +181,7 @@ public: } void insert_datetime_column(const char* data_ptr, size_t num) { + data.reserve(data.size() + num); size_t value_size = sizeof(uint64_t); for (int i = 0; i < num; i++) { const char* cur_ptr = data_ptr + value_size * i; diff --git a/be/test/CMakeLists.txt b/be/test/CMakeLists.txt index ec4a252872..e604715c5c 100644 --- a/be/test/CMakeLists.txt +++ b/be/test/CMakeLists.txt @@ -341,6 +341,7 @@ set(VEC_TEST_FILES vec/core/column_array_test.cpp vec/core/column_complex_test.cpp vec/core/column_nullable_test.cpp + vec/core/column_vector_test.cpp vec/exec/vgeneric_iterators_test.cpp vec/exec/vbroker_scan_node_test.cpp vec/exec/vbroker_scanner_test.cpp diff --git a/be/test/vec/core/column_vector_test.cpp b/be/test/vec/core/column_vector_test.cpp new file mode 100644 index 0000000000..d310e8a7e7 --- /dev/null +++ b/be/test/vec/core/column_vector_test.cpp @@ -0,0 +1,41 @@ + +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "vec/columns/column_vector.h" + +#include <gtest/gtest.h> + +#include <memory> +#include <string> + +#include "vec/data_types/data_type_date.h" + +namespace doris::vectorized { + +TEST(VColumnVectorTest, insert_date_column) { + auto column = ColumnVector<Int64>::create(); + + size_t rows = 4096; + int64_t val = 0; + for (size_t i = 0; i < rows; ++i) { + column->insert_date_column(reinterpret_cast<char*>(&val), 1); + } + ASSERT_EQ(column->size(), rows); +} + +} // namespace doris::vectorized --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org