From 9e105b877c3676249d86a6845de48f7d7b98daba Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Mon, 23 Mar 2020 22:21:15 +0300 Subject: [PATCH] Update intHash. --- dbms/src/Common/HashTable/Hash.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dbms/src/Common/HashTable/Hash.h b/dbms/src/Common/HashTable/Hash.h index 11d84408b0a..8d4477d278f 100644 --- a/dbms/src/Common/HashTable/Hash.h +++ b/dbms/src/Common/HashTable/Hash.h @@ -71,6 +71,20 @@ inline DB::UInt64 intHashCRC32(DB::UInt64 x, DB::UInt64 updated_value) #endif } +template +inline typename std::enable_if<(sizeof(T) > sizeof(DB::UInt64)), DB::UInt64>::type +intHashCRC32(const T & x, DB::UInt64 updated_value) +{ + auto * begin64 = reinterpret_cast(&x); + for (size_t i = 0; i < sizeof(T); i += sizeof(UInt64)) + { + updated_value = intHashCRC32(*begin64, updated_value); + ++begin64; + } + + return updated_value; +} + inline UInt32 updateWeakHash32(const DB::UInt8 * pos, size_t size, DB::UInt32 updated_value) { if (size < 8)