use of org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker.Progress in project beam by apache.
the class OffsetRangeTrackerTest method testLargeRange.
@Test
public void testLargeRange() throws Exception {
OffsetRangeTracker tracker = new OffsetRangeTracker(new OffsetRange(Long.MIN_VALUE, Long.MAX_VALUE));
Progress progress = tracker.getProgress();
assertEquals(0, progress.getWorkCompleted(), 0.001);
assertEquals(BigDecimal.valueOf(Long.MAX_VALUE).subtract(BigDecimal.valueOf(Long.MIN_VALUE), MathContext.DECIMAL128).doubleValue(), progress.getWorkRemaining(), 0.001);
SplitResult res = tracker.trySplit(0);
assertEquals(new OffsetRange(Long.MIN_VALUE, Long.MIN_VALUE), res.getPrimary());
assertEquals(new OffsetRange(Long.MIN_VALUE, Long.MAX_VALUE), res.getResidual());
}
use of org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker.Progress in project beam by apache.
the class ByteKeyRangeTrackerTest method testBacklogFinished.
@Test
public void testBacklogFinished() {
ByteKeyRangeTracker tracker = ByteKeyRangeTracker.of(ByteKeyRange.ALL_KEYS);
tracker.tryClaim(ByteKey.EMPTY);
Progress progress = tracker.getProgress();
assertEquals(1, progress.getWorkCompleted(), 0.001);
assertEquals(0, progress.getWorkRemaining(), 0.001);
tracker = ByteKeyRangeTracker.of(ByteKeyRange.of(ByteKey.of(0x10), ByteKey.of(0xc0)));
tracker.tryClaim(ByteKey.of(0xd0));
progress = tracker.getProgress();
assertEquals(1, progress.getWorkCompleted(), 0.001);
assertEquals(0, progress.getWorkRemaining(), 0.001);
}
use of org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker.Progress in project beam by apache.
the class OffsetRangeTrackerTest method testBacklogFinished.
@Test
public void testBacklogFinished() {
OffsetRangeTracker tracker = new OffsetRangeTracker(new OffsetRange(0, 200));
tracker.tryClaim(300L);
Progress progress = tracker.getProgress();
assertEquals(200, progress.getWorkCompleted(), 0.001);
assertEquals(0, progress.getWorkRemaining(), 0.001);
tracker = new OffsetRangeTracker(new OffsetRange(100, 200));
tracker.tryClaim(300L);
progress = tracker.getProgress();
assertEquals(100, progress.getWorkCompleted(), 0.001);
assertEquals(0, progress.getWorkRemaining(), 0.001);
}
use of org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker.Progress in project beam by apache.
the class OffsetRangeTrackerTest method testBacklogUnstarted.
@Test
public void testBacklogUnstarted() {
OffsetRangeTracker tracker = new OffsetRangeTracker(new OffsetRange(0, 200));
Progress progress = tracker.getProgress();
assertEquals(0, progress.getWorkCompleted(), 0.001);
assertEquals(200, progress.getWorkRemaining(), 0.001);
tracker = new OffsetRangeTracker(new OffsetRange(100, 200));
progress = tracker.getProgress();
assertEquals(0, progress.getWorkCompleted(), 0.001);
assertEquals(100, progress.getWorkRemaining(), 0.001);
}
use of org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker.Progress in project beam by apache.
the class ByteKeyRangeTrackerTest method testBacklogUnstarted.
@Test
public void testBacklogUnstarted() {
ByteKeyRangeTracker tracker = ByteKeyRangeTracker.of(ByteKeyRange.ALL_KEYS);
Progress progress = tracker.getProgress();
assertEquals(0, progress.getWorkCompleted(), 0.001);
assertEquals(1, progress.getWorkRemaining(), 0.001);
tracker = ByteKeyRangeTracker.of(ByteKeyRange.of(ByteKey.of(0x10), ByteKey.of(0xc0)));
progress = tracker.getProgress();
assertEquals(0, progress.getWorkCompleted(), 0.001);
assertEquals(1, progress.getWorkRemaining(), 0.001);
}
Aggregations