use of org.apache.beam.sdk.io.range.OffsetRange in project beam by apache.
the class OffsetRangeTrackerTest method testCheckpointJustStarted.
@Test
public void testCheckpointJustStarted() throws Exception {
OffsetRangeTracker tracker = new OffsetRangeTracker(new OffsetRange(100, 200));
assertTrue(tracker.tryClaim(100L));
OffsetRange checkpoint = tracker.trySplit(0).getResidual();
assertEquals(new OffsetRange(100, 101), tracker.currentRestriction());
assertEquals(new OffsetRange(101, 200), checkpoint);
tracker.checkDone();
}
use of org.apache.beam.sdk.io.range.OffsetRange in project beam by apache.
the class OffsetRangeTrackerTest method testTrySplitAfterCheckpoint.
@Test
public void testTrySplitAfterCheckpoint() throws Exception {
OffsetRangeTracker tracker = new OffsetRangeTracker(new OffsetRange(100, 200));
tracker.tryClaim(105L);
tracker.trySplit(0);
assertNull(tracker.trySplit(0.1));
}
use of org.apache.beam.sdk.io.range.OffsetRange in project beam by apache.
the class OffsetRangeTrackerTest method testTrySplitAtEmptyRange.
@Test
public void testTrySplitAtEmptyRange() throws Exception {
OffsetRangeTracker tracker = new OffsetRangeTracker(new OffsetRange(100, 100));
assertNull(tracker.trySplit(0));
assertNull(tracker.trySplit(0.1));
assertNull(tracker.trySplit(1));
}
use of org.apache.beam.sdk.io.range.OffsetRange in project beam by apache.
the class OffsetRangeTrackerTest method testTryClaim.
@Test
public void testTryClaim() throws Exception {
OffsetRange range = new OffsetRange(100, 200);
OffsetRangeTracker tracker = new OffsetRangeTracker(range);
assertEquals(range, tracker.currentRestriction());
assertTrue(tracker.tryClaim(100L));
assertTrue(tracker.tryClaim(150L));
assertTrue(tracker.tryClaim(199L));
assertFalse(tracker.tryClaim(200L));
}
use of org.apache.beam.sdk.io.range.OffsetRange in project beam by apache.
the class OffsetRangeTrackerTest method testCheckpointRegular.
@Test
public void testCheckpointRegular() throws Exception {
OffsetRangeTracker tracker = new OffsetRangeTracker(new OffsetRange(100, 200));
assertTrue(tracker.tryClaim(105L));
assertTrue(tracker.tryClaim(110L));
OffsetRange checkpoint = tracker.trySplit(0).getResidual();
assertEquals(new OffsetRange(100, 111), tracker.currentRestriction());
assertEquals(new OffsetRange(111, 200), checkpoint);
tracker.checkDone();
}
Aggregations