What algorithm yields the best distribution when it comes to mapping hash key --> bucket instance ?
In other words, let’s say I have an hashing function (probably SHA-1) and I have n buckets; what algorithm do I use to map a key to a bucket? E.g. lower bits, upper bits, something else?
Usually, you just
modyour hash value with the number of buckets. In the unlikely event that the number of buckets is a power of two, you can use bitwise-and instead.An excerpt from Wikipedia on hash function: