6 #ifndef TURI_CITYHASH_GL_H_ 7 #define TURI_CITYHASH_GL_H_ 10 #include <core/util/code_optimization.hpp> 92 #include <nmmintrin.h> 96 #if defined( _MSC_VER) || defined(_WIN32) 99 #define bswap_32(x) _byteswap_ulong(x) 100 #define bswap_64(x) _byteswap_uint64(x) 102 #elif defined(__APPLE__) 105 #include <libkern/OSByteOrder.h> 106 #define bswap_32(x) OSSwapInt32(x) 107 #define bswap_64(x) OSSwapInt64(x) 109 #elif defined(__NetBSD__) 111 #include <sys/types.h> 112 #include <machine/bswap.h> 113 #if defined(__BSWAP_RENAME) && !defined(__bswap_32) 114 #define bswap_32(x) bswap32(x) 115 #define bswap_64(x) bswap64(x) 120 #include <byteswap.h> 124 #ifdef WORDS_BIGENDIAN 125 #define uint32_t_in_expected_order(x) (bswap_32(x)) 126 #define uint64_t_in_expected_order(x) (bswap_64(x)) 128 #define uint32_t_in_expected_order(x) (x) 129 #define uint64_t_in_expected_order(x) (x) 132 #define _CH_PERMUTE3(a, b, c) do { std::swap(a, b); std::swap(a, c); } while (0) 136 namespace cityhash_local {
138 typedef std::pair<uint64_t, uint64_t> local_uint128;
140 static inline uint64_t Uint128Low64(
const local_uint128& x) {
144 static inline uint64_t Uint128High64(
const local_uint128& x) {
148 static inline uint64_t UNALIGNED_LOAD64(
const char *p) {
150 memcpy(&result, p,
sizeof(result));
154 static inline uint32_t UNALIGNED_LOAD32(
const char *p) {
156 memcpy(&result, p,
sizeof(result));
160 static inline uint64_t Hash128to64(
const local_uint128& x) {
162 const uint64_t kMul = 0x9ddfea08eb382d69ULL;
163 uint64_t a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul;
165 uint64_t b = (Uint128High64(x) ^ a) * kMul;
171 static inline uint64_t Fetch64(
const char *p) {
172 return uint64_t_in_expected_order(UNALIGNED_LOAD64(p));
175 static inline uint32_t Fetch32(
const char *p) {
176 return uint32_t_in_expected_order(UNALIGNED_LOAD32(p));
180 static const uint64_t k0 = 0xc3a5c85c97cb3127ULL;
181 static const uint64_t k1 = 0xb492b66fbe98f273ULL;
182 static const uint64_t k2 = 0x9ae16a3b2f90404fULL;
185 static const uint32_t c1 = 0xcc9e2d51;
186 static const uint32_t c2 = 0x1b873593;
189 static inline uint32_t fmix(uint32_t h)
199 static inline uint32_t Rotate32(uint32_t val,
int shift) {
201 return shift == 0 ? val : ((val >> shift) | (val << (32 - shift)));
204 static inline uint32_t Mur(uint32_t a, uint32_t h) {
211 return h * 5 + 0xe6546b64;
214 static inline uint32_t Hash32Len13to24(
const char *s,
size_t len) {
215 uint32_t a = Fetch32(s - 4 + (len >> 1));
216 uint32_t b = Fetch32(s + 4);
217 uint32_t c = Fetch32(s + len - 8);
218 uint32_t d = Fetch32(s + (len >> 1));
219 uint32_t e = Fetch32(s);
220 uint32_t f = Fetch32(s + len - 4);
221 uint32_t h =
static_cast<uint32_t
>(len);
223 return fmix(Mur(f, Mur(e, Mur(d, Mur(c, Mur(b, Mur(a, h)))))));
226 static inline uint32_t Hash32Len0to4(
const char *s,
size_t len) {
229 for (
size_t i = 0; i < len; i++) {
230 signed char v = s[i];
234 return fmix(Mur(b, Mur(static_cast<uint32_t>(len), c)));
237 static inline uint32_t Hash32Len5to12(
const char *s,
size_t len) {
238 uint32_t a =
static_cast<uint32_t
>(len), b = static_cast<uint32_t>(len * 5), c = 9, d = b;
240 b += Fetch32(s + len - 4);
241 c += Fetch32(s + ((len >> 1) & 4));
242 return fmix(Mur(c, Mur(b, Mur(a, d))));
245 static inline uint32_t CityHash32(
const char *s,
size_t len) {
248 (len <= 4 ? Hash32Len0to4(s, len) : Hash32Len5to12(s, len)) :
249 Hash32Len13to24(s, len);
253 uint32_t h =
static_cast<uint32_t
>(len), g = static_cast<uint32_t>(c1 * len), f = g;
254 uint32_t a0 = Rotate32(Fetch32(s + len - 4) * c1, 17) * c2;
255 uint32_t a1 = Rotate32(Fetch32(s + len - 8) * c1, 17) * c2;
256 uint32_t a2 = Rotate32(Fetch32(s + len - 16) * c1, 17) * c2;
257 uint32_t a3 = Rotate32(Fetch32(s + len - 12) * c1, 17) * c2;
258 uint32_t a4 = Rotate32(Fetch32(s + len - 20) * c1, 17) * c2;
261 h = h * 5 + 0xe6546b64;
264 h = h * 5 + 0xe6546b64;
267 g = g * 5 + 0xe6546b64;
270 g = g * 5 + 0xe6546b64;
273 f = f * 5 + 0xe6546b64;
274 size_t iters = (len - 1) / 20;
276 uint32_t a0 = Rotate32(Fetch32(s) * c1, 17) * c2;
277 uint32_t a1 = Fetch32(s + 4);
278 uint32_t a2 = Rotate32(Fetch32(s + 8) * c1, 17) * c2;
279 uint32_t a3 = Rotate32(Fetch32(s + 12) * c1, 17) * c2;
280 uint32_t a4 = Fetch32(s + 16);
283 h = h * 5 + 0xe6546b64;
289 g = g * 5 + 0xe6546b64;
292 h = h * 5 + 0xe6546b64;
298 _CH_PERMUTE3(f, h, g);
300 }
while (--iters != 0);
301 g = Rotate32(g, 11) * c1;
302 g = Rotate32(g, 17) * c1;
303 f = Rotate32(f, 11) * c1;
304 f = Rotate32(f, 17) * c1;
305 h = Rotate32(h + g, 19);
306 h = h * 5 + 0xe6546b64;
307 h = Rotate32(h, 17) * c1;
308 h = Rotate32(h + f, 19);
309 h = h * 5 + 0xe6546b64;
310 h = Rotate32(h, 17) * c1;
316 static inline uint64_t Rotate(uint64_t val,
int shift) {
318 return shift == 0 ? val : ((val >> shift) | (val << (64 - shift)));
321 static inline uint64_t ShiftMix(uint64_t val) {
322 return val ^ (val >> 47);
325 static inline uint64_t HashLen16(uint64_t u, uint64_t v) {
326 return Hash128to64(local_uint128(u, v));
329 static inline uint64_t HashLen16(uint64_t u, uint64_t v, uint64_t mul) {
331 uint64_t a = (u ^ v) * mul;
333 uint64_t b = (v ^ a) * mul;
339 static inline uint64_t HashLen0to16(
const char *s,
size_t len) {
341 uint64_t mul = k2 + len * 2;
342 uint64_t a = Fetch64(s) + k2;
343 uint64_t b = Fetch64(s + len - 8);
344 uint64_t c = Rotate(b, 37) * mul + a;
345 uint64_t d = (Rotate(a, 25) + b) * mul;
346 return HashLen16(c, d, mul);
349 uint64_t mul = k2 + len * 2;
350 uint64_t a = Fetch32(s);
351 return HashLen16(len + (a << 3), Fetch32(s + len - 4), mul);
355 uint8_t b = s[len >> 1];
356 uint8_t c = s[len - 1];
357 uint32_t y =
static_cast<uint32_t
>(a) + (static_cast<uint32_t>(b) << 8);
358 uint32_t z =
static_cast<uint32_t
>(len) + (c << 2);
359 return ShiftMix(y * k2 ^ z * k0) * k2;
366 static inline uint64_t HashLen17to32(
const char *s,
size_t len) {
367 uint64_t mul = k2 + len * 2;
368 uint64_t a = Fetch64(s) * k1;
369 uint64_t b = Fetch64(s + 8);
370 uint64_t c = Fetch64(s + len - 8) * mul;
371 uint64_t d = Fetch64(s + len - 16) * k2;
372 return HashLen16(Rotate(a + b, 43) + Rotate(c, 30) + d,
373 a + Rotate(b + k2, 18) + c, mul);
378 static inline std::pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
379 uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) {
381 b = Rotate(b + a + z, 21);
386 return std::make_pair(a + z, b + c);
390 static inline std::pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
391 const char* s, uint64_t a, uint64_t b) {
392 return WeakHashLen32WithSeeds(Fetch64(s),
401 static uint64_t HashLen33to64(
const char *s,
size_t len) {
402 uint64_t mul = k2 + len * 2;
403 uint64_t a = Fetch64(s) * k2;
404 uint64_t b = Fetch64(s + 8);
405 uint64_t c = Fetch64(s + len - 24);
406 uint64_t d = Fetch64(s + len - 32);
407 uint64_t e = Fetch64(s + 16) * k2;
408 uint64_t f = Fetch64(s + 24) * 9;
409 uint64_t g = Fetch64(s + len - 8);
410 uint64_t h = Fetch64(s + len - 16) * mul;
411 uint64_t u = Rotate(a + g, 43) + (Rotate(b, 30) + c) * 9;
412 uint64_t v = ((a + g) ^ d) + f + 1;
413 uint64_t w = bswap_64((u + v) * mul) + h;
414 uint64_t x = Rotate(e + f, 42) + c;
415 uint64_t y = (bswap_64((v + w) * mul) + g) * mul;
416 uint64_t z = e + f + c;
417 a = bswap_64((x + z) * mul + y) + b;
418 b = ShiftMix((z + a) * mul + d + h) * mul;
422 static inline uint64_t CityHash64(
const char *s,
size_t len) {
425 return HashLen0to16(s, len);
427 return HashLen17to32(s, len);
429 }
else if (len <= 64) {
430 return HashLen33to64(s, len);
435 uint64_t x = Fetch64(s + len - 40);
436 uint64_t y = Fetch64(s + len - 16) + Fetch64(s + len - 56);
437 uint64_t z = HashLen16(Fetch64(s + len - 48) + len, Fetch64(s + len - 24));
438 std::pair<uint64_t, uint64_t> v = WeakHashLen32WithSeeds(s + len - 64, len, z);
439 std::pair<uint64_t, uint64_t> w = WeakHashLen32WithSeeds(s + len - 32, y + k1, x);
440 x = x * k1 + Fetch64(s);
443 len = (len - 1) & ~static_cast<size_t>(63);
445 x = Rotate(x + y + v.first + Fetch64(s + 8), 37) * k1;
446 y = Rotate(y + v.second + Fetch64(s + 48), 42) * k1;
448 y += v.first + Fetch64(s + 40);
449 z = Rotate(z + w.first, 33) * k1;
450 v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
451 w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch64(s + 16));
456 return HashLen16(HashLen16(v.first, w.first) + ShiftMix(y) * k1 + z,
457 HashLen16(v.second, w.second) + x);
460 static inline uint64_t CityHash64WithSeeds(
const char *s,
size_t len,
461 uint64_t seed0, uint64_t seed1) {
462 return HashLen16(CityHash64(s, len) - seed0, seed1);
465 static inline uint64_t CityHash64WithSeed(
const char *s,
size_t len, uint64_t
seed) {
466 return CityHash64WithSeeds(s, len, k2, seed);
471 static inline local_uint128 CityMurmur(
const char *s,
size_t len, local_uint128
seed) {
472 uint64_t a = Uint128Low64(seed);
473 uint64_t b = Uint128High64(seed);
476 signed long l = len - 16;
478 a = ShiftMix(a * k1) * k1;
479 c = b * k1 + HashLen0to16(s, len);
480 d = ShiftMix(a + (len >= 8 ? Fetch64(s) : c));
482 c = HashLen16(Fetch64(s + len - 8) + k1, a);
483 d = HashLen16(b + len, c + Fetch64(s + len - 16));
486 a ^= ShiftMix(Fetch64(s) * k1) * k1;
489 c ^= ShiftMix(Fetch64(s + 8) * k1) * k1;
498 return local_uint128(a ^ b, HashLen16(b, a));
501 static inline local_uint128 CityHash128WithSeed(
const char *s,
size_t len, local_uint128 seed) {
503 return CityMurmur(s, len, seed);
508 std::pair<uint64_t, uint64_t> v, w;
509 uint64_t x = Uint128Low64(seed);
510 uint64_t y = Uint128High64(seed);
511 uint64_t z = len * k1;
512 v.first = Rotate(y ^ k1, 49) * k1 + Fetch64(s);
513 v.second = Rotate(v.first, 42) * k1 + Fetch64(s + 8);
514 w.first = Rotate(y + z, 35) * k1 + x;
515 w.second = Rotate(x + Fetch64(s + 88), 53) * k1;
519 x = Rotate(x + y + v.first + Fetch64(s + 8), 37) * k1;
520 y = Rotate(y + v.second + Fetch64(s + 48), 42) * k1;
522 y += v.first + Fetch64(s + 40);
523 z = Rotate(z + w.first, 33) * k1;
524 v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
525 w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch64(s + 16));
528 x = Rotate(x + y + v.first + Fetch64(s + 8), 37) * k1;
529 y = Rotate(y + v.second + Fetch64(s + 48), 42) * k1;
531 y += v.first + Fetch64(s + 40);
532 z = Rotate(z + w.first, 33) * k1;
533 v = WeakHashLen32WithSeeds(s, v.second * k1, x + w.first);
534 w = WeakHashLen32WithSeeds(s + 32, z + w.second, y + Fetch64(s + 16));
538 }
while (LIKELY(len >= 128));
539 x += Rotate(v.first + z, 49) * k0;
540 y = y * k0 + Rotate(w.second, 37);
541 z = z * k0 + Rotate(w.first, 27);
545 for (
size_t tail_done = 0; tail_done < len; ) {
547 y = Rotate(x + y, 42) * k0 + v.second;
548 w.first += Fetch64(s + len - tail_done + 16);
549 x = x * k0 + w.first;
550 z += w.second + Fetch64(s + len - tail_done);
552 v = WeakHashLen32WithSeeds(s + len - tail_done, v.first + z, v.second);
558 x = HashLen16(x, v.first);
559 y = HashLen16(y + z, w.first);
560 return local_uint128(HashLen16(x + v.second, w.second) + y,
561 HashLen16(x + w.second, y + v.second));
564 static inline local_uint128 CityHash128(
const char *s,
size_t len) {
566 CityHash128WithSeed(s + 16, len - 16,
567 local_uint128(Fetch64(s), Fetch64(s + 8) + k0)) :
568 CityHash128WithSeed(s, len, local_uint128(k0, k1));
573 static void CityHashCrc256Long(
const char *s,
size_t len,
574 uint32_t seed, uint64_t *result) {
575 uint64_t a = Fetch64(s + 56) + k0;
576 uint64_t b = Fetch64(s + 96) + k0;
577 uint64_t c = result[0] = HashLen16(b, len);
578 uint64_t d = result[1] = Fetch64(s + 120) * k0 + len;
579 uint64_t e = Fetch64(s + 184) +
seed;
588 size_t iters = len / 240;
593 _CH_PERMUTE3(x, z, y); \ 595 c += Fetch64(s + 8); \ 596 d += Fetch64(s + 16); \ 597 e += Fetch64(s + 24); \ 598 f += Fetch64(s + 32); \ 606 z = _mm_crc32_u64(z, b + g); \ 607 y = _mm_crc32_u64(y, e + h); \ 608 x = _mm_crc32_u64(x, f + a); \ 613 CHUNK(0); _CH_PERMUTE3(a, h, c);
614 CHUNK(33); _CH_PERMUTE3(a, h, f);
615 CHUNK(0); _CH_PERMUTE3(b, h, f);
616 CHUNK(42); _CH_PERMUTE3(b, h, d);
617 CHUNK(0); _CH_PERMUTE3(b, h, e);
618 CHUNK(33); _CH_PERMUTE3(a, h, e);
619 }
while (--iters > 0);
627 _CH_PERMUTE3(c, h, g);
641 a = HashLen16(a, g + z);
644 c = HashLen16(c, z) + h;
645 d = HashLen16(d, e + result[0]);
647 h += HashLen16(x, f);
648 e = HashLen16(a, d) + g;
649 z = HashLen16(b, c) + a;
650 y = HashLen16(g, h) + c;
651 result[0] = e + z + y + x;
652 a = ShiftMix((a + y) * k0) * k0 + b;
653 result[1] += a + result[0];
654 a = ShiftMix(a * k0) * k0 + c;
655 result[2] = a + result[1];
656 a = ShiftMix((a + e) * k0) * k0;
657 result[3] = a + result[2];
661 static inline void CityHashCrc256Short(
const char *s,
size_t len, uint64_t *result) {
664 memset(buf + len, 0, 240 - len);
665 CityHashCrc256Long(buf, 240, ~static_cast<uint32_t>(len), result);
668 static inline void CityHashCrc256(
const char *s,
size_t len, uint64_t *result) {
669 if (LIKELY(len >= 240)) {
670 CityHashCrc256Long(s, len, 0, result);
672 CityHashCrc256Short(s, len, result);
676 static inline local_uint128 CityHashCrc128WithSeed(
const char *s,
size_t len, local_uint128 seed) {
678 return CityHash128WithSeed(s, len, seed);
681 CityHashCrc256(s, len, result);
682 uint64_t u = Uint128High64(seed) + result[0];
683 uint64_t v = Uint128Low64(seed) + result[1];
684 return local_uint128(HashLen16(u, v + result[2]),
685 HashLen16(Rotate(v, 32), u * k0 + result[3]));
689 static inline local_uint128 CityHashCrc128(
const char *s,
size_t len) {
691 return CityHash128(s, len);
694 CityHashCrc256(s, len, result);
695 return local_uint128(result[2], result[3]);
703 static inline uint64_t SimpleIntegerHash64(uint64_t s) {
705 static const uint64_t m = 0xc6a4a7935bd1e995ULL;
706 static const int r = 47;
713 uint64_t k = (uint64_t(s) ^ k0);
722 static inline local_uint128 SimpleIntegerHash128(uint64_t s1, uint64_t s2) {
728 static const uint64_t m = 0xc6a4a7935bd1e995ULL;
729 static const int r = 47;
738 k.first ^= k.first >> r;
739 k.second ^= k.second >> r;
750 static inline local_uint128 SimpleIntegerHash128(uint64_t s) {
752 static const uint64_t rand_int_1 = 0x6e626e7774e95a48ULL;
754 return SimpleIntegerHash128(s, rand_int_1 ^ s);
757 static inline local_uint128 Murmor3MixRoutine64(uint64_t x, uint64_t y, uint64_t seed) {
761 const uint64_t c1 = 0x87c37b91114253d5ULL;
762 const uint64_t c2 = 0x4cf5ad432745937fULL;
767 x *= c1; x = Rotate(x,31); x *= c2; h1 ^= x;
769 h1 = Rotate(h1,27); h1 += h2; h1 = h1*5+0x52dce729;
771 y *= c2; y = Rotate(y,33); y *= c1; h2 ^= y;
773 h2 = Rotate(h2,31); h2 += h1; h2 = h2*5+0x38495ab5;
775 return std::make_pair(h1, h2);
778 static inline local_uint128 Murmor3MixRoutine128(uint128_t x, uint128_t y, uint64_t seed) {
782 const uint64_t c1 = 0x87c37b91114253d5ULL;
783 const uint64_t c2 = 0x4cf5ad432745937fULL;
788 uint64_t x1 = uint64_t(x >> 64);
789 uint64_t x2 = uint64_t(x);
791 x1 *= c1; x1 = Rotate(x1,31); x1 *= c2; h1 ^= x1;
793 h1 = Rotate(h1,27); h1 += h2; h1 = h1*5+0x52dce729;
795 x2 *= c2; x2 = Rotate(x2,33); x2 *= c1; h2 ^= x2;
797 h2 = Rotate(h2,31); h2 += h1; h2 = h2*5+0x38495ab5;
799 uint64_t y1 = uint64_t(y >> 64);
800 uint64_t y2 = uint64_t(y);
802 y1 *= c1; y1 = Rotate(y1,31); y1 *= c2; h1 ^= y1;
804 h1 = Rotate(h1,27); h1 += h2; h1 = h1*5+0x52dce729;
806 y2 *= c2; y = Rotate(y2,33); y2 *= c1; h2 ^= y2;
808 h2 = Rotate(h2,31); h2 += h1; h2 = h2*5+0x38495ab5;
810 return std::make_pair(h1, h2);
833 static inline uint128_t
hash128(
const char* s,
size_t len) {
834 cityhash_local::local_uint128 r = cityhash_local::CityHash128(s, len);
836 return ((uint128_t(cityhash_local::Uint128High64(r)) << 64)
837 + uint128_t(cityhash_local::Uint128Low64(r)));
846 static inline uint128_t
hash128(
const std::string& s) {
847 return hash128(s.c_str(), s.size());
856 static inline uint128_t
hash128(uint128_t v) {
857 cityhash_local::local_uint128 r = cityhash_local::Murmor3MixRoutine64(
858 uint64_t(v >> 64), uint64_t(v), 0x8f84e92c0587b7e3ULL);
860 return ((uint128_t(cityhash_local::Uint128High64(r)) << 64)
861 + uint128_t(cityhash_local::Uint128Low64(r)));
870 template <
typename T>
872 const T& v,
typename std::enable_if<std::is_integral<T>::value &&
sizeof(T) <= 8>::type* = 0) {
874 cityhash_local::local_uint128 r = cityhash_local::SimpleIntegerHash128(uint64_t(v));
876 return ((uint128_t(cityhash_local::Uint128High64(r)) << 64)
877 + uint128_t(cityhash_local::Uint128Low64(r)));
888 cityhash_local::local_uint128 r = cityhash_local::SimpleIntegerHash128(v);
890 return ((uint128_t(cityhash_local::Uint128High64(r)) << 64)
891 + uint128_t(cityhash_local::Uint128Low64(r)));
908 uint128_t
hash128(
const std::vector<flexible_type>& v);
917 static inline uint64_t
hash64(
const char* s,
size_t len) {
918 return cityhash_local::CityHash64(s, len);
927 static inline uint64_t
hash64(
const std::string& s) {
928 return hash64(s.c_str(), s.size());
939 static inline uint64_t
hash64(uint64_t v1, uint64_t v2) {
940 static const uint64_t rand_int = 0x9fa35c8d77b96328ULL;
942 cityhash_local::local_uint128 r = cityhash_local::Murmor3MixRoutine64(v1, v2, rand_int);
944 return r.first ^ r.second;
956 static inline uint64_t
hash64(uint64_t v1, uint64_t v2, uint64_t v3) {
967 static inline uint64_t
hash64(uint128_t v) {
968 static const uint64_t rand_int = 0xf52ef6f00df6f718ULL;
970 uint64_t h1 = uint64_t(v >> 64);
971 uint64_t h2 = uint64_t(v);
973 cityhash_local::local_uint128 r = cityhash_local::Murmor3MixRoutine64(h1, h2, rand_int);
975 return r.first ^ r.second;
985 template <
typename T>
987 const T& v,
typename std::enable_if<std::is_integral<T>::value &&
sizeof(T) <= 8>::type* = 0) {
988 return cityhash_local::SimpleIntegerHash64(uint64_t(v));
1005 uint64_t
hash64(
const std::vector<flexible_type>& v);
1017 static const uint64_t rand_int = 0x5b73ff027f14f66aULL;
1021 cityhash_local::local_uint128 r = cityhash_local::Murmor3MixRoutine128(h1, h2, rand_int);
1023 return ((uint128_t(cityhash_local::Uint128High64(r)) << 64)
1024 + uint128_t(cityhash_local::Uint128Low64(r)));
1035 template <
typename T>
1046 static inline uint128_t
hash128(
const std::vector<std::string>& v) {
1047 uint128_t h =
hash128(v.size());
1048 for(
const std::string& s : v)
1064 static const uint64_t rand_int = 0x73a3916ae45d01e5ULL;
1066 cityhash_local::local_uint128 r = cityhash_local::Murmor3MixRoutine64(h1, h2, rand_int);
1068 return r.first ^ r.second;
1093 template <
typename T>
1104 static inline uint64_t
hash64(
const std::vector<std::string>& v) {
1105 uint64_t h =
hash64(v.size());
1106 for(
const std::string& s : v)
1122 cityhash_local::local_uint128 r = cityhash_local::SimpleIntegerHash128(index, seed);
1124 uint64_t h = r.first ^ r.second;
1125 return uint32_t(h ^ (h >> 32));
1138 static constexpr uint64_t m3_final_1 = 0xff51afd7ed558ccdULL;
1139 static constexpr uint64_t m3_final_2 = 0xc4ceb9fe1a85ec53ULL;
1141 static constexpr uint64_t r = 33;
1160 static constexpr uint64_t m3_final_1_inv = 0x4f74430c22a54005ULL;
1161 static constexpr uint64_t m3_final_2_inv = 0x9cb4b2f8129337dbULL;
1163 static constexpr uint64_t r = 33;
1168 h *= m3_final_2_inv;
1170 h *= m3_final_1_inv;
1186 #pragma clang diagnostic push 1187 #pragma clang diagnostic ignored "-Wmismatched-tags" 1190 #ifndef HASH_FOR_UINT128_DEFINED 1192 template <>
struct hash<uint128_t> {
1193 size_t operator()(
const uint128_t& t)
const {
1194 return size_t(t ^ (t >> 64));
1200 #ifndef HASH_FOR_INT128_DEFINED 1202 template <>
struct hash<int128_t> {
1203 size_t operator()(
const int128_t& t)
const {
1204 return size_t(t ^ (t >> 64));
1213 #pragma clang diagnostic pop static uint32_t simple_random_mapping(size_t index, size_t seed)
static uint128_t hash128(const char *s, size_t len)
static uint64_t reverse_index_hash(uint64_t idx)
static uint64_t hash64_combine(uint64_t h1, uint64_t h2)
static uint128_t hash128_combine(uint128_t h1, uint128_t h2)
static uint64_t hash64(const char *s, size_t len)
static uint64_t hash64_update(uint64_t h1, const T &t)
uint64_t hash64_proportion_cutoff(double proportion)
static uint128_t hash128_update(uint128_t h, const T &v)
static uint64_t index_hash(uint64_t idx)