public interface ConsistentBucketHasher
A hash function that maps a given hash consistently to a bucket index of given range.
-
Method Summary
Modifier and TypeMethodDescriptionintgetBucket(long hash, int numBuckets) Returns a bucket index in the range[0, numBuckets)based on a 64-bit hash value of the key.
-
Method Details
-
getBucket
int getBucket(long hash, int numBuckets) Returns a bucket index in the range[0, numBuckets)based on a 64-bit hash value of the key.The returned bucket index is uniformly distributed. If
numBucketsis changed, remapping to other bucket indices is minimized.This function is not thread-safe!
- Parameters:
hash- a 64-bit hash value of the keynumBuckets- the number of buckets, must be positive- Returns:
- the bucket index
-