jamesge commented on a change in pull request #1009: bugfix to the hash 
function HashInts32.
URL: https://github.com/apache/incubator-brpc/pull/1009#discussion_r362367108
 
 

 ##########
 File path: src/butil/containers/hash_tables.h
 ##########
 @@ -129,8 +129,10 @@ using BUTIL_HASH_NAMESPACE::hash_set;
 //
 // Contact [email protected] for any questions.
 inline std::size_t HashInts32(uint32_t value1, uint32_t value2) {
-  uint64_t value1_64 = value1;
-  uint64_t hash64 = (value1_64 << 32) | value2;
+  uint64_t short_random1 = 842304669U;
+  uint64_t short_random2 = 619063811U;
+
+  uint64_t hash64 =  short_random1 * value1 + short_random2 * value2;
 
 Review comment:
   please use 
[fmix64](https://github.com/apache/incubator-brpc/blob/fc07b7bf45c4b2aa90ae5c832f3b48a8da124640/src/butil/third_party/murmurhash3/murmurhash3.h#L57)((value1_64
 << 32) | value2) which is better studied.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to