From 5b08295c501a612ab901d7bf22f7d967ad65405f Mon Sep 17 00:00:00 2001 From: Luke Cwik Date: Tue, 6 Nov 2018 17:02:20 -0800 Subject: [PATCH] [BEAM-5974] Minor fixes for comments on PR/6949. --- .../splittabledofn/ByteKeyRangeTracker.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/splittabledofn/ByteKeyRangeTracker.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/splittabledofn/ByteKeyRangeTracker.java index 52ee359135f1..457c19e876c6 100644 --- a/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/splittabledofn/ByteKeyRangeTracker.java +++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/splittabledofn/ByteKeyRangeTracker.java @@ -63,7 +63,7 @@ public synchronized ByteKeyRange checkpoint() { // If we haven't done any work, we should return the original range we were processing // as the checkpoint. if (lastAttemptedKey == null) { - ByteKeyRange rval = ByteKeyRange.of(range.getStartKey(), range.getEndKey()); + ByteKeyRange rval = range; // We update our current range to an interval that contains no elements. range = NO_KEYS; return rval; @@ -87,11 +87,14 @@ public synchronized ByteKeyRange checkpoint() { /** * Attempts to claim the given key. * - *

Must be larger than the last attempted key. Note that passing in {@link ByteKey#EMPTY} - * claims all keys to the end of range and can only be claimed once. + *

Must be larger than the last attempted key. Since this restriction tracker represents a + * range over a semi-open bounded interval {@code [start, end)}, the last key that was attempted + * may have failed but still have consumed the interval {@code [lastAttemptedKey, end)} since this + * range tracker processes keys in a monotonically increasing order. Note that passing in {@link + * ByteKey#EMPTY} claims all keys to the end of range and can only be claimed once. * * @return {@code true} if the key was successfully claimed, {@code false} if it is outside the - * current {@link ByteKeyRange} of this tracker (in that case this operation is a no-op). + * current {@link ByteKeyRange} of this tracker. */ @Override protected synchronized boolean tryClaimImpl(ByteKey key) {