diff --git a/README.md b/README.md index 4ea3a51f..ec6dbafb 100644 --- a/README.md +++ b/README.md @@ -225,20 +225,20 @@ ConsistentBucketHasher consistentBucketHasher = long[] hashValues = {9184114998275508886L, 7090183756869893925L, -8795772374088297157L}; -// determine assignment of hash value to 2 buckets +// determine assignment of hash values to 2 buckets Map> assignment2Buckets = LongStream.of(hashValues) .boxed() .collect(groupingBy(hash -> consistentBucketHasher.getBucket(hash, 2))); // gives {0=[7090183756869893925, -8795772374088297157], 1=[9184114998275508886]} -// determine assignment of hash value to 3 buckets +// determine assignment of hash values to 3 buckets Map> assignment3Buckets = LongStream.of(hashValues) .boxed() .collect(groupingBy(hash -> consistentBucketHasher.getBucket(hash, 3))); // gives {0=[7090183756869893925], 1=[9184114998275508886], 2=[-8795772374088297157]} -// hash value 7090183756869893925 got reassigned from bucket 0 to bucket 2 +// hash value -8795772374088297157 got reassigned from bucket 0 to bucket 2 // probability of reassignment is equal to 1/3 ``` See also [ConsistentHashingDemo.java](src/test/java/com/dynatrace/hash4j/consistent/ConsistentHashingDemo.java). diff --git a/src/test/java/com/dynatrace/hash4j/consistent/ConsistentHashingDemo.java b/src/test/java/com/dynatrace/hash4j/consistent/ConsistentHashingDemo.java index 4c44e806..a42969c6 100644 --- a/src/test/java/com/dynatrace/hash4j/consistent/ConsistentHashingDemo.java +++ b/src/test/java/com/dynatrace/hash4j/consistent/ConsistentHashingDemo.java @@ -35,20 +35,20 @@ void demoJumphash() { long[] hashValues = {9184114998275508886L, 7090183756869893925L, -8795772374088297157L}; - // determine assignment of hash value to 2 buckets + // determine assignment of hash values to 2 buckets Map> assignment2Buckets = LongStream.of(hashValues) .boxed() .collect(groupingBy(hash -> consistentBucketHasher.getBucket(hash, 2))); // gives {0=[7090183756869893925, -8795772374088297157], 1=[9184114998275508886]} - // determine assignment of hash value to 3 buckets + // determine assignment of hash values to 3 buckets Map> assignment3Buckets = LongStream.of(hashValues) .boxed() .collect(groupingBy(hash -> consistentBucketHasher.getBucket(hash, 3))); // gives {0=[7090183756869893925], 1=[9184114998275508886], 2=[-8795772374088297157]} - // hash value 7090183756869893925 got reassigned from bucket 0 to bucket 2 + // hash value -8795772374088297157 got reassigned from bucket 0 to bucket 2 // probability of reassignment is equal to 1/3 assertThat(assignment2Buckets)