This is an automated email from the ASF dual-hosted git repository.
panxiaolei 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 9cd25119b3d [Chore](gutil) move gutil/endian to vec/common (#53916)
9cd25119b3d is described below
commit 9cd25119b3da8475243b12d5b5e91e20850791fd
Author: Pxl <[email protected]>
AuthorDate: Mon Jul 28 10:14:13 2025 +0800
[Chore](gutil) move gutil/endian to vec/common (#53916)
move gutil/endian to vec/common
---
be/src/exec/decompressor.cpp | 2 +-
be/src/gutil/hash/city.cc | 28 +++------
be/src/gutil/hash/city.h | 4 +-
be/src/io/cache/cache_lru_dumper.cpp | 2 +-
be/src/olap/key_coder.h | 2 +-
be/src/olap/tablet_meta_manager.cpp | 5 +-
be/src/util/bit_util.h | 1 -
be/src/util/block_compression.cpp | 2 +-
be/src/util/coding.h | 2 +
be/src/util/frame_of_reference_coding.cpp | 2 +-
be/src/util/hash_util.hpp | 4 +-
be/src/util/murmur_hash3.cpp | 7 +--
be/src/util/murmur_hash3.h | 24 +-------
be/src/vec/columns/column.h | 2 +
be/src/{gutil => vec/common}/endian.h | 74 +++++------------------
be/src/vec/common/sip_hash.h | 35 ++++++-----
be/src/vec/common/uint128.h | 2 +-
be/src/vec/common/unaligned.h | 33 +---------
be/src/vec/exec/format/parquet/parquet_pred_cmp.h | 2 +-
be/src/vec/functions/function_ip.h | 16 +++--
be/test/util/bit_util_test.cpp | 1 +
21 files changed, 77 insertions(+), 173 deletions(-)
diff --git a/be/src/exec/decompressor.cpp b/be/src/exec/decompressor.cpp
index 17042372b15..e558c528c98 100644
--- a/be/src/exec/decompressor.cpp
+++ b/be/src/exec/decompressor.cpp
@@ -24,7 +24,7 @@
#include "common/logging.h"
#include "common/status.h"
-#include "gutil/endian.h"
+#include "vec/common/endian.h"
namespace doris {
diff --git a/be/src/gutil/hash/city.cc b/be/src/gutil/hash/city.cc
index 4bc50c73a7e..91c2fcbc776 100644
--- a/be/src/gutil/hash/city.cc
+++ b/be/src/gutil/hash/city.cc
@@ -17,22 +17,12 @@
#include "gutil/hash/city.h"
#include <algorithm>
-
-using std::copy;
-using std::max;
-using std::min;
-using std::reverse;
-using std::sort;
-using std::swap;
#include <utility>
-using std::make_pair;
-using std::pair;
-
#include "common/logging.h"
-#include "gutil/endian.h"
+#include "vec/common/endian.h"
-namespace util_hash {
+namespace doris::util_hash {
// Some primes between 2^63 and 2^64 for various uses.
static const uint64_t k0 = 0xa5b85c5e198ed849ULL;
@@ -110,19 +100,19 @@ static uint64_t HashLen17to32(const char* s, size_t len) {
// Return a 16-byte hash for 48 bytes. Quick and dirty.
// Callers do best to use "random-looking" values for a and b.
// (For more, see the code review discussion of CL 18799087.)
-static pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(uint64_t w, uint64_t x,
uint64_t y,
- uint64_t z, uint64_t a,
uint64_t b) {
+static std::pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(uint64_t w,
uint64_t x, uint64_t y,
+ uint64_t z,
uint64_t a, uint64_t b) {
a += w;
b = Rotate(b + a + z, 51);
uint64_t c = a;
a += x;
a += y;
b += Rotate(a, 23);
- return make_pair(a + z, b + c);
+ return std::make_pair(a + z, b + c);
}
// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
-static pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(const char* s, uint64_t
a, uint64_t b) {
+static std::pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(const char* s,
uint64_t a, uint64_t b) {
return WeakHashLen32WithSeeds(LittleEndian::Load64(s),
LittleEndian::Load64(s + 8),
LittleEndian::Load64(s + 16),
LittleEndian::Load64(s + 24), a, b);
}
@@ -168,8 +158,8 @@ uint64_t CityHash64(const char* s, size_t len) {
uint64_t y = LittleEndian::Load64(s + len - 16) + LittleEndian::Load64(s +
len - 56);
uint64_t z =
HashLen16(LittleEndian::Load64(s + len - 48) + len,
LittleEndian::Load64(s + len - 24));
- pair<uint64_t, uint64_t> v = WeakHashLen32WithSeeds(s + len - 64, len, z);
- pair<uint64_t, uint64_t> w = WeakHashLen32WithSeeds(s + len - 32, y + k1,
x);
+ std::pair<uint64_t, uint64_t> v = WeakHashLen32WithSeeds(s + len - 64,
len, z);
+ std::pair<uint64_t, uint64_t> w = WeakHashLen32WithSeeds(s + len - 32, y +
k1, x);
x = x * k1 + LittleEndian::Load64(s);
// Decrease len to the nearest multiple of 64, and operate on 64-byte
chunks.
@@ -199,4 +189,4 @@ uint64_t CityHash64WithSeeds(const char* s, size_t len,
uint64_t seed0, uint64_t
uint64_t CityHash64WithSeed(const char* s, size_t len, uint64_t seed) {
return CityHash64WithSeeds(s, len, k2, seed);
}
-} // namespace util_hash
+} // namespace doris::util_hash
diff --git a/be/src/gutil/hash/city.h b/be/src/gutil/hash/city.h
index d9460822215..2fb931443c9 100644
--- a/be/src/gutil/hash/city.h
+++ b/be/src/gutil/hash/city.h
@@ -27,7 +27,7 @@
// The implementation of cityhash in this file is somewhat different from
Google's original version.
// For the same input, there will be different output results.
// Therefore, we should do not to use this special cityhash as possible as we
can.
-namespace util_hash {
+namespace doris::util_hash {
uint64_t HashLen16(uint64_t u, uint64_t v);
@@ -38,4 +38,4 @@ uint64_t CityHash64(const char* buf, size_t len);
// Hash function for a byte array. For convenience, a 64-bit seed is also
// hashed into the result. The mapping may change from time to time.
uint64_t CityHash64WithSeed(const char* buf, size_t len, uint64_t seed);
-} // namespace util_hash
+} // namespace doris::util_hash
diff --git a/be/src/io/cache/cache_lru_dumper.cpp
b/be/src/io/cache/cache_lru_dumper.cpp
index 004a7b1a011..968b2a6b77e 100644
--- a/be/src/io/cache/cache_lru_dumper.cpp
+++ b/be/src/io/cache/cache_lru_dumper.cpp
@@ -18,9 +18,9 @@
#include "io/cache/cache_lru_dumper.h"
#include "io/cache/block_file_cache.h"
-#include "io/cache/cache_lru_dumper.h"
#include "io/cache/lru_queue_recorder.h"
#include "util/crc32c.h"
+#include "vec/common/endian.h"
namespace doris::io {
diff --git a/be/src/olap/key_coder.h b/be/src/olap/key_coder.h
index de046900bea..2a38c234958 100644
--- a/be/src/olap/key_coder.h
+++ b/be/src/olap/key_coder.h
@@ -29,11 +29,11 @@
#include "absl/strings/substitute.h"
#include "common/status.h"
-#include "gutil/endian.h"
#include "olap/decimal12.h"
#include "olap/olap_common.h"
#include "olap/types.h"
#include "util/slice.h"
+#include "vec/common/endian.h"
#include "vec/core/extended_types.h"
#include "vec/core/types.h"
diff --git a/be/src/olap/tablet_meta_manager.cpp
b/be/src/olap/tablet_meta_manager.cpp
index fda1e9e409a..b426a51e1ce 100644
--- a/be/src/olap/tablet_meta_manager.cpp
+++ b/be/src/olap/tablet_meta_manager.cpp
@@ -29,7 +29,6 @@
#include "common/logging.h"
#include "common/status.h"
-#include "gutil/endian.h"
#include "json2pb/json_to_pb.h"
#include "json2pb/pb_to_json.h"
#include "olap/data_dir.h"
@@ -230,8 +229,8 @@ void NO_SANITIZE_UNDEFINED
TabletMetaManager::decode_delete_bitmap_key(std::stri
TTabletId* tablet_id,
int64_t* version) {
DCHECK_EQ(enc_key.size(), 20);
- *tablet_id = to_endian<std::endian::big>(UNALIGNED_LOAD64(enc_key.data() +
4));
- *version = to_endian<std::endian::big>(UNALIGNED_LOAD64(enc_key.data() +
12));
+ *tablet_id =
to_endian<std::endian::big>(unaligned_load<uint64_t>(enc_key.data() + 4));
+ *version =
to_endian<std::endian::big>(unaligned_load<uint64_t>(enc_key.data() + 12));
}
Status TabletMetaManager::save_delete_bitmap(DataDir* store, TTabletId
tablet_id,
diff --git a/be/src/util/bit_util.h b/be/src/util/bit_util.h
index a81a35953dc..fb1c0b1fdc8 100644
--- a/be/src/util/bit_util.h
+++ b/be/src/util/bit_util.h
@@ -28,7 +28,6 @@
#endif
#include "common/compiler_util.h" // IWYU pragma: keep
-#include "gutil/endian.h"
#include "util/cpu_info.h"
#include "util/sse_util.hpp"
diff --git a/be/src/util/block_compression.cpp
b/be/src/util/block_compression.cpp
index c232f3d2059..f6fe0401693 100644
--- a/be/src/util/block_compression.cpp
+++ b/be/src/util/block_compression.cpp
@@ -52,10 +52,10 @@
#include "common/config.h"
#include "common/factory_creator.h"
#include "exec/decompressor.h"
-#include "gutil/endian.h"
#include "runtime/thread_context.h"
#include "util/defer_op.h"
#include "util/faststring.h"
+#include "vec/common/endian.h"
namespace orc {
/**
diff --git a/be/src/util/coding.h b/be/src/util/coding.h
index 67ae763dc95..8851f1af86c 100644
--- a/be/src/util/coding.h
+++ b/be/src/util/coding.h
@@ -9,6 +9,7 @@
#pragma once
#include <bit>
+
#ifndef __APPLE__
#include <endian.h>
#endif
@@ -17,6 +18,7 @@
#include "olap/olap_common.h"
#include "util/slice.h"
+#include "vec/common/endian.h"
namespace doris {
diff --git a/be/src/util/frame_of_reference_coding.cpp
b/be/src/util/frame_of_reference_coding.cpp
index e49058a6734..2d56df48213 100644
--- a/be/src/util/frame_of_reference_coding.cpp
+++ b/be/src/util/frame_of_reference_coding.cpp
@@ -27,9 +27,9 @@
#include <limits>
#include "common/cast_set.h"
-#include "gutil/endian.h"
#include "util/bit_util.h"
#include "util/coding.h"
+#include "vec/common/endian.h"
namespace doris {
#include "common/compile_check_begin.h"
diff --git a/be/src/util/hash_util.hpp b/be/src/util/hash_util.hpp
index ef6c98c4618..247fa46d5e7 100644
--- a/be/src/util/hash_util.hpp
+++ b/be/src/util/hash_util.hpp
@@ -28,9 +28,7 @@
#include <functional>
#include "common/compiler_util.h" // IWYU pragma: keep
-#include "gutil/endian.h"
#include "gutil/hash/city.h"
-#include "runtime/define_primitive_type.h"
#include "util/cpu_info.h"
#include "util/murmur_hash3.h"
#include "util/sse_util.hpp"
@@ -397,7 +395,7 @@ struct std::hash<std::pair<First, Second>> {
size_t operator()(const pair<First, Second>& p) const {
size_t h1 = std::hash<First>()(p.first);
size_t h2 = std::hash<Second>()(p.second);
- return util_hash::HashLen16(h1, h2);
+ return doris::util_hash::HashLen16(h1, h2);
}
};
diff --git a/be/src/util/murmur_hash3.cpp b/be/src/util/murmur_hash3.cpp
index 0cab7ee3047..23069862967 100644
--- a/be/src/util/murmur_hash3.cpp
+++ b/be/src/util/murmur_hash3.cpp
@@ -10,10 +10,8 @@
#include "murmur_hash3.h"
#include "vec/common/unaligned.h"
-//-----------------------------------------------------------------------------
-// Platform-specific functions and macros
-// Microsoft Visual Studio
+namespace doris {
#include "common/compile_check_begin.h"
#if defined(_MSC_VER)
@@ -504,4 +502,5 @@ void murmur_hash3_x64_64(const void* key, const int64_t
len, const uint64_t seed
((uint64_t*)out)[0] = h1;
}
#include "common/compile_check_end.h"
-//-----------------------------------------------------------------------------
+
+} // namespace doris
\ No newline at end of file
diff --git a/be/src/util/murmur_hash3.h b/be/src/util/murmur_hash3.h
index 24996646022..93e7ef13018 100644
--- a/be/src/util/murmur_hash3.h
+++ b/be/src/util/murmur_hash3.h
@@ -4,26 +4,8 @@
#pragma once
-//-----------------------------------------------------------------------------
-// Platform-specific functions and macros
-
-// Microsoft Visual Studio
-
-#if defined(_MSC_VER) && (_MSC_VER < 1600)
-
-typedef unsigned char uint8_t;
-typedef unsigned int uint32_t;
-typedef unsigned __int64 uint64_t;
-
-// Other compilers
-
-#else // defined(_MSC_VER)
-
-#include <stdint.h>
-
-#endif // !defined(_MSC_VER)
-
-//-----------------------------------------------------------------------------
+#include <cstdint>
+namespace doris {
void murmur_hash3_x86_32(const void* key, int64_t len, uint32_t seed, void*
out);
@@ -33,4 +15,4 @@ void murmur_hash3_x64_128(const void* key, int len, uint32_t
seed, void* out);
void murmur_hash3_x64_64(const void* key, int64_t len, uint64_t seed, void*
out);
-//-----------------------------------------------------------------------------
+} // namespace doris
\ No newline at end of file
diff --git a/be/src/vec/columns/column.h b/be/src/vec/columns/column.h
index df2806c7dc2..903a0679880 100644
--- a/be/src/vec/columns/column.h
+++ b/be/src/vec/columns/column.h
@@ -37,7 +37,9 @@
#include "vec/core/field.h"
#include "vec/core/types.h"
+namespace doris {
class SipHash;
+}
namespace doris::vectorized {
diff --git a/be/src/gutil/endian.h b/be/src/vec/common/endian.h
similarity index 70%
rename from be/src/gutil/endian.h
rename to be/src/vec/common/endian.h
index 739ef2358c3..b10a6f65c13 100644
--- a/be/src/gutil/endian.h
+++ b/be/src/vec/common/endian.h
@@ -1,5 +1,3 @@
-// Copyright 2005 Google Inc.
-//
// 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
@@ -16,54 +14,14 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-//
-// ---
-//
-//
-// Utility functions that depend on bytesex. We define htonll and ntohll,
-// as well as "Google" versions of all the standards: ghtonl, ghtons, and
-// so on. These functions do exactly the same as their standard variants,
-// but don't require including the dangerous netinet/in.h.
-//
-// Buffer routines will copy to and from buffers without causing
-// a bus error when the architecture requires different byte alignments
#pragma once
-#include <assert.h>
-
#include "olap/uint24.h"
+#include "vec/common/unaligned.h"
#include "vec/core/extended_types.h"
-inline uint16_t UNALIGNED_LOAD16(const void* p) {
- uint16_t t;
- memcpy(&t, p, sizeof t);
- return t;
-}
-
-inline uint32_t UNALIGNED_LOAD32(const void* p) {
- uint32_t t;
- memcpy(&t, p, sizeof t);
- return t;
-}
-
-inline uint64_t UNALIGNED_LOAD64(const void* p) {
- uint64_t t;
- memcpy(&t, p, sizeof t);
- return t;
-}
-
-inline void UNALIGNED_STORE16(void* p, uint16_t v) {
- memcpy(p, &v, sizeof v);
-}
-
-inline void UNALIGNED_STORE32(void* p, uint32_t v) {
- memcpy(p, &v, sizeof v);
-}
-
-inline void UNALIGNED_STORE64(void* p, uint64_t v) {
- memcpy(p, &v, sizeof v);
-}
+namespace doris {
inline uint64_t gbswap_64(uint64_t host_int) {
#if defined(__GNUC__) && defined(__x86_64__) && !defined(__APPLE__)
@@ -99,6 +57,7 @@ inline uint32_t bswap_24(uint32_t x) {
return ((x & 0x0000ffULL) << 16) | ((x & 0x00ff00ULL)) | ((x &
0xff0000ULL) >> 16);
}
+// use std::byteswap after doris enable cpp23
template <typename T>
T byte_swap(T x) {
if constexpr (sizeof(T) == sizeof(wide::Int256)) {
@@ -139,27 +98,27 @@ class LittleEndian {
public:
// Functions to do unaligned loads and stores in little-endian order.
static uint16_t Load16(const void* p) {
- return to_endian<std::endian::little>(UNALIGNED_LOAD16(p));
+ return to_endian<std::endian::little>(unaligned_load<uint16_t>(p));
}
static void Store16(void* p, uint16_t v) {
- UNALIGNED_STORE16(p, to_endian<std::endian::little>(v));
+ unaligned_store<uint16_t>(p, to_endian<std::endian::little>(v));
}
static uint32_t Load32(const void* p) {
- return to_endian<std::endian::little>(UNALIGNED_LOAD32(p));
+ return to_endian<std::endian::little>(unaligned_load<uint32_t>(p));
}
static void Store32(void* p, uint32_t v) {
- UNALIGNED_STORE32(p, to_endian<std::endian::little>(v));
+ unaligned_store<uint32_t>(p, to_endian<std::endian::little>(v));
}
static uint64_t Load64(const void* p) {
- return to_endian<std::endian::little>(UNALIGNED_LOAD64(p));
+ return to_endian<std::endian::little>(unaligned_load<uint64_t>(p));
}
static void Store64(void* p, uint64_t v) {
- UNALIGNED_STORE64(p, to_endian<std::endian::little>(v));
+ unaligned_store<uint64_t>(p, to_endian<std::endian::little>(v));
}
};
@@ -171,29 +130,28 @@ class BigEndian {
public:
// Functions to do unaligned loads and stores in little-endian order.
static uint16_t Load16(const void* p) {
- return to_endian<std::endian::big>(UNALIGNED_LOAD16(p));
+ return to_endian<std::endian::big>(unaligned_load<uint16_t>(p));
}
static void Store16(void* p, uint16_t v) {
- UNALIGNED_STORE16(p, to_endian<std::endian::big>(v));
+ unaligned_store<uint16_t>(p, to_endian<std::endian::big>(v));
}
static uint32_t Load32(const void* p) {
- return to_endian<std::endian::big>(UNALIGNED_LOAD32(p));
+ return to_endian<std::endian::big>(unaligned_load<uint32_t>(p));
}
static void Store32(void* p, uint32_t v) {
- UNALIGNED_STORE32(p, to_endian<std::endian::big>(v));
+ unaligned_store<uint32_t>(p, to_endian<std::endian::big>(v));
}
static uint64_t Load64(const void* p) {
- return to_endian<std::endian::big>(UNALIGNED_LOAD64(p));
+ return to_endian<std::endian::big>(unaligned_load<uint64_t>(p));
}
static void Store64(void* p, uint64_t v) {
- UNALIGNED_STORE64(p, to_endian<std::endian::big>(v));
+ unaligned_store<uint64_t>(p, to_endian<std::endian::big>(v));
}
}; // BigEndian
-// Network byte order is big-endian
-typedef BigEndian NetworkByteOrder;
+} // namespace doris
\ No newline at end of file
diff --git a/be/src/vec/common/sip_hash.h b/be/src/vec/common/sip_hash.h
index e22ebd829e7..8568d5bb7d0 100644
--- a/be/src/vec/common/sip_hash.h
+++ b/be/src/vec/common/sip_hash.h
@@ -40,7 +40,9 @@
#include "vec/common/unaligned.h"
#include "vec/core/types.h"
-#define ROTL(x, b) static_cast<doris::vectorized::UInt64>(((x) << (b)) | ((x)
>> (64 - (b))))
+namespace doris {
+
+#define ROTL(x, b) static_cast<vectorized::UInt64>(((x) << (b)) | ((x) >> (64
- (b))))
#define SIPROUND \
do { \
@@ -63,18 +65,18 @@
class SipHash {
private:
/// State.
- doris::vectorized::UInt64 v0;
- doris::vectorized::UInt64 v1;
- doris::vectorized::UInt64 v2;
- doris::vectorized::UInt64 v3;
+ vectorized::UInt64 v0;
+ vectorized::UInt64 v1;
+ vectorized::UInt64 v2;
+ vectorized::UInt64 v3;
/// How many bytes have been processed.
- doris::vectorized::UInt64 cnt;
+ vectorized::UInt64 cnt;
/// The current 8 bytes of input data.
union {
- doris::vectorized::UInt64 current_word;
- doris::vectorized::UInt8 current_bytes[8];
+ vectorized::UInt64 current_word;
+ vectorized::UInt8 current_bytes[8];
};
ALWAYS_INLINE void finalize() {
@@ -95,7 +97,7 @@ private:
public:
/// Arguments - seed.
- SipHash(doris::vectorized::UInt64 k0 = 0, doris::vectorized::UInt64 k1 =
0) {
+ SipHash(vectorized::UInt64 k0 = 0, vectorized::UInt64 k1 = 0) {
/// Initialize the state with some random bytes and seed.
v0 = 0x736f6d6570736575ULL ^ k0;
v1 = 0x646f72616e646f6dULL ^ k1;
@@ -106,7 +108,7 @@ public:
current_word = 0;
}
- void update(const char* data, doris::vectorized::UInt64 size) {
+ void update(const char* data, vectorized::UInt64 size) {
const char* end = data + size;
/// We'll finish to process the remainder of the previous update, if
any.
@@ -129,7 +131,7 @@ public:
cnt += end - data;
while (data + 8 <= end) {
- current_word = unaligned_load<doris::vectorized::UInt64>(data);
+ current_word = unaligned_load<vectorized::UInt64>(data);
v3 ^= current_word;
SIPROUND;
@@ -171,8 +173,7 @@ public:
template <typename T>
void update(const T& x) {
if constexpr (std::is_same_v<T, std::string>) {
- throw doris::Exception(doris::ErrorCode::INTERNAL_ERROR,
- "String should not use SipHash!");
+ throw Exception(ErrorCode::INTERNAL_ERROR, "String should not use
SipHash!");
}
update(reinterpret_cast<const char*>(&x), sizeof(x));
}
@@ -181,8 +182,8 @@ public:
void get128(char* out) {
finalize();
- reinterpret_cast<doris::vectorized::UInt64*>(out)[0] = v0 ^ v1;
- reinterpret_cast<doris::vectorized::UInt64*>(out)[1] = v2 ^ v3;
+ reinterpret_cast<vectorized::UInt64*>(out)[0] = v0 ^ v1;
+ reinterpret_cast<vectorized::UInt64*>(out)[1] = v2 ^ v3;
}
/// template for avoiding 'unsigned long long' vs 'unsigned long' problem
on old poco in macos
@@ -194,7 +195,7 @@ public:
hi = v2 ^ v3;
}
- doris::vectorized::UInt64 get64() {
+ vectorized::UInt64 get64() {
finalize();
return v0 ^ v1 ^ v2 ^ v3;
}
@@ -216,3 +217,5 @@ inline void sip_hash128(const char* data, const size_t
size, char* out) {
hash.update(data, size);
hash.get128(out);
}
+
+} // namespace doris
\ No newline at end of file
diff --git a/be/src/vec/common/uint128.h b/be/src/vec/common/uint128.h
index 19e80b57c26..bf50921afce 100644
--- a/be/src/vec/common/uint128.h
+++ b/be/src/vec/common/uint128.h
@@ -77,6 +77,6 @@ struct UInt136 {
template <>
struct std::hash<doris::vectorized::UInt128> {
size_t operator()(const doris::vectorized::UInt128& u) const {
- return util_hash::HashLen16(u.low(), u.high());
+ return doris::util_hash::HashLen16(u.low(), u.high());
}
};
diff --git a/be/src/vec/common/unaligned.h b/be/src/vec/common/unaligned.h
index ee807c606e5..9c449c16bbe 100644
--- a/be/src/vec/common/unaligned.h
+++ b/be/src/vec/common/unaligned.h
@@ -20,11 +20,11 @@
#pragma once
-#include <bit>
-#include <cstdint>
#include <cstring>
#include <type_traits>
+namespace doris {
+
template <typename T>
T unaligned_load(const void* address) {
T res {};
@@ -41,31 +41,4 @@ void unaligned_store(void* address, const typename
std::enable_if<true, T>::type
static_assert(std::is_trivially_copyable_v<T>);
memcpy(address, &src, sizeof(src));
}
-
-inline void reverse_memcpy(void* dst, const void* src, size_t size) {
- uint8_t* uint_dst = reinterpret_cast<uint8_t*>(dst) + size; // Perform
addition here
- const uint8_t* uint_src = reinterpret_cast<const uint8_t*>(src);
-
- while (size) {
- --uint_dst;
- *uint_dst = *uint_src;
- ++uint_src;
- --size;
- }
-}
-
-template <std::endian endian, typename T>
-inline T unaligned_load_endian(const void* address) {
- T res {};
- if constexpr (std::endian::native == endian) {
- memcpy(&res, address, sizeof(res));
- } else {
- reverse_memcpy(&res, address, sizeof(res));
- }
- return res;
-}
-
-template <typename T>
-inline T unaligned_load_little_endian(const void* address) {
- return unaligned_load_endian<std::endian::little, T>(address);
-}
\ No newline at end of file
+} // namespace doris
\ No newline at end of file
diff --git a/be/src/vec/exec/format/parquet/parquet_pred_cmp.h
b/be/src/vec/exec/format/parquet/parquet_pred_cmp.h
index bac6aa0b63e..e82c448bd46 100644
--- a/be/src/vec/exec/format/parquet/parquet_pred_cmp.h
+++ b/be/src/vec/exec/format/parquet/parquet_pred_cmp.h
@@ -23,9 +23,9 @@
#include "cctz/time_zone.h"
#include "exec/olap_common.h"
-#include "gutil/endian.h"
#include "parquet_common.h"
#include "util/timezone_utils.h"
+#include "vec/common/endian.h"
#include "vec/data_types/data_type_decimal.h"
#include "vec/exec/format/format_common.h"
#include "vec/exec/format/parquet/schema_desc.h"
diff --git a/be/src/vec/functions/function_ip.h
b/be/src/vec/functions/function_ip.h
index 651a0f9ea7a..2eb656e4882 100644
--- a/be/src/vec/functions/function_ip.h
+++ b/be/src/vec/functions/function_ip.h
@@ -32,9 +32,9 @@
#include "vec/columns/column_struct.h"
#include "vec/columns/column_vector.h"
#include "vec/common/assert_cast.h"
+#include "vec/common/endian.h"
#include "vec/common/format_ip.h"
#include "vec/common/ipv6_to_binary.h"
-#include "vec/common/unaligned.h"
#include "vec/core/column_with_type_and_name.h"
#include "vec/core/types.h"
#include "vec/data_types/data_type.h"
@@ -1026,9 +1026,8 @@ public:
private:
static bool is_ipv4_compat(const UInt8* address) {
- return (unaligned_load_little_endian<UInt64>(address) == 0) &&
- (unaligned_load_little_endian<UInt32>(address + 8) == 0) &&
- (unaligned_load_little_endian<UInt32>(address + 12) != 0);
+ return (LittleEndian::Load64(address) == 0) &&
(LittleEndian::Load32(address + 8) == 0) &&
+ (LittleEndian::Load32(address + 12) != 0);
}
};
@@ -1067,8 +1066,8 @@ public:
private:
static bool is_ipv4_mapped(const UInt8* address) {
- return (unaligned_load_little_endian<UInt64>(address) == 0) &&
- ((unaligned_load_little_endian<UInt64>(address + 8) &
0x00000000FFFFFFFFULL) ==
+ return (LittleEndian::Load64(address) == 0) &&
+ ((LittleEndian::Load64(address + 8) & 0x00000000FFFFFFFFULL) ==
0x00000000FFFF0000ULL);
}
};
@@ -1323,9 +1322,8 @@ public:
private:
static bool is_ipv4_mapped(const UInt8* address) {
- return (unaligned_load_little_endian<UInt64>(address + 8) == 0) &&
- ((unaligned_load_little_endian<UInt64>(address) &
0xFFFFFFFF00000000ULL) ==
- 0x0000FFFF00000000ULL);
+ return (LittleEndian::Load64(address + 8) == 0) &&
+ ((LittleEndian::Load64(address) & 0xFFFFFFFF00000000ULL) ==
0x0000FFFF00000000ULL);
}
static void cut_address(unsigned char* address, char*& dst, UInt8
zeroed_tail_bytes_count) {
diff --git a/be/test/util/bit_util_test.cpp b/be/test/util/bit_util_test.cpp
index 3dacf1ac867..f355b6a1c04 100644
--- a/be/test/util/bit_util_test.cpp
+++ b/be/test/util/bit_util_test.cpp
@@ -24,6 +24,7 @@
#include <boost/utility/binary.hpp>
#include "gtest/gtest_pred_impl.h"
+#include "vec/common/endian.h"
namespace doris {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]