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 |
CACHE_FLUSH_INTERVAL_IN_BYTES
public static final long CACHE_FLUSH_INTERVAL_IN_BYTES
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.FileNotFoundException
- Throws:
java.io.FileNotFoundException
open
public static RandomAccessReader open(java.io.File file,
boolean skipIOCache)
open
public static RandomAccessReader open(java.io.File file)
open
public static RandomAccessReader open(java.io.File file,
int bufferSize)
open
public static RandomAccessReader open(java.io.File file,
int bufferSize,
boolean skipIOCache)
open
public static RandomAccessReader open(SequentialWriter writer)
reBuffer
protected void reBuffer()
- Read data from file starting from current currentOffset to populate buffer.
getFilePointer
public long getFilePointer()
- Specified by:
getFilePointer in interface FileDataInput- Overrides:
getFilePointer in class java.io.RandomAccessFile
getPath
public java.lang.String getPath()
- Specified by:
getPath in interface FileDataInput
reset
public void reset()
bytesPastMark
public long bytesPastMark()
mark
public FileMark mark()
- Specified by:
mark in interface FileDataInput
reset
public void reset(FileMark mark)
- Specified by:
reset in interface FileDataInput
bytesPastMark
public long bytesPastMark(FileMark mark)
- Specified by:
bytesPastMark in interface FileDataInput
isEOF
public boolean isEOF()
- Specified by:
isEOF in interface FileDataInput
- Returns:
- true if there is no more data to read
bytesRemaining
public long bytesRemaining()
- Specified by:
bytesRemaining in interface FileDataInput
bufferCursor
protected int bufferCursor()
resetBuffer
protected void resetBuffer()
close
public void close()
- Specified by:
close in interface java.io.Closeable- Overrides:
close in class java.io.RandomAccessFile
toString
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object
seek
public void seek(long newPosition)
- Specified by:
seek in interface FileDataInput- Overrides:
seek in class java.io.RandomAccessFile
read
public int read()
- Overrides:
read in class java.io.RandomAccessFile
read
public int read(byte[] buffer)
- Overrides:
read in class java.io.RandomAccessFile
read
public int read(byte[] buff,
int offset,
int length)
- Overrides:
read in class java.io.RandomAccessFile
readBytes
public java.nio.ByteBuffer readBytes(int length)
throws java.io.EOFException
- 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.EOFException
length
public long length()
- Overrides:
length in class java.io.RandomAccessFile
write
public void write(int value)
- Specified by:
write in interface java.io.DataOutput- Overrides:
write in class java.io.RandomAccessFile
write
public void write(byte[] buffer)
- Specified by:
write in interface java.io.DataOutput- Overrides:
write in class java.io.RandomAccessFile
write
public void write(byte[] buffer,
int offset,
int length)
- Specified by:
write in interface java.io.DataOutput- Overrides:
write in class java.io.RandomAccessFile
Copyright © 2012 The Apache Software Foundation