|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.flume.serialization.ResettableInputStream org.apache.flume.serialization.ResettableFileInputStream
@InterfaceAudience.Private @InterfaceStability.Evolving public class ResettableFileInputStream
This class makes the following assumptions:
reset()
is dependent on the underlying PositionTracker
instance's durability semantics.
Field Summary | |
---|---|
static int |
DEFAULT_BUF_SIZE
|
Constructor Summary | |
---|---|
ResettableFileInputStream(File file,
PositionTracker tracker)
|
|
ResettableFileInputStream(File file,
PositionTracker tracker,
int bufSize,
Charset charset)
|
Method Summary | |
---|---|
void |
close()
|
long |
getMarkPosition()
Return the saved mark position without moving the mark pointer. |
long |
length()
returns the total length of the stream or file |
void |
mark()
Marks the current position in this input stream. |
void |
markPosition(long position)
Indicate that the specified position should be returned to in the case of Resettable.reset() being called. |
int |
read()
Read a single byte of data from the stream. |
int |
read(byte[] b,
int off,
int len)
Read multiple bytes of data from the stream. |
int |
readChar()
Read a single character. |
void |
reset()
Reset stream position to that set by ResettableInputStream.mark() |
void |
seek(long newPos)
Seek to the specified byte position in the stream. |
long |
tell()
Tell the current byte position. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_BUF_SIZE
Constructor Detail |
---|
public ResettableFileInputStream(File file, PositionTracker tracker) throws IOException
file
- File to readtracker
- PositionTracker implementation to make offset position durable
FileNotFoundException
IOException
public ResettableFileInputStream(File file, PositionTracker tracker, int bufSize, Charset charset) throws IOException
file
- File to readtracker
- PositionTracker implementation to make offset position durablebufSize
- Size of the underlying buffer used for inputcharset
- Character set used for decoding text, as necessary
FileNotFoundException
IOException
Method Detail |
---|
public int read() throws IOException
ResettableInputStream
read
in class ResettableInputStream
-1
if the end of the stream has
been reached.
IOException
public int read(byte[] b, int off, int len) throws IOException
ResettableInputStream
read
in class ResettableInputStream
b
- the buffer into which the data is read.off
- Offset into the array b
at which the data is written.len
- the maximum number of bytes to read.
-1
if
the end of the stream has been reached.
IOException
public int readChar() throws IOException
ResettableInputStream
Read a single character.
Note that this may lead to returning only one character in a 2-char surrogate pair sequence. When this happens, the underlying implementation should never persist a mark between two chars of a two-char surrogate pair sequence.
readChar
in class ResettableInputStream
IOException
public void mark() throws IOException
ResettableInputStream
reset
method repositions this stream at the last marked
position so that subsequent reads re-read the same bytes.
Marking a closed stream should not have any effect on the stream.
mark
in interface Resettable
mark
in class ResettableInputStream
IOException
- If there is an error while setting the mark position.InputStream.mark(int)
,
InputStream.reset()
public void markPosition(long position) throws IOException
RemoteMarkable
Resettable.reset()
being called.
markPosition
in interface RemoteMarkable
IOException
public long getMarkPosition() throws IOException
RemoteMarkable
getMarkPosition
in interface RemoteMarkable
IOException
public void reset() throws IOException
ResettableInputStream
ResettableInputStream.mark()
reset
in interface Resettable
reset
in class ResettableInputStream
IOException
public long length() throws IOException
LengthMeasurable
length
in interface LengthMeasurable
IOException
public long tell() throws IOException
ResettableInputStream
tell
in interface Seekable
tell
in class ResettableInputStream
IOException
public void seek(long newPos) throws IOException
ResettableInputStream
seek
in interface Seekable
seek
in class ResettableInputStream
newPos
- Absolute byte offset to seek to
IOException
public void close() throws IOException
close
in interface Closeable
close
in class ResettableInputStream
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |