OmniSciDB  04ee39c94c
MurmurHash1Inl.h File Reference
+ Include dependency graph for MurmurHash1Inl.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

FORCE_INLINE DEVICE uint32_t MurmurHash1Impl (const void *key, int len, const uint32_t seed)
 
FORCE_INLINE DEVICE uint64_t MurmurHash64AImpl (const void *key, int len, uint64_t seed)
 

Function Documentation

◆ MurmurHash1Impl()

FORCE_INLINE DEVICE uint32_t MurmurHash1Impl ( const void *  key,
int  len,
const uint32_t  seed 
)

Definition at line 6 of file MurmurHash1Inl.h.

Referenced by get_matching_baseline_hash_slot_readonly(), MurmurHash1(), and write_baseline_hash_slot().

8  {
9  const unsigned int m = 0xc6a4a793;
10 
11  const int r = 16;
12 
13  unsigned int h = seed ^ (len * m);
14 
15  //----------
16 
17  const unsigned char* data = (const unsigned char*)key;
18 
19  while (len >= 4) {
20  unsigned int k = *(unsigned int*)data;
21 
22  h += k;
23  h *= m;
24  h ^= h >> 16;
25 
26  data += 4;
27  len -= 4;
28  }
29 
30  //----------
31 
32  switch (len) {
33  case 3:
34  h += data[2] << 16;
35  case 2:
36  h += data[1] << 8;
37  case 1:
38  h += data[0];
39  h *= m;
40  h ^= h >> r;
41  };
42 
43  //----------
44 
45  h *= m;
46  h ^= h >> 10;
47  h *= m;
48  h ^= h >> 17;
49 
50  return h;
51 }
+ Here is the caller graph for this function:

◆ MurmurHash64AImpl()

FORCE_INLINE DEVICE uint64_t MurmurHash64AImpl ( const void *  key,
int  len,
uint64_t  seed 
)

Definition at line 53 of file MurmurHash1Inl.h.

Referenced by approximate_distinct_tuples_impl(), and MurmurHash64A().

53  {
54  const uint64_t m = 0xc6a4a7935bd1e995LLU;
55  const int r = 47;
56 
57  uint64_t h = seed ^ (len * m);
58 
59  const uint64_t* data = (const uint64_t*)key;
60  const uint64_t* end = data + (len / 8);
61 
62  while (data != end) {
63  uint64_t k = *data++;
64 
65  k *= m;
66  k ^= k >> r;
67  k *= m;
68 
69  h ^= k;
70  h *= m;
71  }
72 
73  const unsigned char* data2 = (const unsigned char*)data;
74 
75  switch (len & 7) {
76  case 7:
77  h ^= ((uint64_t)data2[6]) << 48;
78  case 6:
79  h ^= ((uint64_t)data2[5]) << 40;
80  case 5:
81  h ^= ((uint64_t)data2[4]) << 32;
82  case 4:
83  h ^= ((uint64_t)data2[3]) << 24;
84  case 3:
85  h ^= ((uint64_t)data2[2]) << 16;
86  case 2:
87  h ^= ((uint64_t)data2[1]) << 8;
88  case 1:
89  h ^= ((uint64_t)data2[0]);
90  h *= m;
91  };
92 
93  h ^= h >> r;
94  h *= m;
95  h ^= h >> r;
96 
97  return h;
98 }
+ Here is the caller graph for this function: