Package org.apache.cassandra.io.util
Class RandomAccessReader
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.cassandra.io.util.RebufferingInputStream
-
- org.apache.cassandra.io.util.RandomAccessReader
-
- All Implemented Interfaces:
java.io.Closeable,java.io.DataInput,java.lang.AutoCloseable,DataInputPlus,FileDataInput,RewindableDataInput
@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
Fields Modifier and Type Field Description static intDEFAULT_BUFFER_SIZE-
Fields inherited from class org.apache.cassandra.io.util.RebufferingInputStream
buffer
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()longbytesPastMark()longbytesPastMark(DataPosition mark)longbytesRemaining()voidclose()protected longcurrent()ChannelProxygetChannel()doublegetCrcCheckChance()longgetFilePointer()java.lang.StringgetPath()longgetPosition()booleanisEOF()longlength()DataPositionmark()booleanmarkSupported()static RandomAccessReaderopen(File file)Open a RandomAccessReader (not compressed, not mmapped, no read throttling) that will own its channel.java.lang.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 reachedjava.lang.StringtoString()-
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, readUTF, readVInt
-
Methods inherited from class java.io.InputStream
mark, nullInputStream, read, readAllBytes, readNBytes, readNBytes, skip, transferTo
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.io.DataInput
readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF
-
Methods inherited from interface org.apache.cassandra.io.util.DataInputPlus
readUnsignedVInt, readVInt, skipBytesFully
-
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
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
public java.lang.String getPath()
- Specified by:
getPathin interfaceFileDataInput
-
getChannel
public ChannelProxy getChannel()
-
reset
public void reset() throws java.io.IOException- Overrides:
resetin classjava.io.InputStream- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classjava.io.InputStream
-
bytesPastMark
public long bytesPastMark()
-
mark
public DataPosition mark()
- Specified by:
markin interfaceRewindableDataInput
-
reset
public void reset(DataPosition mark)
- Specified by:
resetin interfaceRewindableDataInput
-
bytesPastMark
public long bytesPastMark(DataPosition mark)
- 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
public int available() throws java.io.IOException- Overrides:
availablein classjava.io.InputStream- Throws:
java.io.IOException
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
seek
public void seek(long newPosition)
- Specified by:
seekin interfaceFileDataInput
-
skipBytes
public int skipBytes(int n) throws java.io.IOExceptionDescription copied from interface:DataInputPlusAlways skips the requested number of bytes, unless EOF is reached- Specified by:
skipBytesin interfacejava.io.DataInput- Specified by:
skipBytesin interfaceDataInputPlus- Overrides:
skipBytesin classRebufferingInputStream- Parameters:
n- number of bytes to skip- Returns:
- number of bytes skipped
- Throws:
java.io.IOException
-
readLine
public final java.lang.String readLine() throws java.io.IOExceptionReads 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 interfacejava.io.DataInput- 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:
java.io.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
public static RandomAccessReader open(File file)
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.
-
-