aboutsummaryrefslogtreecommitdiffstats
path: root/util/digest/city.h
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/digest/city.h
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/digest/city.h')
-rw-r--r--util/digest/city.h64
1 files changed, 32 insertions, 32 deletions
diff --git a/util/digest/city.h b/util/digest/city.h
index 675a798074..3c4b70fc55 100644
--- a/util/digest/city.h
+++ b/util/digest/city.h
@@ -1,48 +1,48 @@
-#pragma once
-
-#include <util/generic/utility.h>
+#pragma once
+
+#include <util/generic/utility.h>
#include <util/generic/strbuf.h>
-
+
#include <utility>
-
+
// NOTE: These functions provide CityHash 1.0 implementation whose results are *different* from
// the mainline version of CityHash.
using uint128 = std::pair<ui64, ui64>;
constexpr ui64 Uint128Low64(const uint128& x) {
- return x.first;
-}
-
+ return x.first;
+}
+
constexpr ui64 Uint128High64(const uint128& x) {
- return x.second;
-}
-
+ return x.second;
+}
+
// Hash functions for a byte array.
// http://en.wikipedia.org/wiki/CityHash
-Y_PURE_FUNCTION ui64 CityHash64(const char* buf, size_t len) noexcept;
-
-Y_PURE_FUNCTION ui64 CityHash64WithSeed(const char* buf, size_t len, ui64 seed) noexcept;
-
-Y_PURE_FUNCTION ui64 CityHash64WithSeeds(const char* buf, size_t len, ui64 seed0, ui64 seed1) noexcept;
-
-Y_PURE_FUNCTION uint128 CityHash128(const char* s, size_t len) noexcept;
-
-Y_PURE_FUNCTION uint128 CityHash128WithSeed(const char* s, size_t len, uint128 seed) noexcept;
-
-// Hash 128 input bits down to 64 bits of output.
-// This is intended to be a reasonably good hash function.
+Y_PURE_FUNCTION ui64 CityHash64(const char* buf, size_t len) noexcept;
+
+Y_PURE_FUNCTION ui64 CityHash64WithSeed(const char* buf, size_t len, ui64 seed) noexcept;
+
+Y_PURE_FUNCTION ui64 CityHash64WithSeeds(const char* buf, size_t len, ui64 seed0, ui64 seed1) noexcept;
+
+Y_PURE_FUNCTION uint128 CityHash128(const char* s, size_t len) noexcept;
+
+Y_PURE_FUNCTION uint128 CityHash128WithSeed(const char* s, size_t len, uint128 seed) noexcept;
+
+// Hash 128 input bits down to 64 bits of output.
+// This is intended to be a reasonably good hash function.
inline ui64 Hash128to64(const uint128& x) {
- // Murmur-inspired hashing.
- const ui64 kMul = 0x9ddfea08eb382d69ULL;
- ui64 a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul;
- a ^= (a >> 47);
- ui64 b = (Uint128High64(x) ^ a) * kMul;
- b ^= (b >> 47);
- b *= kMul;
- return b;
-}
+ // Murmur-inspired hashing.
+ const ui64 kMul = 0x9ddfea08eb382d69ULL;
+ ui64 a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul;
+ a ^= (a >> 47);
+ ui64 b = (Uint128High64(x) ^ a) * kMul;
+ b ^= (b >> 47);
+ b *= kMul;
+ return b;
+}
namespace NPrivateCityHash {
template <class TStringType>