ByteKeyRange implements Serializable,
        HasDefaultTracker<
            ByteKeyRange, org.apache.beam.sdk.transforms.splittabledofn.ByteKeyRangeTracker> { @Override public int hashCode() { return Objects.hash(startKey, endKey); } private  ByteKeyRange(ByteKey startKey, ByteKey endKey); static ByteKeyRange of(ByteKey startKey, ByteKey endKey); ByteKey getStartKey(); ByteKey getEndKey(); Boolean containsKey(ByteKey key); Boolean overlaps(ByteKeyRange other); List<ByteKey> split(int numSplits); double estimateFractionForKey(ByteKey key); ByteKey interpolateKey(double fraction); ByteKeyRange withStartKey(ByteKey startKey); ByteKeyRange withEndKey(ByteKey endKey); @Override String toString(); @Override boolean equals(@Nullable Object o); @Override int hashCode(); @Override org.apache.beam.sdk.transforms.splittabledofn.ByteKeyRangeTracker newTracker(); static final ByteKeyRange ALL_KEYS; }
@Test public void testHashCode() { int collisions = 0; for (int i = 0; i < TEST_RANGES.length; ++i) { ByteKeyRange current = TEST_RANGES[i]; int left = current.hashCode(); int leftClone = ByteKeyRange.of(current.getStartKey(), current.getEndKey()).hashCode(); assertEquals( String.format("Expected same hash code for %s and a copy of itself", current), left, leftClone); for (int j = i + 1; j < TEST_RANGES.length; ++j) { int right = TEST_RANGES[j].hashCode(); if (left == right) { ++collisions; } } } int totalUnequalTests = TEST_RANGES.length * (TEST_RANGES.length - 1) / 2; assertThat("Too many hash collisions", collisions, lessThan(totalUnequalTests / 2)); }