public class ByteKeyRangeTracker extends RestrictionTracker<ByteKeyRange,ByteKey> implements Sizes.HasSize
ByteKeys in a
ByteKeyRangein a monotonically increasing fashion. The range is a semi-open bounded interval [startKey, endKey) where the limits are both represented by
Note, one can complete a range by claiming the
ByteKey.EMPTY once one runs out of keys
|Modifier and Type||Method and Description|
Called by the runner after
Signals that the current
Returns a restriction accurately describing the full range of work the current
A representation for the amount of known work represented as a size.
Attempts to claim the given key.
public ByteKeyRange currentRestriction()
DoFn.ProcessElementcall will do, including already completed work.
public ByteKeyRange checkpoint()
DoFn.ProcessElementcall should terminate as soon as possible: after this method returns, the tracker MUST refuse all future claim calls, and
RestrictionTracker.currentRestriction(). Returns a restriction representing the rest of the
work: the old value of
RestrictionTracker.currentRestriction() is equivalent to the new value and the
return value of this method combined.
Must be called at most once on a given object.
public boolean tryClaim(ByteKey key)
Must be larger than the last attempted key. Since this restriction tracker represents a
range over a semi-open bounded interval
[start, end), the last key that was attempted
may have failed but still have consumed the interval
[lastAttemptedKey, end) since this
range tracker processes keys in a monotonically increasing order. Note that passing in
ByteKey.EMPTY claims all keys to the end of range and can only be claimed once.
public void checkDone() throws java.lang.IllegalStateException
Must throw an exception with an informative error message, if there is still any unclaimed work remaining in the restriction.
public java.lang.String toString()
public double getSize()
doublerepresentations should preferably represent a linear space and be comparable within the same partition.
It is up to each restriction tracker to convert between their natural representation of outstanding work and this representation. For example:
message bytesthat have not been processed.
DoFns should provide a method annotated with
DoFn.GetPartition to report a
partition identifier if the element and restriction represent the size for a shared resource
such as a message queue topic. See
DoFn.GetPartition for additional details.