public class RandomAccessReader extends AbstractDataInput implements FileDataInput
| Modifier and Type | Class and Description |
|---|---|
protected static class |
RandomAccessReader.BufferedRandomAccessFileMark
Class to hold a mark to the position of the file
|
DataInputPlus.DataInputStreamPlus| Modifier and Type | Field and Description |
|---|---|
protected java.nio.ByteBuffer |
buffer |
protected long |
bufferOffset |
protected ChannelProxy |
channel |
static int |
DEFAULT_BUFFER_SIZE |
protected long |
markedPointer |
| Modifier | Constructor and Description |
|---|---|
protected |
RandomAccessReader(ChannelProxy channel,
int bufferSize,
long overrideLength,
BufferType bufferType) |
| Modifier and Type | Method and Description |
|---|---|
protected java.nio.ByteBuffer |
allocateBuffer(int size,
BufferType bufferType) |
long |
bytesPastMark() |
long |
bytesPastMark(FileMark mark) |
long |
bytesRemaining() |
void |
close() |
protected long |
current() |
protected int |
getBufferSize(int size)
The buffer size is typically already page aligned but if that is not the case
make sure that it is a multiple of the page size, 4096.
|
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,
int bufferSize,
long overrideSize) |
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() |
readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, skipBytesclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitreadUnsignedVInt, readVIntpublic static final int DEFAULT_BUFFER_SIZE
protected final ChannelProxy channel
protected java.nio.ByteBuffer buffer
protected long bufferOffset
protected long markedPointer
protected RandomAccessReader(ChannelProxy channel, int bufferSize, long overrideLength, BufferType bufferType)
protected int getBufferSize(int size)
protected java.nio.ByteBuffer allocateBuffer(int size,
BufferType bufferType)
public static RandomAccessReader open(java.io.File file)
public static RandomAccessReader open(ChannelProxy channel)
public static RandomAccessReader open(ChannelProxy channel, int bufferSize, long overrideSize)
public ChannelProxy getChannel()
protected void reBuffer()
public long getFilePointer()
getFilePointer in interface FileDataInputprotected long current()
public java.lang.String getPath()
getPath in interface FileDataInputpublic int getTotalBufferSize()
public void reset()
reset in class java.io.InputStreampublic long bytesPastMark()
public FileMark mark()
mark in interface FileDataInputpublic void reset(FileMark mark)
reset in interface FileDataInputpublic long bytesPastMark(FileMark mark)
bytesPastMark in interface FileDataInputpublic boolean isEOF()
isEOF in interface FileDataInputpublic long bytesRemaining()
bytesRemaining in interface FileDataInputpublic void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.InputStreampublic java.lang.String toString()
toString in class java.lang.Objectpublic void seek(long newPosition)
seek in interface FileDataInputseek in class AbstractDataInputpublic int read()
read in class java.io.InputStreampublic int read(byte[] buffer)
read in class java.io.InputStreampublic int read(byte[] buff,
int offset,
int length)
read in class java.io.InputStreampublic java.nio.ByteBuffer readBytes(int length)
throws java.io.EOFException
FileDataInputreadBytes in interface FileDataInputlength - length of the bytes to readjava.io.EOFExceptionpublic long length()
public long getPosition()
getPosition in class AbstractDataInputpublic long getPositionLimit()
getPositionLimit in class AbstractDataInputCopyright © 2015 The Apache Software Foundation