org.apache.cassandra.io.util
Class RandomAccessReader

java.lang.Object
  extended by java.io.RandomAccessFile
      extended by 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


Nested Class Summary
protected static class RandomAccessReader.BufferedRandomAccessFileMark
          Class to hold a mark to the position of the file
 
Field Summary
protected  byte[] buffer
           
protected  long bufferOffset
           
static long CACHE_FLUSH_INTERVAL_IN_BYTES
           
protected  java.nio.channels.FileChannel channel
           
protected  long current
           
static int DEFAULT_BUFFER_SIZE
           
protected  long markedPointer
           
protected  PoolingSegmentedFile owner
           
protected  int validBufferBytes
           
 
Constructor Summary
protected RandomAccessReader(java.io.File file, int bufferSize, boolean skipIOCache, PoolingSegmentedFile owner)
           
 
Method Summary
protected  int bufferCursor()
           
 long bytesPastMark()
           
 long bytesPastMark(FileMark mark)
           
 long bytesRemaining()
           
 void close()
           
 void deallocate()
           
 long getFilePointer()
           
 java.lang.String getPath()
           
 boolean isEOF()
           
 long length()
           
 FileMark mark()
           
static RandomAccessReader open(java.io.File file)
           
static RandomAccessReader open(java.io.File file, boolean skipIOCache)
           
static RandomAccessReader open(java.io.File file, PoolingSegmentedFile owner)
           
 int read()
           
 int read(byte[] buffer)
           
 int read(byte[] buff, int offset, int length)
           
 java.nio.ByteBuffer readBytes(int length)
          Read length bytes from current file position
protected  void reBuffer()
          Read data from file starting from current currentOffset to populate buffer.
 void reset()
           
 void reset(FileMark mark)
           
protected  void resetBuffer()
           
 void seek(long newPosition)
           
 java.lang.String toString()
           
 void write(byte[] buffer)
           
 void write(byte[] buffer, int offset, int length)
           
 void write(int value)
           
 
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
 

Field Detail

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

owner

protected final PoolingSegmentedFile owner
Constructor Detail

RandomAccessReader

protected RandomAccessReader(java.io.File file,
                             int bufferSize,
                             boolean skipIOCache,
                             PoolingSegmentedFile owner)
                      throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException
Method Detail

open

public static RandomAccessReader open(java.io.File file)

open

public static RandomAccessReader open(java.io.File file,
                                      PoolingSegmentedFile owner)

open

public static RandomAccessReader open(java.io.File file,
                                      boolean skipIOCache)

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

deallocate

public void deallocate()

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 © 2013 The Apache Software Foundation