Package org.apache.cassandra.io.util
Class RandomAccessReader
java.lang.Object
java.io.InputStream
org.apache.cassandra.io.util.DataInputPlus.DataInputStreamPlus
org.apache.cassandra.io.util.RebufferingInputStream
org.apache.cassandra.io.util.RandomAccessReader
- All Implemented Interfaces:
Closeable,DataInput,AutoCloseable,DataInputPlus,FileDataInput,RewindableDataInput
- Direct Known Subclasses:
RandomAccessReaderAdapter
@NotThreadSafe
public class RandomAccessReader
extends RebufferingInputStream
implements FileDataInput
-
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 -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRandomAccessReader(Rebufferer rebufferer) Only created through Builder -
Method Summary
Modifier and TypeMethodDescriptionintlonglongbytesPastMark(DataPosition mark) longvoidclose()protected longcurrent()doublelonggetPath()longbooleanisEOF()longlength()mark()booleanstatic RandomAccessReaderOpen a RandomAccessReader (not compressed, not mmapped, no read throttling) that will own its channel.final StringreadLine()Reads a line of text form the current position in this file.voidreBuffer()Read data from file starting from current currentOffset to populate buffer.voidreset()voidreset(DataPosition mark) voidseek(long newPosition) intskipBytes(int n) Always skips the requested number of bytes, unless EOF is reachedtoString()Methods inherited from class org.apache.cassandra.io.util.RebufferingInputStream
read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readFully, readInt, readLong, readPrimitiveSlowly, readShort, readUnsignedByte, readUnsignedShort, readUnsignedVInt, readUnsignedVInt32, readUTF, readVInt, readVInt32Methods inherited from class java.io.InputStream
mark, nullInputStream, read, readAllBytes, readNBytes, readNBytes, skip, skipNBytes, transferToMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.io.DataInput
readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTFMethods inherited from interface org.apache.cassandra.io.util.DataInputPlus
readUnsignedVInt, readUnsignedVInt32, readVInt, readVInt32, skipBytesFully
-
Field Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE- See Also:
-
bufferHolder
-
-
Constructor Details
-
RandomAccessReader
Only created through Builder- Parameters:
rebufferer- Rebufferer to use
-
-
Method Details
-
reBuffer
public void reBuffer()Read data from file starting from current currentOffset to populate buffer.- Specified by:
reBufferin classRebufferingInputStream
-
getFilePointer
public long getFilePointer()- Specified by:
getFilePointerin interfaceFileDataInput
-
current
protected long current() -
getPath
- Specified by:
getPathin interfaceFileDataInput
-
getChannel
-
reset
- Overrides:
resetin classInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classInputStream
-
bytesPastMark
public long bytesPastMark() -
mark
- Specified by:
markin interfaceRewindableDataInput
-
reset
- Specified by:
resetin interfaceRewindableDataInput
-
bytesPastMark
- Specified by:
bytesPastMarkin interfaceRewindableDataInput
-
isEOF
public boolean isEOF()- Specified by:
isEOFin interfaceFileDataInput- Returns:
- true if there is no more data to read
-
bytesRemaining
public long bytesRemaining()- Specified by:
bytesRemainingin interfaceFileDataInput
-
available
- Overrides:
availablein classInputStream- Throws:
IOException
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream
-
toString
-
seek
public void seek(long newPosition) - Specified by:
seekin interfaceFileDataInput
-
skipBytes
Description copied from interface:DataInputPlusAlways skips the requested number of bytes, unless EOF is reached- Specified by:
skipBytesin interfaceDataInput- Specified by:
skipBytesin interfaceDataInputPlus- Overrides:
skipBytesin classRebufferingInputStream- Parameters:
n- number of bytes to skip- Returns:
- number of bytes skipped
- Throws:
IOException
-
readLine
Reads a line of text form the current position in this file. A line is represented by zero or more characters followed by'\n','\r',"\r\n"or the end of file marker. The string does not include the line terminating sequence.Blocks until a line terminating sequence has been read, the end of the file is reached or an exception is thrown.
- Specified by:
readLinein interfaceDataInput- Overrides:
readLinein classRebufferingInputStream- Returns:
- the contents of the line or
nullif no characters have been read before the end of the file has been reached. - Throws:
IOException- if this file is closed or another I/O error occurs.
-
length
public long length() -
getPosition
public long getPosition() -
getCrcCheckChance
public double getCrcCheckChance() -
open
Open a RandomAccessReader (not compressed, not mmapped, no read throttling) that will own its channel.- Parameters:
file- File to open for reading- Returns:
- new RandomAccessReader that owns the channel opened in this method.
-