boyuanzz commented on a change in pull request #11454:
URL: https://github.com/apache/beam/pull/11454#discussion_r414116060
##########
File path:
sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/splittabledofn/ByteKeyRangeTrackerTest.java
##########
@@ -152,9 +158,35 @@ public void testCheckpointAfterLastUsingEmptyKey() throws
Exception {
assertTrue(tracker.tryClaim(ByteKey.of(0x90)));
assertTrue(tracker.tryClaim(ByteKey.of(0xa0)));
assertFalse(tracker.tryClaim(ByteKey.EMPTY));
- ByteKeyRange checkpoint = tracker.trySplit(0).getResidual();
+ assertNull(tracker.trySplit(0));
assertEquals(ByteKeyRange.of(ByteKey.of(0x10), ByteKey.of(0xc0)),
tracker.currentRestriction());
- assertEquals(ByteKeyRangeTracker.NO_KEYS, checkpoint);
+ tracker.checkDone();
+ }
+
+ @Test
+ public void testTrySplit() throws Exception {
+ ByteKeyRangeTracker tracker =
+ ByteKeyRangeTracker.of(ByteKeyRange.of(ByteKey.EMPTY,
ByteKey.of(0x80)));
+ SplitResult<ByteKeyRange> res = tracker.trySplit(0.5);
+ assertKeyRangeEqualExceptPadding(
+ ByteKeyRange.of(ByteKey.EMPTY, ByteKey.of(0x40)), res.getPrimary());
+ assertKeyRangeEqualExceptPadding(
+ ByteKeyRange.of(ByteKey.of(0x40), ByteKey.of(0x80)),
res.getResidual());
+ tracker.tryClaim(ByteKey.of(0x00));
+ res = tracker.trySplit(0.5);
+ assertKeyRangeEqualExceptPadding(
+ ByteKeyRange.of(ByteKey.of(0x00), ByteKey.of(0x20)), res.getPrimary());
Review comment:
It should be `EMPTY`. Thanks for catching this!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]