Package org.apache.cassandra.hints
Class ChecksummedDataInput
java.lang.Object
java.io.InputStream
org.apache.cassandra.io.util.DataInputPlus.DataInputStreamPlus
org.apache.cassandra.io.util.RebufferingInputStream
org.apache.cassandra.hints.ChecksummedDataInput
- All Implemented Interfaces:
Closeable,DataInput,AutoCloseable,DataInputPlus
- Direct Known Subclasses:
CompressedChecksummedDataInput,EncryptedChecksummedDataInput
A
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).-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.cassandra.io.util.DataInputPlus
DataInputPlus.DataInputStreamPlus -
Field Summary
FieldsFields inherited from class org.apache.cassandra.io.util.RebufferingInputStream
buffer -
Method Summary
Modifier and TypeMethodDescriptionlongbooleancheckCrc()voidcheckLimit(int length) voidclose()protected StringgetPath()protected longReturns the exact position in the uncompressed view of the file.Return a seekable representation of the current position.protected longReturns the position in the source file, which is different for getPosition() for compressed/encrypted files and may be imprecise.booleanisEOF()voidlimit(long newLimit) static ChecksummedDataInputintread(byte[] b, int off, int len) protected voidvoidreadFully(byte[] b) protected voidreBuffer()Implementations must implement this method to refill the buffer.voidresetCrc()voidvoidseek(InputPosition pos) voidMethods inherited from class org.apache.cassandra.io.util.RebufferingInputStream
read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readPrimitiveSlowly, readShort, readUnsignedByte, readUnsignedShort, readUnsignedVInt, readUnsignedVInt32, readUTF, readVInt, readVInt32, skipBytesMethods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferToMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.cassandra.io.util.DataInputPlus
skipBytesFully
-
Field Details
-
bufferOffset
protected long bufferOffset -
channel
-
-
Method Details
-
open
-
isEOF
public boolean isEOF() -
getSeekPosition
Return a seekable representation of the current position. For compressed files this is chunk position in file and offset within chunk. -
seek
-
resetCrc
public void resetCrc() -
limit
public void limit(long newLimit) -
getPosition
protected long getPosition()Returns the exact position in the uncompressed view of the file. -
getSourcePosition
protected long getSourcePosition()Returns the position in the source file, which is different for getPosition() for compressed/encrypted files and may be imprecise. -
resetLimit
public void resetLimit() -
checkLimit
- Throws:
IOException
-
bytesPastLimit
public long bytesPastLimit() -
checkCrc
- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceDataInput- Overrides:
readFullyin classRebufferingInputStream- Throws:
IOException
-
read
- Overrides:
readin classRebufferingInputStream- Throws:
IOException
-
reBuffer
protected void reBuffer()Description copied from class:RebufferingInputStreamImplementations must implement this method to refill the buffer. They can expect the buffer to be empty when this method is invoked.- Specified by:
reBufferin classRebufferingInputStream
-
readBuffer
protected void readBuffer() -
tryUncacheRead
public void tryUncacheRead() -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream
-
getPath
-
getChannel
-