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

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

commit e4993a19e52df8daecd483389e6989b466de67c9
Author: Pxl <pxl...@qq.com>
AuthorDate: Mon Apr 1 10:45:11 2024 +0800

    [Chore](column) remove ColumnVectorHelper (#33036)
    
    remove ColumnVectorHelper
---
 be/src/vec/columns/column_decimal.h             |  5 +--
 be/src/vec/columns/column_vector.h              | 11 ++---
 be/src/vec/columns/column_vector_helper.h       | 59 -------------------------
 be/src/vec/common/hash_table/hash_map_context.h |  7 +--
 be/src/vec/exec/vaggregation_node.h             |  1 -
 5 files changed, 6 insertions(+), 77 deletions(-)

diff --git a/be/src/vec/columns/column_decimal.h 
b/be/src/vec/columns/column_decimal.h
index 920f6ad8438..0dbd8c14027 100644
--- a/be/src/vec/columns/column_decimal.h
+++ b/be/src/vec/columns/column_decimal.h
@@ -33,7 +33,6 @@
 #include "runtime/define_primitive_type.h"
 #include "vec/columns/column.h"
 #include "vec/columns/column_impl.h"
-#include "vec/columns/column_vector_helper.h"
 #include "vec/common/assert_cast.h"
 #include "vec/common/cow.h"
 #include "vec/common/pod_array.h"
@@ -85,12 +84,12 @@ private:
 
 /// A ColumnVector for Decimals
 template <typename T>
-class ColumnDecimal final : public COWHelper<ColumnVectorHelper, 
ColumnDecimal<T>> {
+class ColumnDecimal final : public COWHelper<IColumn, ColumnDecimal<T>> {
     static_assert(IsDecimalNumber<T>);
 
 private:
     using Self = ColumnDecimal;
-    friend class COWHelper<ColumnVectorHelper, Self>;
+    friend class COWHelper<IColumn, Self>;
 
 public:
     using value_type = T;
diff --git a/be/src/vec/columns/column_vector.h 
b/be/src/vec/columns/column_vector.h
index ff9197df357..a2cfb7cd041 100644
--- a/be/src/vec/columns/column_vector.h
+++ b/be/src/vec/columns/column_vector.h
@@ -41,7 +41,6 @@
 #include "runtime/define_primitive_type.h"
 #include "vec/columns/column.h"
 #include "vec/columns/column_impl.h"
-#include "vec/columns/column_vector_helper.h"
 #include "vec/common/assert_cast.h"
 #include "vec/common/cow.h"
 #include "vec/common/pod_array_fwd.h"
@@ -129,12 +128,12 @@ struct CompareHelper<Float64> : public 
FloatCompareHelper<Float64> {};
 /** A template for columns that use a simple array to store.
  */
 template <typename T>
-class ColumnVector final : public COWHelper<ColumnVectorHelper, 
ColumnVector<T>> {
+class ColumnVector final : public COWHelper<IColumn, ColumnVector<T>> {
     static_assert(!IsDecimalNumber<T>);
 
 private:
     using Self = ColumnVector;
-    friend class COWHelper<ColumnVectorHelper, Self>;
+    friend class COWHelper<IColumn, Self>;
 
     struct less;
     struct greater;
@@ -239,11 +238,7 @@ public:
     }
 
     void insert_many_raw_data(const char* pos, size_t num) override {
-        if constexpr (std::is_same_v<T, vectorized::Int128>) {
-            insert_many_in_copy_way(pos, num);
-        } else {
-            insert_many_default_type(pos, num);
-        }
+        insert_many_in_copy_way(pos, num);
     }
 
     void insert_default() override { data.push_back(T()); }
diff --git a/be/src/vec/columns/column_vector_helper.h 
b/be/src/vec/columns/column_vector_helper.h
deleted file mode 100644
index 36b512be3f8..00000000000
--- a/be/src/vec/columns/column_vector_helper.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// 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.
-// This file is copied from
-// 
https://github.com/ClickHouse/ClickHouse/blob/master/src/Columns/ColumnVectorHelper.h
-// and modified by Doris
-
-#pragma once
-
-#include "vec/columns/column.h"
-
-namespace doris::vectorized {
-
-/** Allows to access internal array of ColumnVector or ColumnFixedString 
without cast to concrete type.
-  * We will inherit ColumnVector and ColumnFixedString from this class instead 
of IColumn.
-  * Assumes data layout of ColumnVector, ColumnFixedString and PODArray.
-  *
-  * Why it is needed?
-  *
-  * There are some algorithms that specialize on the size of data type but 
doesn't care about concrete type.
-  * The same specialization may work for UInt64, Int64, Float64, 
FixedString(8), if it only does byte moving and hashing.
-  * To avoid code bloat and compile time increase, we can use single template 
instantiation for these cases
-  *  and just static_cast pointer to some single column type (e. g. 
ColumnUInt64) assuming that all types have identical memory layout.
-  *
-  * But this static_cast (downcast to unrelated type) is illegal according to 
the C++ standard and UBSan warns about it.
-  * To allow functional tests to work under UBSan we have to separate some 
base class that will present the memory layout in explicit way,
-  *  and we will do static_cast to this class.
-  */
-class ColumnVectorHelper : public IColumn {
-public:
-    template <size_t ELEMENT_SIZE>
-    const char* get_raw_data_begin() const {
-        return reinterpret_cast<const PODArrayBase<ELEMENT_SIZE, 4096, 
Allocator<false>, 15, 16>*>(
-                       reinterpret_cast<const char*>(this) + sizeof(*this))
-                ->raw_data();
-    }
-
-    template <size_t ELEMENT_SIZE>
-    void insert_raw_data(const char* ptr) {
-        return reinterpret_cast<PODArrayBase<ELEMENT_SIZE, 4096, 
Allocator<false>, 15, 16>*>(
-                       reinterpret_cast<char*>(this) + sizeof(*this))
-                ->push_back_raw(ptr);
-    }
-};
-
-} // namespace doris::vectorized
diff --git a/be/src/vec/common/hash_table/hash_map_context.h 
b/be/src/vec/common/hash_table/hash_map_context.h
index 1536d48fe7a..f52be441dd6 100644
--- a/be/src/vec/common/hash_table/hash_map_context.h
+++ b/be/src/vec/common/hash_table/hash_map_context.h
@@ -346,12 +346,7 @@ struct MethodOneNumber : public MethodBase<TData> {
 
     void insert_keys_into_columns(std::vector<typename Base::Key>& input_keys,
                                   MutableColumns& key_columns, const size_t 
num_rows) override {
-        key_columns[0]->reserve(num_rows);
-        auto* column = static_cast<ColumnVectorHelper*>(key_columns[0].get());
-        for (size_t i = 0; i != num_rows; ++i) {
-            const auto* key_holder = reinterpret_cast<const 
char*>(&input_keys[i]);
-            column->insert_raw_data<sizeof(FieldType)>(key_holder);
-        }
+        key_columns[0]->insert_many_raw_data((char*)input_keys.data(), 
num_rows);
     }
 };
 
diff --git a/be/src/vec/exec/vaggregation_node.h 
b/be/src/vec/exec/vaggregation_node.h
index 594f25f6039..f09ebcbba83 100644
--- a/be/src/vec/exec/vaggregation_node.h
+++ b/be/src/vec/exec/vaggregation_node.h
@@ -41,7 +41,6 @@
 #include "vec/columns/column.h"
 #include "vec/columns/column_nullable.h"
 #include "vec/columns/column_string.h"
-#include "vec/columns/column_vector_helper.h"
 #include "vec/columns/columns_number.h"
 #include "vec/common/allocator.h"
 #include "vec/common/arena.h"


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to