public class RewindableDataInputStreamPlus extends java.io.FilterInputStream implements RewindableDataInput, java.io.Closeable
this#mark() or this#mark(int), up to
maxMemBufferSize will be cached in memory (heap). If more than
maxMemBufferSize bytes are read while the stream is marked, the
following bytes are cached on the spillFile for up to maxDiskBufferSize.
Please note that successive calls to this#mark() and this#reset() will write
sequentially to the same spillFile until maxDiskBufferSize is reached.
At this point, if less than maxDiskBufferSize bytes are currently cached on the
spillFile, the remaining bytes are written to the beginning of the file,
treating the spillFile as a circular buffer.
If more than maxMemBufferSize + maxDiskBufferSize are cached while the stream is marked,
the following this#reset() invocation will throw a IllegalStateException.| Modifier and Type | Class and Description |
|---|---|
protected static class |
RewindableDataInputStreamPlus.RewindableDataInputPlusMark |
DataInputPlus.DataInputStreamPlus| Modifier and Type | Field and Description |
|---|---|
protected int |
diskHeadAvailable |
protected int |
diskTailAvailable |
protected int |
memAvailable |
| Constructor and Description |
|---|
RewindableDataInputStreamPlus(java.io.InputStream in,
int initialMemBufferSize,
int maxMemBufferSize,
java.io.File spillFile,
int maxDiskBufferSize) |
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
long |
bytesPastMark(DataPosition mark) |
void |
close() |
void |
close(boolean closeUnderlying) |
DataPosition |
mark()
Marks the current position of a stream to return to this position later via the
this#reset(DataPosition) method. |
void |
mark(int readlimit)
Marks the current position of a stream to return to this position
later via the
this#reset() method. |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
boolean |
readBoolean() |
byte |
readByte() |
char |
readChar() |
double |
readDouble() |
float |
readFloat() |
void |
readFully(byte[] b) |
void |
readFully(byte[] b,
int off,
int len) |
int |
readInt() |
java.lang.String |
readLine() |
long |
readLong() |
short |
readShort() |
int |
readUnsignedByte() |
int |
readUnsignedShort() |
java.lang.String |
readUTF() |
void |
reset() |
void |
reset(DataPosition mark)
Rewinds to the previously marked position via the
this#mark() method. |
long |
skip(long n) |
int |
skipBytes(int n)
Always skips the requested number of bytes, unless EOF is reached
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitreadUnsignedVInt, readVInt, skipBytesFullyprotected int memAvailable
protected int diskTailAvailable
protected int diskHeadAvailable
public RewindableDataInputStreamPlus(java.io.InputStream in,
int initialMemBufferSize,
int maxMemBufferSize,
java.io.File spillFile,
int maxDiskBufferSize)
public DataPosition mark()
this#reset(DataPosition) method.mark in interface RewindableDataInputpublic void reset(DataPosition mark) throws java.io.IOException
this#mark() method.reset in interface RewindableDataInputmark - it's not possible to return to a custom position, so this parameter is ignored.java.io.IOException - if an error ocurs while resettingpublic long bytesPastMark(DataPosition mark)
bytesPastMark in interface RewindableDataInputpublic boolean markSupported()
markSupported in class java.io.FilterInputStreampublic void mark(int readlimit)
this#reset() method.mark in class java.io.FilterInputStreamreadlimit - the maximum amount of bytes to cachepublic void reset()
throws java.io.IOException
reset in class java.io.FilterInputStreamjava.io.IOExceptionpublic int available()
throws java.io.IOException
available in class java.io.FilterInputStreamjava.io.IOExceptionpublic int read()
throws java.io.IOException
read in class java.io.FilterInputStreamjava.io.IOExceptionpublic int read(byte[] b,
int off,
int len)
throws java.io.IOException
read in class java.io.FilterInputStreamjava.io.IOExceptionpublic int read(byte[] b)
throws java.io.IOException
read in class java.io.FilterInputStreamjava.io.IOExceptionpublic long skip(long n)
throws java.io.IOException
skip in class java.io.FilterInputStreamjava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.FilterInputStreamjava.io.IOExceptionpublic void close(boolean closeUnderlying)
throws java.io.IOException
java.io.IOExceptionpublic void readFully(byte[] b)
throws java.io.IOException
readFully in interface java.io.DataInputjava.io.IOExceptionpublic void readFully(byte[] b,
int off,
int len)
throws java.io.IOException
readFully in interface java.io.DataInputjava.io.IOExceptionpublic int skipBytes(int n)
throws java.io.IOException
DataInputPlusskipBytes in interface java.io.DataInputskipBytes in interface DataInputPlusn - number of bytes to skipjava.io.IOExceptionpublic boolean readBoolean()
throws java.io.IOException
readBoolean in interface java.io.DataInputjava.io.IOExceptionpublic byte readByte()
throws java.io.IOException
readByte in interface java.io.DataInputjava.io.IOExceptionpublic int readUnsignedByte()
throws java.io.IOException
readUnsignedByte in interface java.io.DataInputjava.io.IOExceptionpublic short readShort()
throws java.io.IOException
readShort in interface java.io.DataInputjava.io.IOExceptionpublic int readUnsignedShort()
throws java.io.IOException
readUnsignedShort in interface java.io.DataInputjava.io.IOExceptionpublic char readChar()
throws java.io.IOException
readChar in interface java.io.DataInputjava.io.IOExceptionpublic int readInt()
throws java.io.IOException
readInt in interface java.io.DataInputjava.io.IOExceptionpublic long readLong()
throws java.io.IOException
readLong in interface java.io.DataInputjava.io.IOExceptionpublic float readFloat()
throws java.io.IOException
readFloat in interface java.io.DataInputjava.io.IOExceptionpublic double readDouble()
throws java.io.IOException
readDouble in interface java.io.DataInputjava.io.IOExceptionpublic java.lang.String readLine()
throws java.io.IOException
readLine in interface java.io.DataInputjava.io.IOExceptionpublic java.lang.String readUTF()
throws java.io.IOException
readUTF in interface java.io.DataInputjava.io.IOExceptionCopyright © 2016 The Apache Software Foundation