public static class DataStreams.DataStreamDecoder<T> extends java.lang.Object implements PrefetchableIterator<T>
InputStream to a PrefetchableIterator of T
values using the specified Coder.
Note that this adapter follows the Beam Fn API specification for forcing values that decode consuming zero bytes to consuming exactly one byte.
Note that access to the underlying InputStream is lazy and will only be invoked on
first access to next(), hasNext(), isReady(), and prefetch().
Note that isReady() and prefetch() rely on non-empty ByteStrings being
returned via the underlying PrefetchableIterator otherwise the prefetch() will
seemingly make zero progress yet will actually advance through the empty pages.
| Constructor and Description |
|---|
DataStreamDecoder(Coder<T> coder,
PrefetchableIterator<org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.ByteString> inputStream) |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<T> |
decodeFromChunkBoundaryToChunkBoundary()
Skips any remaining bytes in the current
ByteString moving to the next ByteString in the underlying ByteString iterator and decoding
elements till at the next boundary. |
boolean |
hasNext() |
boolean |
isReady()
Returns
true if and only if Iterator.hasNext() and Iterator.next() will not require an
expensive operation. |
T |
next() |
void |
prefetch()
If not
PrefetchableIterator.isReady(), schedules the next expensive operation such that at some point in time
in the future PrefetchableIterator.isReady() will return true. |
void |
remove() |
public DataStreamDecoder(Coder<T> coder, PrefetchableIterator<org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.ByteString> inputStream)
public java.util.List<T> decodeFromChunkBoundaryToChunkBoundary()
ByteString moving to the next ByteString in the underlying ByteString iterator and decoding
elements till at the next boundary.public boolean isReady()
PrefetchableIteratortrue if and only if Iterator.hasNext() and Iterator.next() will not require an
expensive operation.isReady in interface PrefetchableIterator<T>public void prefetch()
PrefetchableIteratorPrefetchableIterator.isReady(), schedules the next expensive operation such that at some point in time
in the future PrefetchableIterator.isReady() will return true.prefetch in interface PrefetchableIterator<T>public boolean hasNext()
hasNext in interface java.util.Iterator<T>public void remove()
remove in interface java.util.Iterator<T>