You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by al...@apache.org on 2020/04/27 23:05:05 UTC

[incubator-datasketches-cpp] 01/02: mix the result of given hash function in case it is not very good

This is an automated email from the ASF dual-hosted git repository.

alsay pushed a commit to branch fi_use_fmix64
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-cpp.git

commit 9972cc292bd52adf73bf1a07b1e9a7dab216ff8e
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Mon Apr 27 16:03:36 2020 -0700

    mix the result of given hash function in case it is not very good
---
 fi/include/reverse_purge_hash_map_impl.hpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fi/include/reverse_purge_hash_map_impl.hpp b/fi/include/reverse_purge_hash_map_impl.hpp
index c8fdccd..ad2d9d9 100644
--- a/fi/include/reverse_purge_hash_map_impl.hpp
+++ b/fi/include/reverse_purge_hash_map_impl.hpp
@@ -25,6 +25,8 @@
 #include <iterator>
 #include <cmath>
 
+#include "MurmurHash3.h"
+
 namespace datasketches {
 
 // clang++ seems to require this declaration for CMAKE_BUILD_TYPE='Debug"
@@ -147,7 +149,7 @@ V reverse_purge_hash_map<K, V, H, E, A>::adjust_or_insert(K&& key, V value) {
 template<typename K, typename V, typename H, typename E, typename A>
 V reverse_purge_hash_map<K, V, H, E, A>::get(const K& key) const {
   const uint32_t mask = (1 << lg_cur_size) - 1;
-  uint32_t probe = H()(key) & mask;
+  uint32_t probe = fmix64(H()(key)) & mask;
   while (is_active(probe)) {
     if (E()(keys[probe], key)) return values[probe];
     probe = (probe + 1) & mask;
@@ -256,7 +258,7 @@ void reverse_purge_hash_map<K, V, H, E, A>::hash_delete(uint32_t delete_index) {
 template<typename K, typename V, typename H, typename E, typename A>
 uint32_t reverse_purge_hash_map<K, V, H, E, A>::internal_adjust_or_insert(const K& key, V value) {
   const uint32_t mask = (1 << lg_cur_size) - 1;
-  uint32_t index = H()(key) & mask;
+  uint32_t index = fmix64(H()(key)) & mask;
   uint16_t drift = 1;
   while (is_active(index)) {
     if (E()(keys[index], key)) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org