You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2022/12/06 03:22:18 UTC

[doris] branch branch-1.1-lts updated: [fix](ColumnVector) ColumnVector::insert_date_column crashed #14839 (#14844)

This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-1.1-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-1.1-lts by this push:
     new 3608a2972d [fix](ColumnVector) ColumnVector::insert_date_column crashed #14839 (#14844)
3608a2972d is described below

commit 3608a2972d5f738da56acd66faa62b4784a683df
Author: camby <10...@qq.com>
AuthorDate: Tue Dec 6 11:22:12 2022 +0800

    [fix](ColumnVector) ColumnVector::insert_date_column crashed #14839 (#14844)
    
    ColumnVector::insert_date_column make BE crashed with large data(>512 rows).
    
    Co-authored-by: cambyzju <zh...@baidu.com>
    
    Co-authored-by: cambyzju <zh...@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 4d4ceb14e2..da5dcca787 100644
--- a/be/src/vec/columns/column_vector.h
+++ b/be/src/vec/columns/column_vector.h
@@ -169,6 +169,7 @@ public:
     }
 
     void insert_date_column(const char* data_ptr, size_t num) {
+        data.reserve(data.size() + num);
         size_t value_size = sizeof(uint24_t);
         for (int i = 0; i < num; i++) {
             const char* cur_ptr = data_ptr + value_size * i;
@@ -184,6 +185,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 437dd4e354..b1f060c228 100644
--- a/be/test/CMakeLists.txt
+++ b/be/test/CMakeLists.txt
@@ -336,6 +336,7 @@ set(VEC_TEST_FILES
     vec/core/block_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/exprs/vexpr_test.cpp
     vec/function/function_bitmap_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-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org