You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by GitBox <gi...@apache.org> on 2019/12/30 04:19:06 UTC

[GitHub] [incubator-brpc] pexeer opened a new pull request #1009: bugfix to the hash function HashInts32.

pexeer opened a new pull request #1009: bugfix to the hash function HashInts32.
URL: https://github.com/apache/incubator-brpc/pull/1009
 
 
   the another optional solution of Issue #1007
   make right of the hash function of HashInts32.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] pexeer commented on a change in pull request #1009: bugfix to the hash function HashInts32.

Posted by GitBox <gi...@apache.org>.
pexeer commented on a change in pull request #1009: bugfix to the hash function HashInts32.
URL: https://github.com/apache/incubator-brpc/pull/1009#discussion_r364665770
 
 

 ##########
 File path: src/butil/containers/hash_tables.h
 ##########
 @@ -129,8 +129,10 @@ using BUTIL_HASH_NAMESPACE::hash_set;
 //
 // Contact danakj@chromium.org 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:
   good idea!

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] jamesge merged pull request #1009: bugfix to the hash function HashInts32.

Posted by GitBox <gi...@apache.org>.
jamesge merged pull request #1009: bugfix to the hash function HashInts32.
URL: https://github.com/apache/incubator-brpc/pull/1009
 
 
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] jamesge commented on a change in pull request #1009: bugfix to the hash function HashInts32.

Posted by GitBox <gi...@apache.org>.
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 danakj@chromium.org 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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org