...
Look on http://en.wikipedia.org/wiki/List_of_hash_functions for a 64 bit hash function OR use a stronger hash function but only take the first 8 bytes out the output.
Code Block |
---|
ByteBuffer buffer = ByteBuffer.wrap(hashArray);
long hash = buffer.getLong(); |
Locator Hashing
Code Block |
---|
// We need to get pp distinct nodes for the pool, so we continually hash the hash of the locator until we have everything we need. Integer[] partitionPool = new Integer[pp] Long hash = null; for(int i = 0; i < pp ; i++){ int slot = -1; while(slot == -1 || partitionPool[slot] != null){ slot = hash(hash == null ? locator : hash) % n; //n is number of nodes } partitionPool[i] = slot; } // We now have an array of node identifiers that form our partition pool. |
...