Search in sources :

Example 1 with Progress

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());
}
Also used : OffsetRange(org.apache.beam.sdk.io.range.OffsetRange) Progress(org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker.Progress) Test(org.junit.Test)

Example 2 with Progress

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);
}
Also used : Progress(org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker.Progress) Test(org.junit.Test)

Example 3 with Progress

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);
}
Also used : OffsetRange(org.apache.beam.sdk.io.range.OffsetRange) Progress(org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker.Progress) Test(org.junit.Test)

Example 4 with Progress

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);
}
Also used : OffsetRange(org.apache.beam.sdk.io.range.OffsetRange) Progress(org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker.Progress) Test(org.junit.Test)

Example 5 with Progress

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);
}
Also used : Progress(org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker.Progress) Test(org.junit.Test)

Aggregations

Progress (org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker.Progress)14 Test (org.junit.Test)13 OffsetRange (org.apache.beam.sdk.io.range.OffsetRange)5 HasProgress (org.apache.beam.sdk.transforms.splittabledofn.RestrictionTracker.HasProgress)1 VisibleForTesting (org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting)1