public static class DatastoreIO.DatastoreReader extends BoundedSource.AbstractBoundedReader<com.google.api.services.datastore.DatastoreV1.Entity>
Timestamped records are currently not supported. All records implicitly have the timestamp
of BoundedWindow.TIMESTAMP_MIN_VALUE.
| Constructor and Description |
|---|
DatastoreIO.DatastoreReader(DatastoreIO.Source source,
com.google.api.services.datastore.client.Datastore datastore)
Returns a DatastoreIterator with query and Datastore object set.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
advance()
Advances the reader to the next valid record.
|
void |
close()
Closes the reader.
|
com.google.api.services.datastore.DatastoreV1.Entity |
getCurrent()
Returns the value of the data item that was read by the last
Source.Reader.start() or
Source.Reader.advance() call. |
DatastoreIO.Source |
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. |
DatastoreIO.Source |
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.
|
boolean |
start()
Initializes the reader and advances the reader to the first record.
|
getCurrentTimestampclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetCurrentTimestamppublic DatastoreIO.DatastoreReader(DatastoreIO.Source source, com.google.api.services.datastore.client.Datastore datastore)
datastore - a datastore connection to use.public com.google.api.services.datastore.DatastoreV1.Entity getCurrent()
Source.ReaderSource.Reader.start() or
Source.Reader.advance() call.public boolean start()
throws java.io.IOException
Source.Reader This method should be called exactly once. The invocation should occur prior to calling
Source.Reader.advance() or Source.Reader.getCurrent(). This method may perform expensive operations that
are needed to initialize the reader.
true if a record was read, false if we're at the end of input.java.io.IOExceptionpublic boolean advance()
throws java.io.IOException
Source.ReaderSource.Reader.getCurrent() call.true if a record was read, false if we're at the end of input.java.io.IOExceptionpublic void close()
throws java.io.IOException
Source.Readerjava.io.IOExceptionpublic DatastoreIO.Source 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 DatastoreIO.Source 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<com.google.api.services.datastore.DatastoreV1.Entity>splitAtFraction in class BoundedSource.AbstractBoundedReader<com.google.api.services.datastore.DatastoreV1.Entity>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<com.google.api.services.datastore.DatastoreV1.Entity>getFractionConsumed in class BoundedSource.AbstractBoundedReader<com.google.api.services.datastore.DatastoreV1.Entity>null if such an estimate is not available.