org.apache.cassandra.io.util
Class RandomAccessReader
java.lang.Object
java.io.RandomAccessFile
org.apache.cassandra.io.util.RandomAccessReader
- All Implemented Interfaces:
- java.io.Closeable, java.io.DataInput, java.io.DataOutput, FileDataInput
- Direct Known Subclasses:
- CompressedRandomAccessReader
public class RandomAccessReader
- extends java.io.RandomAccessFile
- implements FileDataInput
Constructor Summary |
RandomAccessReader(java.io.File file,
int bufferSize,
boolean skipIOCache)
|
Methods inherited from class java.io.RandomAccessFile |
getChannel, getFD, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, setLength, skipBytes, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF |
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, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, skipBytes |
MAX_BYTES_IN_PAGE_CACHE
public static final long MAX_BYTES_IN_PAGE_CACHE
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE
- See Also:
- Constant Field Values
buffer
protected byte[] buffer
bufferOffset
protected long bufferOffset
current
protected long current
markedPointer
protected long markedPointer
validBufferBytes
protected int validBufferBytes
channel
protected final java.nio.channels.FileChannel channel
RandomAccessReader
public RandomAccessReader(java.io.File file,
int bufferSize,
boolean skipIOCache)
throws java.io.IOException
- Throws:
java.io.IOException
open
public static RandomAccessReader open(java.io.File file,
boolean skipIOCache)
throws java.io.IOException
- Throws:
java.io.IOException
open
public static RandomAccessReader open(java.io.File file)
throws java.io.IOException
- Throws:
java.io.IOException
open
public static RandomAccessReader open(java.io.File file,
int bufferSize)
throws java.io.IOException
- Throws:
java.io.IOException
open
public static RandomAccessReader open(java.io.File file,
int bufferSize,
boolean skipIOCache)
throws java.io.IOException
- Throws:
java.io.IOException
open
public static RandomAccessReader open(SequentialWriter writer)
throws java.io.IOException
- Throws:
java.io.IOException
reBuffer
protected void reBuffer()
throws java.io.IOException
- Read data from file starting from current currentOffset to populate buffer.
- Throws:
java.io.IOException
- on any I/O error.
getFilePointer
public long getFilePointer()
- Overrides:
getFilePointer
in class java.io.RandomAccessFile
getPath
public java.lang.String getPath()
- Specified by:
getPath
in interface FileDataInput
reset
public void reset()
throws java.io.IOException
- Throws:
java.io.IOException
bytesPastMark
public long bytesPastMark()
mark
public FileMark mark()
- Specified by:
mark
in interface FileDataInput
reset
public void reset(FileMark mark)
throws java.io.IOException
- Specified by:
reset
in interface FileDataInput
- Throws:
java.io.IOException
bytesPastMark
public long bytesPastMark(FileMark mark)
- Specified by:
bytesPastMark
in interface FileDataInput
isEOF
public boolean isEOF()
throws java.io.IOException
- Specified by:
isEOF
in interface FileDataInput
- Returns:
- true if there is no more data to read
- Throws:
java.io.IOException
- on any I/O error.
bytesRemaining
public long bytesRemaining()
throws java.io.IOException
- Specified by:
bytesRemaining
in interface FileDataInput
- Throws:
java.io.IOException
bufferCursor
protected int bufferCursor()
resetBuffer
protected void resetBuffer()
close
public void close()
throws java.io.IOException
- Specified by:
close
in interface java.io.Closeable
- Overrides:
close
in class java.io.RandomAccessFile
- Throws:
java.io.IOException
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
seek
public void seek(long newPosition)
throws java.io.IOException
- Overrides:
seek
in class java.io.RandomAccessFile
- Throws:
java.io.IOException
read
public int read()
throws java.io.IOException
- Overrides:
read
in class java.io.RandomAccessFile
- Throws:
java.io.IOException
read
public int read(byte[] buffer)
throws java.io.IOException
- Overrides:
read
in class java.io.RandomAccessFile
- Throws:
java.io.IOException
read
public int read(byte[] buff,
int offset,
int length)
throws java.io.IOException
- Overrides:
read
in class java.io.RandomAccessFile
- Throws:
java.io.IOException
readBytes
public java.nio.ByteBuffer readBytes(int length)
throws java.io.IOException
- Description copied from interface:
FileDataInput
- Read length bytes from current file position
- Specified by:
readBytes
in interface FileDataInput
- Parameters:
length
- length of the bytes to read
- Returns:
- buffer with bytes read
- Throws:
java.io.IOException
- if any I/O operation failed
length
public long length()
throws java.io.IOException
- Overrides:
length
in class java.io.RandomAccessFile
- Throws:
java.io.IOException
write
public void write(int value)
throws java.io.IOException
- Specified by:
write
in interface java.io.DataOutput
- Overrides:
write
in class java.io.RandomAccessFile
- Throws:
java.io.IOException
write
public void write(byte[] buffer)
throws java.io.IOException
- Specified by:
write
in interface java.io.DataOutput
- Overrides:
write
in class java.io.RandomAccessFile
- Throws:
java.io.IOException
write
public void write(byte[] buffer,
int offset,
int length)
throws java.io.IOException
- Specified by:
write
in interface java.io.DataOutput
- Overrides:
write
in class java.io.RandomAccessFile
- Throws:
java.io.IOException
Copyright © 2011 The Apache Software Foundation