未验证 提交 25ffa844 编写于 作者: T Tao Luo 提交者: GitHub

refine murmurhash3_x64_128 for bloom_filter (#20996)

test=develop
上级 878a40f5
...@@ -101,46 +101,30 @@ void murmurhash3_x64_128(const void *key, const int len, const uint32_t seed, ...@@ -101,46 +101,30 @@ void murmurhash3_x64_128(const void *key, const int len, const uint32_t seed,
const uint8_t *tail = (const uint8_t *)(data + nblocks * 16); const uint8_t *tail = (const uint8_t *)(data + nblocks * 16);
uint64_t nk1 = 0; uint64_t nk1 = 0;
uint64_t nk2 = 0; uint64_t nk2 = 0;
// no break here!!!
switch (len & 15) { uint64_t tail0_64 = *(uint64_t *)(tail); // NOLINT
case 15: uint64_t tail_64 = *(uint64_t *)(tail + 8); // NOLINT
nk2 ^= ((uint64_t)tail[14]) << 48; uint64_t mask0 = 0xffffffffffffffff;
case 14: uint64_t mask = 0x00ffffffffffffff;
nk2 ^= ((uint64_t)tail[13]) << 40;
case 13: int flag = len & 15;
nk2 ^= ((uint64_t)tail[12]) << 32; if (flag && flag <= 8) {
case 12: tail0_64 &= (mask0 >> ((8 - flag) << 3));
nk2 ^= ((uint64_t)tail[11]) << 24; } else if (flag > 8) {
case 11: tail_64 &= (mask >> ((15 - flag) << 3));
nk2 ^= ((uint64_t)tail[10]) << 16; nk2 ^= tail_64;
case 10: nk2 *= c2;
nk2 ^= ((uint64_t)tail[9]) << 8; nk2 = ROTL64(nk2, 33);
case 9: nk2 *= c1;
nk2 ^= ((uint64_t)tail[8]) << 0; h2 ^= nk2;
nk2 *= c2; }
nk2 = ROTL64(nk2, 33);
nk2 *= c1; if (flag) {
h2 ^= nk2; nk1 ^= tail0_64;
case 8: nk1 *= c1;
nk1 ^= ((uint64_t)tail[7]) << 56; nk1 = ROTL64(nk1, 31);
case 7: nk1 *= c2;
nk1 ^= ((uint64_t)tail[6]) << 48; h1 ^= nk1;
case 6:
nk1 ^= ((uint64_t)tail[5]) << 40;
case 5:
nk1 ^= ((uint64_t)tail[4]) << 32;
case 4:
nk1 ^= ((uint64_t)tail[3]) << 24;
case 3:
nk1 ^= ((uint64_t)tail[2]) << 16;
case 2:
nk1 ^= ((uint64_t)tail[1]) << 8;
case 1:
nk1 ^= ((uint64_t)tail[0]) << 0;
nk1 *= c1;
nk1 = ROTL64(nk1, 31);
nk1 *= c2;
h1 ^= nk1;
} }
//---------- //----------
...@@ -158,9 +142,7 @@ void murmurhash3_x64_128(const void *key, const int len, const uint32_t seed, ...@@ -158,9 +142,7 @@ void murmurhash3_x64_128(const void *key, const int len, const uint32_t seed,
h1 += h2; h1 += h2;
h2 += h1; h2 += h1;
// ((uint64_t *)out)[0] = h1;
reinterpret_cast<uint64_t *>(out)[0] = h1; reinterpret_cast<uint64_t *>(out)[0] = h1;
// ((uint64_t *)out)[1] = h2;
reinterpret_cast<uint64_t *>(out)[1] = h2; reinterpret_cast<uint64_t *>(out)[1] = h2;
} }
......
...@@ -20,7 +20,6 @@ limitations under the License. */ ...@@ -20,7 +20,6 @@ limitations under the License. */
extern "C" { extern "C" {
#include "math/bloomfilter.h" #include "math/bloomfilter.h"
// void* memcpy1(void* dst, void* src, uint32_t length);
} }
namespace paddle { namespace paddle {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册