Skip to content

Commit

Permalink
fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
oertl committed Feb 16, 2024
1 parent ba95128 commit c7dcceb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer, List<Long>> 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<Integer, List<Long>> 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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer, List<Long>> 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<Integer, List<Long>> 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)
Expand Down

0 comments on commit c7dcceb

Please sign in to comment.