public abstract class LevelDbInputReader extends InputReader<ByteBuffer>
LevelDbOutputWriter
)
If you want to read about the format it is here:
"https://github.com/google/leveldb/"
This implementation deviates from the specification above, in that it allows blocks to be zero
padded regardless of how much data is in the block, rather than only if the block is within 6
bytes of full.
Data is read in as needed, so the only state required to reconstruct this class when it is
serialized is the offset.
In the event that corrupt data is encountered a CorruptDataException
is thrown. If this
occurs, do not continue to attempt to read. Behavior is not guaranteed.
For internal use only. User code cannot safely depend on this class.Modifier | Constructor and Description |
---|---|
|
LevelDbInputReader() |
protected |
LevelDbInputReader(int blockSize) |
Modifier and Type | Method and Description |
---|---|
void |
beginShard()
Performs setup at the beginning of the shard.
|
void |
beginSlice()
Prepares the
InputReader for reading, after possibly having gone
through serialization and deserialization. |
abstract ReadableByteChannel |
createReadableByteChannel() |
void |
endShard()
Calls close on the underlying stream.
|
protected long |
getBytesRead() |
ByteBuffer |
next()
Returns the next input value, or throws
NoSuchElementException
when there is no more input data. |
close, endSlice, estimateMemoryRequirement, getContext, getProgress, open, setContext
public LevelDbInputReader()
protected LevelDbInputReader(int blockSize)
public abstract ReadableByteChannel createReadableByteChannel()
protected long getBytesRead()
public void beginShard()
InputReader
InputReader.beginSlice()
. It will not be invoked again unless the shard restarts. When a shard is
restarted, this method is invoked and the input should be read from the beginning.beginShard
in class InputReader<ByteBuffer>
public void endShard() throws IOException
endShard
in class InputReader<ByteBuffer>
IOException
- in the event of failurepublic void beginSlice()
InputReader
InputReader
for reading, after possibly having gone
through serialization and deserialization.beginSlice
in class InputReader<ByteBuffer>
public ByteBuffer next() throws IOException, NoSuchElementException
NoSuchElementException
when there is no more input data. This is done rather than providing a
hasNext() function, to allow the implementation to deal with streams and
remain serializable, even if the item being read is not.next
in class InputReader<ByteBuffer>
IOException
NoSuchElementException
Copyright © 2015 Google. All rights reserved.