org.apache.cassandra.io.util

## Class RandomAccessReader

- java.lang.Object
- - java.io.InputStream
  - - org.apache.cassandra.io.util.AbstractDataInput
    - - org.apache.cassandra.io.util.RandomAccessReader

All Implemented Interfaces:
  java.io.Closeable, java.io.DataInput, java.lang.AutoCloseable, FileDataInput

Direct Known Subclasses:
  ChecksummedRandomAccessReader, CompressedRandomAccessReader, ThrottledReader

    public class RandomAccessReader
    extends AbstractDataInput
    implements FileDataInput

### Nested Class Summary

Nested Classes
`protected static class` `RandomAccessReader.BufferedRandomAccessFileMark` Class to hold a mark to the position of the file

### Field Summary

Fields
`protected java.nio.ByteBuffer` `buffer`
`static int` `BUFFER_SIZE`
`protected long` `bufferOffset`
`protected ChannelProxy` `channel`
`static int` `DEFAULT_BUFFER_SIZE`
`protected long` `markedPointer`
`protected PoolingSegmentedFile` `owner`

### Constructor Summary

Constructors
`protected` `RandomAccessReader(ChannelProxy channel, int bufferSize, long overrideLength, BufferType bufferType, PoolingSegmentedFile owner)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`protected java.nio.ByteBuffer` `allocateBuffer(int bufferSize, BufferType bufferType)`
`long` `bytesPastMark()`
`long` `bytesPastMark(FileMark mark)`
`long` `bytesRemaining()`
`void` `close()`
`protected long` `current()`
`void` `deallocate()`
`ChannelProxy` `getChannel()`
`long` `getFilePointer()`
`java.lang.String` `getPath()`
`long` `getPosition()`
`long` `getPositionLimit()`
`int` `getTotalBufferSize()`
`boolean` `isEOF()`
`long` `length()`
`FileMark` `mark()`
`static RandomAccessReader` `open(ChannelProxy channel)`
`static RandomAccessReader` `open(ChannelProxy channel, long overrideSize)`
`static RandomAccessReader` `open(ChannelProxy channel, long overrideSize, PoolingSegmentedFile owner)`
`static RandomAccessReader` `open(java.io.File file)`
`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)`
`void` `seek(long newPosition)`
`java.lang.String` `toString()`

### Methods inherited from class org.apache.cassandra.io.util.AbstractDataInput

`readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, skipBytes`

### Methods inherited from class java.io.InputStream

`available, mark, markSupported, skip`

### 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

#### DEFAULT_BUFFER_SIZE

    public static final int DEFAULT_BUFFER_SIZE

See Also:
  Constant Field Values

#### BUFFER_SIZE

    public static final int BUFFER_SIZE

#### buffer

    protected java.nio.ByteBuffer buffer

#### bufferOffset

    protected long bufferOffset

#### markedPointer

    protected long markedPointer

#### channel

    protected final ChannelProxy channel

#### owner

    protected final PoolingSegmentedFile owner

### Constructor Detail

#### RandomAccessReader

    protected RandomAccessReader(ChannelProxy channel,
                                 int bufferSize,
                                 long overrideLength,
                                 BufferType bufferType,
                                 PoolingSegmentedFile owner)

### Method Detail

#### allocateBuffer

    protected java.nio.ByteBuffer allocateBuffer(int bufferSize,
                                                 BufferType bufferType)

#### open

    public static RandomAccessReader open(ChannelProxy channel,
                                          long overrideSize,
                                          PoolingSegmentedFile owner)

#### open

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

#### open

    public static RandomAccessReader open(ChannelProxy channel)

#### open

    public static RandomAccessReader open(ChannelProxy channel,
                                          long overrideSize)

#### getChannel

    public ChannelProxy getChannel()

#### 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`

#### current

    protected long current()

#### getPath

    public java.lang.String getPath()

Specified by:
  `getPath` in interface `FileDataInput`

#### getTotalBufferSize

    public int getTotalBufferSize()

#### reset

    public void reset()

Overrides:
  `reset` in class `java.io.InputStream`

#### 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`

#### close

    public void close()

Specified by:
  `close` in interface `java.io.Closeable`
Specified by:
  `close` in interface `java.lang.AutoCloseable`
Overrides:
  `close` in class `java.io.InputStream`

#### 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`
Specified by:
  `seek` in class `AbstractDataInput`

#### read

    public int read()

Specified by:
  `read` in class `java.io.InputStream`

#### read

    public int read(byte[] buffer)

Overrides:
  `read` in class `java.io.InputStream`

#### read

    public int read(byte[] buff,
                    int offset,
                    int length)

Overrides:
  `read` in class `java.io.InputStream`

#### 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()

#### getPosition

    public long getPosition()

Specified by:
  `getPosition` in class `AbstractDataInput`

#### getPositionLimit

    public long getPositionLimit()

Specified by:
  `getPositionLimit` in class `AbstractDataInput`