OffsetRangeTracker (Google Cloud Dataflow SDK 1.9.1 API)

Google Cloud Dataflow SDK for Java, version 1.9.1

Class OffsetRangeTracker

    • Field Detail


        public static final long OFFSET_INFINITY
        Offset corresponding to infinity. This can only be used as the upper-bound of a range, and indicates reading all of the records until the end without specifying exactly what the end is.

        Infinite ranges cannot be split because it is impossible to estimate progress within them.

        See Also:
        Constant Field Values
    • Constructor Detail

      • OffsetRangeTracker

        public OffsetRangeTracker(long startOffset,
                                  long stopOffset)
        Creates an OffsetRangeTracker for the specified range.
    • Method Detail

      • isStarted

        public boolean isStarted()
      • isDone

        public boolean isDone()
      • tryReturnRecordAt

        public boolean tryReturnRecordAt(boolean isAtSplitPoint,
                                         Long recordStart)
        Description copied from interface: RangeTracker
        Atomically determines whether a record at the given position can be returned and updates internal state. In particular:
        • If isAtSplitPoint is true, and recordStart is outside the current range, returns false;
        • Otherwise, updates the last-consumed position to recordStart and returns true.

        This method MUST be called on all split point records. It may be called on every record.

        Specified by:
        tryReturnRecordAt in interface RangeTracker<Long>
      • tryReturnRecordAt

        public boolean tryReturnRecordAt(boolean isAtSplitPoint,
                                         long recordStart)
      • trySplitAtPosition

        public boolean trySplitAtPosition(long splitOffset)
      • getPositionForFractionConsumed

        public long getPositionForFractionConsumed(double fraction)
        Returns a position P such that the range [start, P) represents approximately the given fraction of the range [start, end). Assumes that the density of records in the range is approximately uniform.
      • markDone

        public boolean markDone()
        Marks this range tracker as being done. Specifically, this will mark the current split point, if one exists, as being finished.

        Always returns false, so that it can be used in an implementation of Source.Reader.start() or Source.Reader.advance() as follows:

         public boolean start() {
           return startImpl() && rangeTracker.tryReturnRecordAt(isAtSplitPoint, position)
               || rangeTracker.markDone();

Send feedback about...

Cloud Dataflow