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

morningman pushed a commit to branch tpch500
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/tpch500 by this push:
     new 8a836be882f [tmp] fix nullable bug
8a836be882f is described below

commit 8a836be882f0c7c81153f147ecc0f2b744ee9fa1
Author: morningman <morning...@163.com>
AuthorDate: Mon Jan 1 00:35:52 2024 +0800

    [tmp] fix nullable bug
---
 be/src/vec/common/hash_table/hash_map_context.h | 10 ++++++----
 be/src/vec/common/memcpy_small.h                |  9 +++++++--
 2 files changed, 13 insertions(+), 6 deletions(-)

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 031af96e799..4b43435876f 100644
--- a/be/src/vec/common/hash_table/hash_map_context.h
+++ b/be/src/vec/common/hash_table/hash_map_context.h
@@ -380,12 +380,14 @@ struct MethodKeysFixed : public MethodBase<TData> {
                             assert_cast<const 
ColumnUInt8&>(*nullmap_columns[j]).get_data().data();
                     for (size_t i = 0; i < row_numbers; ++i) {
                         // make sure null cell is filled by 0x0
-                        memcpy_fixed<Fixed>((char*)(&result[i]) + offset,
-                                            nullmap[i] ? (char*)&zero : data + 
i * sizeof(Fixed));
+                        memcpy_fixed<Fixed, true>(
+                                (char*)(&result[i]) + offset,
+                                nullmap[i] ? (char*)&zero : data + i * 
sizeof(Fixed));
                     }
                 } else {
                     for (size_t i = 0; i < row_numbers; ++i) {
-                        memcpy_fixed<Fixed>((char*)(&result[i]) + offset, data 
+ i * sizeof(Fixed));
+                        memcpy_fixed<Fixed, true>((char*)(&result[i]) + offset,
+                                                  data + i * sizeof(Fixed));
                     }
                 }
             };
@@ -476,7 +478,7 @@ struct MethodKeysFixed : public MethodBase<TData> {
             auto foo = [&]<typename Fixed>(Fixed zero) {
                 CHECK_EQ(sizeof(Fixed), size);
                 for (size_t j = 0; j < num_rows; j++) {
-                    memcpy_fixed<Fixed>(data + j * sizeof(Fixed), 
(char*)(&keys[j]) + pos);
+                    memcpy_fixed<Fixed, true>(data + j * sizeof(Fixed), 
(char*)(&keys[j]) + pos);
                 }
             };
 
diff --git a/be/src/vec/common/memcpy_small.h b/be/src/vec/common/memcpy_small.h
index af5d0e6074d..47390066318 100644
--- a/be/src/vec/common/memcpy_small.h
+++ b/be/src/vec/common/memcpy_small.h
@@ -82,7 +82,12 @@ inline void memcpy_small_allow_read_write_overflow15(void* 
__restrict dst,
 
 #endif
 
-template <typename T>
+// assume input address not aligned by default
+template <typename T, bool aligned = false>
 void memcpy_fixed(char* lhs, const char* rhs) {
-    *(T*)lhs = *(T*)rhs;
+    if constexpr (aligned || sizeof(T) <= 8) {
+        *(T*)lhs = *(T*)rhs;
+    } else {
+        memcpy(lhs, rhs, sizeof(T));
+    }
 }


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

Reply via email to