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

lihaopeng 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 411f819306a [Opt](join) opt the join copy column from build side 
(#29007)
411f819306a is described below

commit 411f819306a15151fd9ebef8d5edaf6177f72184
Author: HappenLee <happen...@hotmail.com>
AuthorDate: Fri Dec 29 14:39:33 2023 +0800

    [Opt](join) opt the join copy column from build side (#29007)
---
 be/src/vec/columns/column_decimal.h  | 13 +++++++++----
 be/src/vec/columns/column_vector.cpp | 14 +++++++++-----
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/be/src/vec/columns/column_decimal.h 
b/be/src/vec/columns/column_decimal.h
index 9b1ad69bbad..3681f9190ae 100644
--- a/be/src/vec/columns/column_decimal.h
+++ b/be/src/vec/columns/column_decimal.h
@@ -124,11 +124,16 @@ public:
         auto origin_size = size();
         auto new_size = indices_end - indices_begin;
         data.resize(origin_size + new_size);
-        const T* __restrict src_data = reinterpret_cast<const 
T*>(src.get_raw_data().data);
 
-        for (uint32_t i = 0; i < new_size; ++i) {
-            data[origin_size + i] = src_data[indices_begin[i]];
-        }
+        auto copy = [](const T* __restrict src, T* __restrict dest,
+                       const uint32_t* __restrict begin, const uint32_t* 
__restrict end) {
+            for (auto it = begin; it != end; ++it) {
+                *dest = src[*it];
+                ++dest;
+            }
+        };
+        copy(reinterpret_cast<const T*>(src.get_raw_data().data), data.data() 
+ origin_size,
+             indices_begin, indices_end);
     }
 
     void insert_many_fix_len_data(const char* data_ptr, size_t num) override;
diff --git a/be/src/vec/columns/column_vector.cpp 
b/be/src/vec/columns/column_vector.cpp
index ca8db58fc98..7329f898044 100644
--- a/be/src/vec/columns/column_vector.cpp
+++ b/be/src/vec/columns/column_vector.cpp
@@ -372,11 +372,15 @@ void ColumnVector<T>::insert_indices_from(const IColumn& 
src, const uint32_t* in
     auto new_size = indices_end - indices_begin;
     data.resize(origin_size + new_size);
 
-    const T* __restrict src_data = reinterpret_cast<const 
T*>(src.get_raw_data().data);
-
-    for (uint32_t i = 0; i < new_size; ++i) {
-        data[origin_size + i] = src_data[indices_begin[i]];
-    }
+    auto copy = [](const T* __restrict src, T* __restrict dest, const 
uint32_t* __restrict begin,
+                   const uint32_t* __restrict end) {
+        for (auto it = begin; it != end; ++it) {
+            *dest = src[*it];
+            ++dest;
+        }
+    };
+    copy(reinterpret_cast<const T*>(src.get_raw_data().data), data.data() + 
origin_size,
+         indices_begin, indices_end);
 }
 
 template <typename T>


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

Reply via email to