public class ChecksummedDataInput extends RandomAccessReader.RandomAccessReaderWithOwnChannel
RandomAccessReader
wrapper that calculates the CRC in place.
Useful for HintsReader
, for example, where we must verify the CRC, yet don't want
to allocate an extra byte array just that purpose. The CRC can be embedded in the input stream and checked via checkCrc().
In addition to calculating the CRC, it allows to enforce a maximum known size. This is needed
so that Mutation.MutationSerializer
doesn't blow up the heap when deserializing a
corrupted sequence by reading a huge corrupted length of bytes via
ByteBufferUtil.readWithLength(java.io.DataInput)
.Modifier and Type | Class and Description |
---|---|
static class |
ChecksummedDataInput.Builder |
RandomAccessReader.BufferedRandomAccessFileMark, RandomAccessReader.RandomAccessReaderWithOwnChannel
DataInputPlus.DataInputStreamPlus
bufferOffset, bufferSize, bufferType, channel, DEFAULT_BUFFER_SIZE, limiter, markedPointer, MAX_BUFFER_SIZE, regions
buffer
Modifier | Constructor and Description |
---|---|
protected |
ChecksummedDataInput(ChecksummedDataInput.Builder builder) |
Modifier and Type | Method and Description |
---|---|
long |
bytesPastLimit() |
boolean |
checkCrc() |
void |
checkLimit(int length) |
InputPosition |
getSeekPosition()
Return a seekable representation of the current position.
|
protected long |
getSourcePosition()
Returns the position in the source file, which is different for getPosition() for compressed/encrypted files
and may be imprecise.
|
void |
limit(long newLimit) |
static ChecksummedDataInput |
open(java.io.File file) |
int |
read(byte[] b,
int off,
int len) |
void |
readFully(byte[] b) |
void |
reBuffer()
Read data from file starting from current currentOffset to populate buffer.
|
void |
resetCrc() |
void |
resetLimit() |
void |
seek(InputPosition pos) |
void |
tryUncacheRead() |
close
allocateBuffer, available, bytesPastMark, bytesPastMark, bytesRemaining, current, getChannel, getFilePointer, getPath, getPosition, isEOF, length, mark, markSupported, open, readLine, reBufferMmap, reBufferStandard, releaseBuffer, reset, reset, seek, toString
read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readInt, readLong, readPrimitiveSlowly, readShort, readUnsignedByte, readUnsignedShort, readUnsignedVInt, readUTF, readVInt, skipBytes
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
readUnsignedVInt, readVInt, skipBytes, skipBytesFully
protected ChecksummedDataInput(ChecksummedDataInput.Builder builder)
public static ChecksummedDataInput open(java.io.File file)
public InputPosition getSeekPosition()
public void seek(InputPosition pos)
public void resetCrc()
public void limit(long newLimit)
protected long getSourcePosition()
public void resetLimit()
public void checkLimit(int length) throws java.io.IOException
java.io.IOException
public long bytesPastLimit()
public boolean checkCrc() throws java.io.IOException
java.io.IOException
public void readFully(byte[] b) throws java.io.IOException
readFully
in interface java.io.DataInput
readFully
in class RebufferingInputStream
java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
read
in class RebufferingInputStream
java.io.IOException
public void reBuffer()
RandomAccessReader
reBuffer
in class RandomAccessReader
public void tryUncacheRead()
Copyright © 2009- The Apache Software Foundation