Skip to content

Commit 92a0d1b

Browse files
committed
switch to hash function recommended by apache data sketch team
1 parent a03d0fc commit 92a0d1b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/metrics.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,15 @@ class Rate
109109
};
110110

111111
struct IPv4Hash {
112-
size_t operator()(uint32_t k) {
113-
return pcpp::fnv_hash((uint8_t*)&k, sizeof(k));
112+
size_t operator()(long long key) {
113+
// This hash function is taken from the internals of Austin Appleby's MurmurHash3 algorithm
114+
// see https://github.com/apache/incubator-datasketches-characterization/blob/master/cpp/src/frequent_items_sketch_timing_profile.cpp
115+
key ^= key >> 33;
116+
key *= 0xff51afd7ed558ccdL;
117+
key ^= key >> 33;
118+
key *= 0xc4ceb9fe1a85ec53L;
119+
key ^= key >> 33;
120+
return key;
114121
}
115122
};
116123

0 commit comments

Comments
 (0)