public class RandomAccessReader extends RebufferingInputStream implements FileDataInput
Modifier and Type | Class and Description |
---|---|
protected static class |
RandomAccessReader.BufferedRandomAccessFileMark
Class to hold a mark to the position of the file
|
static class |
RandomAccessReader.Builder |
static class |
RandomAccessReader.RandomAccessReaderWithOwnChannel |
DataInputPlus.DataInputStreamPlus
Modifier and Type | Field and Description |
---|---|
protected long |
bufferOffset |
protected int |
bufferSize |
protected BufferType |
bufferType |
protected ChannelProxy |
channel |
static int |
DEFAULT_BUFFER_SIZE |
protected com.google.common.util.concurrent.RateLimiter |
limiter |
protected long |
markedPointer |
static int |
MAX_BUFFER_SIZE |
protected MmappedRegions |
regions |
buffer
Modifier | Constructor and Description |
---|---|
protected |
RandomAccessReader(RandomAccessReader.Builder builder) |
Modifier and Type | Method and Description |
---|---|
protected static java.nio.ByteBuffer |
allocateBuffer(int size,
BufferType bufferType) |
int |
available() |
long |
bytesPastMark() |
long |
bytesPastMark(DataPosition mark) |
long |
bytesRemaining() |
void |
close() |
protected long |
current() |
ChannelProxy |
getChannel() |
long |
getFilePointer() |
java.lang.String |
getPath() |
long |
getPosition() |
boolean |
isEOF() |
long |
length() |
DataPosition |
mark() |
boolean |
markSupported() |
static RandomAccessReader |
open(ChannelProxy channel) |
static RandomAccessReader |
open(java.io.File file) |
java.lang.String |
readLine()
Reads a line of text form the current position in this file.
|
void |
reBuffer()
Read data from file starting from current currentOffset to populate buffer.
|
protected void |
reBufferMmap() |
protected void |
reBufferStandard() |
protected void |
releaseBuffer() |
void |
reset() |
void |
reset(DataPosition mark) |
void |
seek(long newPosition) |
java.lang.String |
toString() |
read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLong, readPrimitiveSlowly, readShort, readUnsignedByte, readUnsignedShort, readUnsignedVInt, readUTF, readVInt, skipBytes
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
readUnsignedVInt, readVInt, skipBytes, skipBytesFully
public static final int DEFAULT_BUFFER_SIZE
public static final int MAX_BUFFER_SIZE
protected final ChannelProxy channel
protected final MmappedRegions regions
protected final com.google.common.util.concurrent.RateLimiter limiter
protected final int bufferSize
protected final BufferType bufferType
protected long bufferOffset
protected long markedPointer
protected RandomAccessReader(RandomAccessReader.Builder builder)
protected static java.nio.ByteBuffer allocateBuffer(int size, BufferType bufferType)
protected void releaseBuffer()
public void reBuffer()
reBuffer
in class RebufferingInputStream
protected void reBufferStandard()
protected void reBufferMmap()
public long getFilePointer()
getFilePointer
in interface FileDataInput
protected long current()
public java.lang.String getPath()
getPath
in interface FileDataInput
public ChannelProxy getChannel()
public void reset() throws java.io.IOException
reset
in class RebufferingInputStream
java.io.IOException
public boolean markSupported()
markSupported
in class RebufferingInputStream
public long bytesPastMark()
public DataPosition mark()
mark
in interface RewindableDataInput
public void reset(DataPosition mark)
reset
in interface RewindableDataInput
public long bytesPastMark(DataPosition mark)
bytesPastMark
in interface RewindableDataInput
public boolean isEOF()
isEOF
in interface FileDataInput
public long bytesRemaining()
bytesRemaining
in interface FileDataInput
public int available() throws java.io.IOException
available
in class java.io.InputStream
java.io.IOException
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.InputStream
public java.lang.String toString()
toString
in class java.lang.Object
public void seek(long newPosition)
seek
in interface FileDataInput
public final java.lang.String readLine() throws java.io.IOException
'\n'
, '\r'
, "\r\n"
or the end of file marker. The string does not
include the line terminating sequence.
Blocks until a line terminating sequence has been read, the end of the
file is reached or an exception is thrown.readLine
in interface java.io.DataInput
readLine
in class RebufferingInputStream
null
if no characters have
been read before the end of the file has been reached.java.io.IOException
- if this file is closed or another I/O error occurs.public long length()
public long getPosition()
public static RandomAccessReader open(java.io.File file)
public static RandomAccessReader open(ChannelProxy channel)
Copyright © 2019 The Apache Software Foundation