4 ms·
Your other option is to hash your monotonically increasing numbers. You don't want to use something like SHA, as it does not give good distribution. You use som
by kyrra 5y ago
Your other option is to hash your monotonically increasing numbers. You don't want to use something like SHA, as it does not give good distribution. You use something like murmur hash (https://en.m.wikipedia.org/wiki/MurmurHash https://en.m.wikipedia.org/wiki/MurmurHash). I've used it before for indexes at Google for values that may hotspot. See Google's impl here: https://github.com/google/zetasketch/blob/master/java/com/google/zetasketch/internal/hash/Fingerprint2011.java https://github.com/google/zetasketch/blob/master/java/com/go...
- rossmohax 5y ago> You don't want to use something like SHA, as it does not give good distribution How come? Even distribution is one of requirements for crypto hash functions.
- kyrra 5y agoYou know, likely am wrong here. I think murmur is good because it had a good distribution and is much faster than SHA? I did find someone that compared murmur to other non crypt hashes here: https://softwareengineering.stackexchange.com/a/145633 https://softwareengineering.stackexchange.com/a/145633. I'd love to see this compared with sha1.
- isoprophlex 5y agoCan you elaborate on the claim about SHA? If I'm not mistaken, all these cryptographic hashes have a 50% chance of flipping any one output bit upon changing a single input bit -- is there some hidden gotcha I'm unaware of?
- withinboredom 5y agoIt’s about random distribution. If you output an array of the key space as a bitmap, it should look like white noise. SHA doesn’t look like white noise. There are certain parts of the space it rarely goes with certain classes of inputs (numeric, usernames, etc) while murmur and md5 give that white noise look.