Skip to content

Commit

Permalink
DBZ-8163 Clarify equals case & positive/negative infinity
Browse files Browse the repository at this point in the history
  • Loading branch information
twthorn committed Aug 23, 2024
1 parent dab6558 commit a8bbcb5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public static Long getInheritedEpoch(String shardString, ShardEpochMap shardEpoc

private static class Shard {

// A string lexicographically less than all other strings
public static final String NEGATIVE_INFINITY = "";
// A string lexicographically greater than all other strings
public static final String POSITIVE_INFINITY = "\uFFFF";
// A string of a single char that is lexicographically less than all other chars
public static final String NEGATIVE_INFINITY = String.valueOf(Character.MIN_VALUE);
// A string of a single char that is lexicographically greater than all other chars
public static final String POSITIVE_INFINITY = String.valueOf(Character.MAX_VALUE);

private final String lowerBound;
private final String upperBound;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ public void shouldGetInheritedEpoch_MultiShard_SplitOneShard() {
assertThat(epoch3).isEqualTo(parentEpoch2 + 1);
}

@Test
public void shouldGetInheritedEpoch_MultiShard_SplitOneShard_UpperEqualsLowerBound() {
Long parentEpoch = 3L;
Long parentEpoch2 = 1L;
ShardEpochMap shardEpochMap = new ShardEpochMap(Map.of("-80", parentEpoch, "80-", parentEpoch2));
// The lower bound (80) is equal to a previous shard's upper bound (-80)
Long epoch2 = ShardLineage.getInheritedEpoch("80-c0", shardEpochMap);
// This is not a descendant so assert the epoch is from the actual parent (which is less than the other parent)
assertThat(epoch2).isEqualTo(parentEpoch2 + 1);
}

@Test
public void shouldGetInheritedEpoch_TwoToFourShards() {
Long parentEpoch = 1L;
Expand Down

0 comments on commit a8bbcb5

Please sign in to comment.