public abstract static class ByteOffsetBasedSource.ByteOffsetBasedReader<T> extends BoundedSource.AbstractBoundedReader<T>
ByteOffsetBasedSources.| Constructor and Description |
|---|
ByteOffsetBasedSource.ByteOffsetBasedReader(ByteOffsetBasedSource<T> source) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract long |
getCurrentOffset()
Returns the current offset of the reader.
|
ByteOffsetBasedSource<T> |
getCurrentSource()
Returns a
Source describing the same input that this Reader reads
(including items already read). |
java.lang.Double |
getFractionConsumed()
Returns a value in [0, 1] representing approximately what fraction of the source
(
BoundedSource.BoundedReader.getCurrentSource()) this reader has read so far. |
ByteOffsetBasedSource<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, waitadvance, close, getCurrent, getCurrentTimestamp, startpublic ByteOffsetBasedSource.ByteOffsetBasedReader(ByteOffsetBasedSource<T> source)
source - the ByteOffsetBasedSource to be read by the current reader.protected abstract long getCurrentOffset()
Source.Reader.start() is called. After Source.Reader.start() is
called the value returned by this method should represent the offset of the value that will
be returned by the Source.Reader.getCurrent() call. Values returned for two consecutive
records should be non-strictly increasing. If the reader has reached the end of the stream
this should return Long.MAX_VALUE. The value returned may be outside the range
defined by the ByteOffsetBasedSource corresponding to this reader, for reasons
described in the comment to ByteOffsetBasedSource.public ByteOffsetBasedSource<T> getCurrentSource()
Source.ReaderSource describing the same input that this Reader reads
(including items already read).
A reader created from the result of getCurrentSource, if consumed, MUST
return the same data items as the current reader.
public java.lang.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>getFractionConsumed in class BoundedSource.AbstractBoundedReader<T>null if such an estimate is not available.public ByteOffsetBasedSource<T> splitAtFraction(double fraction)
BoundedSource.BoundedReaderBoundedSource representing the remainder.
More detailed description: Assuming the following sequence of calls:
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).
Since this method (if successful) affects the reader's source, in subsequent invocations "fraction" should be interpreted relative to the new current source.
splitAtFraction in interface BoundedSource.BoundedReader<T>splitAtFraction in class BoundedSource.AbstractBoundedReader<T>