T - public abstract static class BoundedSource.AbstractBoundedReader<T> extends Source.AbstractReader<T> implements BoundedSource.BoundedReader<T>
BoundedSource.BoundedReader in a default way:
getFractionConsumed()) is not supported.
splitAtFraction(double)) is not supported.
| Constructor and Description |
|---|
AbstractBoundedReader() |
| Modifier and Type | Method and Description |
|---|---|
Double |
getFractionConsumed()
Returns a value in [0, 1] representing approximately what fraction of the source
(
BoundedSource.BoundedReader.getCurrentSource()) this reader has read so far. |
BoundedSource<T> |
splitAtFraction(double fraction)
Tells the reader to narrow the range of the input it's going to read and give up
the remainder, so that the new range would contain approximately the given
fraction of the amount of data in the current range.
|
getCurrentTimestampclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetCurrentSourceadvance, close, getCurrent, getCurrentTimestamp, startpublic Double getFractionConsumed()
BoundedSource.BoundedReaderBoundedSource.BoundedReader.getCurrentSource()) this reader has read so far.
It is recommended that this method should satisfy the following properties:
Source.Reader.start() call.
Source.Reader.start() or Source.Reader.advance() call that returns false.
getFractionConsumed in interface BoundedSource.BoundedReader<T>null if such an estimate is not available.public BoundedSource<T> splitAtFraction(double fraction)
BoundedSource.BoundedReaderReturns a BoundedSource representing the remainder.
BoundedSource<T> initial = reader.getCurrentSource();
BoundedSource<T> residual = reader.splitAtFraction(fraction);
BoundedSource<T> primary = reader.getCurrentSource();
This method should return null if the split cannot be performed for this fraction
while satisfying the semantics above. E.g., a reader that reads a range of offsets
in a file should return null if it is already past the position in its range
corresponding to the given fraction. In this case, the method MUST have no effect
(the reader must behave as if the method hadn't been called at all).
It is also very important that this method always completes quickly, in particular, it should not perform or wait on any blocking operations such as I/O, RPCs etc. Violating this requirement may stall completion of the work item or even cause it to fail.
E.g. it is incorrect to make both this method and Source.Reader.start()/Source.Reader.advance()
synchronized, because those methods can perform blocking operations, and then
this method would have to wait for those calls to complete.
RangeTracker makes it easy to implement
this method safely and correctly.
splitAtFraction in interface BoundedSource.BoundedReader<T>