MCPcopy Create free account
hub / github.com/catboost/catboost / MurmurHash32

Function MurmurHash32

util/digest/murmur.cpp:20–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18 // machines.
19
20 Y_NO_INLINE ui32 MurmurHash32(const void* key, size_t len, ui32 seed) noexcept {
21 const ui32 m = 0x5bd1e995;
22 const int r = 24;
23 ui32 h = ui32(seed ^ len);
24
25 TUnalignedMemoryIterator<ui32> iter(key, len);
26
27 while (!iter.AtEnd()) {
28 ui32 k = iter.Next();
29
30 k *= m;
31 k ^= k >> r;
32 k *= m;
33
34 h *= m;
35 h ^= k;
36 }
37
38 const unsigned char* data = iter.Last();
39
40 switch (iter.Left()) {
41 case 3:
42 h ^= data[2] << 16;
43 [[fallthrough]];
44
45 case 2:
46 h ^= data[1] << 8;
47 [[fallthrough]];
48
49 case 1:
50 h ^= data[0];
51 h *= m;
52 break;
53 }
54
55 h ^= h >> 13;
56 h *= m;
57 h ^= h >> 15;
58
59 return h;
60 }
61
62 //-----------------------------------------------------------------------------
63 // MurmurHash2, 64-bit versions, by Austin Appleby

Callers

nothing calls this directly

Calls 4

AtEndMethod · 0.45
NextMethod · 0.45
LastMethod · 0.45
LeftMethod · 0.45

Tested by

no test coverage detected