Package org.apache.cassandra.io.util
Class RebufferingInputStream
java.lang.Object
java.io.InputStream
org.apache.cassandra.io.util.DataInputPlus.DataInputStreamPlus
org.apache.cassandra.io.util.RebufferingInputStream
- All Implemented Interfaces:
Closeable,DataInput,AutoCloseable,DataInputPlus
- Direct Known Subclasses:
AsyncStreamingInputPlus,ChecksummedDataInput,CompressedInputStream,DataInputBuffer,FileInputStreamPlus,MemoryInputStream,NIODataInputStream,RandomAccessReader,StreamCompressionInputStream
public abstract class RebufferingInputStream
extends DataInputPlus.DataInputStreamPlus
implements DataInputPlus, Closeable
Rough equivalent of BufferedInputStream and DataInputStream wrapping a ByteBuffer that can be refilled
via rebuffer. Implementations provide this buffer from various channels (socket, file, memory, etc).
RebufferingInputStream is not thread safe.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.cassandra.io.util.DataInputPlus
DataInputPlus.DataInputStreamPlus -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintread()intread(byte[] b, int off, int len) booleanbytereadByte()charreadChar()doublefloatvoidreadFully(byte[] b) voidreadFully(byte[] b, int off, int len) voidreadFully(ByteBuffer dst) intreadInt()readLine()longreadLong()protected longreadPrimitiveSlowly(int bytes) shortintintlongThink hard before opting for an unsigned encoding.intRead up to a 32-bit integer back.readUTF()longreadVInt()Read a 64-bit integer back.intRead up to a 32-bit integer back.protected abstract voidreBuffer()Implementations must implement this method to refill the buffer.intskipBytes(int n) Always skips the requested number of bytes, unless EOF is reachedMethods inherited from class java.io.InputStream
available, close, 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
-
buffer
-
-
Constructor Details
-
RebufferingInputStream
-
-
Method Details
-
reBuffer
Implementations must implement this method to refill the buffer. They can expect the buffer to be empty when this method is invoked.- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceDataInput- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceDataInput- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
readFully
- Throws:
IOException
-
readPrimitiveSlowly
- Throws:
IOException
-
skipBytes
Description copied from interface:DataInputPlusAlways skips the requested number of bytes, unless EOF is reached- Specified by:
skipBytesin interfaceDataInput- Specified by:
skipBytesin interfaceDataInputPlus- Parameters:
n- number of bytes to skip- Returns:
- number of bytes skipped
- Throws:
IOException
-
readBoolean
- Specified by:
readBooleanin interfaceDataInput- Throws:
IOException
-
readByte
- Specified by:
readBytein interfaceDataInput- Throws:
IOException
-
readUnsignedByte
- Specified by:
readUnsignedBytein interfaceDataInput- Throws:
IOException
-
readShort
- Specified by:
readShortin interfaceDataInput- Throws:
IOException
-
readUnsignedShort
- Specified by:
readUnsignedShortin interfaceDataInput- Throws:
IOException
-
readChar
- Specified by:
readCharin interfaceDataInput- Throws:
IOException
-
readInt
- Specified by:
readIntin interfaceDataInput- Throws:
IOException
-
readLong
- Specified by:
readLongin interfaceDataInput- Throws:
IOException
-
readVInt
Description copied from interface:DataInputPlusRead a 64-bit integer back. This method assumes it was originally written usingDataOutputPlus.writeVInt(long)or similar that zigzag encodes the vint.- Specified by:
readVIntin interfaceDataInputPlus- Throws:
IOException
-
readVInt32
Description copied from interface:DataInputPlusRead up to a 32-bit integer back. This method assumes the integer was originally written usingDataOutputPlus.writeVInt32(int)or similar that zigzag encodes the vint.- Specified by:
readVInt32in interfaceDataInputPlus- Throws:
IOException
-
readUnsignedVInt
Description copied from interface:DataInputPlusThink hard before opting for an unsigned encoding. Is this going to bite someone because some day they might need to pass in a sentinel value using negative numbers? Is the risk worth it to save a few bytes? Signed, not a fan of unsigned values in protocols and formats- Specified by:
readUnsignedVIntin interfaceDataInputPlus- Throws:
IOException
-
readUnsignedVInt32
Description copied from interface:DataInputPlusRead up to a 32-bit integer back. This method assumes the original integer was written usingDataOutputPlus.writeUnsignedVInt32(int)or similar that doesn't zigzag encodes the vint.- Specified by:
readUnsignedVInt32in interfaceDataInputPlus- Throws:
IOException
-
readFloat
- Specified by:
readFloatin interfaceDataInput- Throws:
IOException
-
readDouble
- Specified by:
readDoublein interfaceDataInput- Throws:
IOException
-
readLine
- Specified by:
readLinein interfaceDataInput- Throws:
IOException
-
readUTF
- Specified by:
readUTFin interfaceDataInput- Throws:
IOException
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-