Balzanka / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Consider adding asBigInteger() to HashCode #1323

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I've encountered a few users internally who are e.g. converting a hash to a 
BigInteger and then modding it or something.

Original issue reported on code.google.com by lowas...@google.com on 7 Mar 2013 at 6:00

GoogleCodeExporter commented 9 years ago
Which hashing algorithms are they using? Presumably ones with >64 bits, right?

Original comment by kurt.kluever on 7 Mar 2013 at 6:04

GoogleCodeExporter commented 9 years ago
How often are they modding the results compared to doing something else? I've 
wondered before whether we'd benefit from a HashCode.bucket(int buckets) 
method. And then I wonder whether those users should use WeightedConsistentHash 
(which, incidentally, we should probably release).

Original comment by cpov...@google.com on 7 Mar 2013 at 6:06

GoogleCodeExporter commented 9 years ago
I wonder how much real world benefit these users actually get from expensively 
modding a 128-bit BigInteger over more cheaply modding the asInt(). I can only 
imagine that being bad if the modulus happens to be in the vicinity of 2^33/3, 
2^33/5, 2^33/7 or maybe a few more like that.

Original comment by kevinb@google.com on 7 Mar 2013 at 11:56

GoogleCodeExporter commented 9 years ago
My assumption was that the callers were concerned about negative numbers 
(<http://code.google.com/p/error-prone/issues/detail?id=77>), but I haven't 
even tried to confirm or deny that assumption.

Original comment by cpov...@google.com on 8 Mar 2013 at 4:28

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:13

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:18

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:08