@InterfaceAudience.Public @InterfaceStability.Evolving public abstract class FSInputStream extends InputStream implements Seekable, PositionedReadable
Constructor and Description |
---|
FSInputStream() |
Modifier and Type | Method and Description |
---|---|
abstract long |
getPos()
Return the current offset from the start of the file
|
int |
read(long position,
byte[] buffer,
int offset,
int length)
Read up to the specified number of bytes, from a given
position within a file, and return the number of bytes read.
|
void |
readFully(long position,
byte[] buffer)
Read number of bytes equal to the length of the buffer, from a given
position within a file.
|
void |
readFully(long position,
byte[] buffer,
int offset,
int length)
Read the specified number of bytes, from a given
position within a file.
|
abstract void |
seek(long pos)
Seek to the given offset from the start of the file.
|
abstract boolean |
seekToNewSource(long targetPos)
Seeks a different copy of the data.
|
String |
toString()
toString method returns the superclass toString, but if the subclass
implements
IOStatisticsSource then those statistics are
extracted and included in the output. |
protected void |
validatePositionedReadArgs(long position,
byte[] buffer,
int offset,
int length)
Validation code, available for use in subclasses.
|
available, close, mark, markSupported, read, read, read, reset, skip
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
maxReadSizeForVectorReads, minSeekForVectorReads, readVectored
public abstract void seek(long pos) throws IOException
seek
in interface Seekable
pos
- offset from the start of the file.IOException
- raised on errors performing I/O.public abstract long getPos() throws IOException
getPos
in interface Seekable
IOException
- raised on errors performing I/O.public abstract boolean seekToNewSource(long targetPos) throws IOException
IOException
public int read(long position, byte[] buffer, int offset, int length) throws IOException
PositionedReadable
read
in interface PositionedReadable
position
- position within filebuffer
- destination bufferoffset
- offset in the bufferlength
- number of bytes to readIOException
- IO problems.protected void validatePositionedReadArgs(long position, byte[] buffer, int offset, int length) throws EOFException
position
- position: if negative an EOF exception is raisedbuffer
- destination bufferoffset
- offset within the bufferlength
- length of bytes to readEOFException
- if the position is negativeIndexOutOfBoundsException
- if there isn't space for the amount of
data requested.IllegalArgumentException
- other arguments are invalid.public void readFully(long position, byte[] buffer, int offset, int length) throws IOException
PositionedReadable
readFully
in interface PositionedReadable
position
- position within filebuffer
- destination bufferoffset
- offset in the bufferlength
- number of bytes to readIOException
- IO problems.EOFException
- the end of the data was reached before
the read operation completedpublic void readFully(long position, byte[] buffer) throws IOException
PositionedReadable
readFully
in interface PositionedReadable
position
- position within filebuffer
- destination bufferIOException
- IO problems.EOFException
- the end of the data was reached before
the read operation completedpublic String toString()
IOStatisticsSource
then those statistics are
extracted and included in the output.
That is: statistics of subclasses are automatically reported.Copyright © 2024 Apache Software Foundation. All rights reserved.