java.io.Closeable, java.lang.AutoCloseable, HasFileDescriptor, PositionedReadable, Seekable, IOStatisticsSource, StreamCapabilities@Private @Unstable public class BufferedFSInputStream extends java.io.BufferedInputStream implements Seekable, PositionedReadable, HasFileDescriptor, IOStatisticsSource, StreamCapabilities
StreamCapabilities.StreamCapabilityABORTABLE_STREAM, DROPBEHIND, HFLUSH, HSYNC, IOSTATISTICS, IOSTATISTICS_CONTEXT, PREADBYTEBUFFER, READAHEAD, READBYTEBUFFER, UNBUFFER, VECTOREDIO| Constructor | Description |
|---|---|
BufferedFSInputStream(FSInputStream in,
int size) |
Creates a
BufferedFSInputStream
with the specified buffer size,
and saves its argument, the input stream
in, for later use. |
| Modifier and Type | Method | Description |
|---|---|---|
java.io.FileDescriptor |
getFileDescriptor() |
|
IOStatistics |
getIOStatistics() |
Return a statistics instance.
|
long |
getPos() |
Return the current offset from the start of the file
|
boolean |
hasCapability(java.lang.String capability) |
If the inner stream supports
StreamCapabilities,
forward the probe to it. |
int |
maxReadSizeForVectorReads() |
What is the largest size that we should group ranges together as?
|
int |
minSeekForVectorReads() |
What is the smallest reasonable seek?
|
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.
|
void |
readVectored(java.util.List<? extends FileRange> ranges,
java.util.function.IntFunction<java.nio.ByteBuffer> allocate) |
Read fully a list of file ranges asynchronously from this file.
|
void |
seek(long pos) |
Seek to the given offset from the start of the file.
|
boolean |
seekToNewSource(long targetPos) |
Seeks a different copy of the data.
|
long |
skip(long n) |
|
java.lang.String |
toString() |
available, close, mark, markSupported, read, read, resetpublic BufferedFSInputStream(FSInputStream in, int size)
BufferedFSInputStream
with the specified buffer size,
and saves its argument, the input stream
in, for later use. An internal
buffer array of length size
is created and stored in buf.in - the underlying input stream.size - the buffer size.java.lang.IllegalArgumentException - if size <= 0.public long getPos()
throws java.io.IOException
Seekablepublic long skip(long n)
throws java.io.IOException
skip in class java.io.BufferedInputStreamjava.io.IOExceptionpublic void seek(long pos)
throws java.io.IOException
Seekablepublic boolean seekToNewSource(long targetPos)
throws java.io.IOException
SeekableseekToNewSource in interface SeekabletargetPos - target position.java.io.IOException - raised on errors performing I/O.public int read(long position,
byte[] buffer,
int offset,
int length)
throws java.io.IOException
PositionedReadableread in interface PositionedReadableposition - position within filebuffer - destination bufferoffset - offset in the bufferlength - number of bytes to readjava.io.IOException - IO problems.public void readFully(long position,
byte[] buffer,
int offset,
int length)
throws java.io.IOException
PositionedReadablereadFully in interface PositionedReadableposition - position within filebuffer - destination bufferoffset - offset in the bufferlength - number of bytes to readjava.io.IOException - IO problems.java.io.EOFException - the end of the data was reached before
the read operation completedpublic void readFully(long position,
byte[] buffer)
throws java.io.IOException
PositionedReadablereadFully in interface PositionedReadableposition - position within filebuffer - destination bufferjava.io.IOException - IO problems.java.io.EOFException - the end of the data was reached before
the read operation completedpublic java.io.FileDescriptor getFileDescriptor()
throws java.io.IOException
getFileDescriptor in interface HasFileDescriptorjava.io.IOException - raised on errors performing I/O.public boolean hasCapability(java.lang.String capability)
StreamCapabilities,
forward the probe to it.
Otherwise: return false.hasCapability in interface StreamCapabilitiescapability - string to query the stream support for.public IOStatistics getIOStatistics()
IOStatisticsSource
It is not a requirement that the same instance is returned every time.
IOStatisticsSource.
If the object implementing this is Closeable, this method may return null if invoked on a closed object, even if it returns a valid instance when called earlier.
getIOStatistics in interface IOStatisticsSourcepublic java.lang.String toString()
toString in class java.lang.Objectpublic int minSeekForVectorReads()
PositionedReadableminSeekForVectorReads in interface PositionedReadablepublic int maxReadSizeForVectorReads()
PositionedReadablemaxReadSizeForVectorReads in interface PositionedReadablepublic void readVectored(java.util.List<? extends FileRange> ranges, java.util.function.IntFunction<java.nio.ByteBuffer> allocate) throws java.io.IOException
PositionedReadableThe position returned by getPos() after readVectored() is undefined.
If a file is changed while the readVectored() operation is in progress, the output is undefined. Some ranges may have old data, some may have new and some may have both.
While a readVectored() operation is in progress, normal read api calls may block.
readVectored in interface PositionedReadableranges - the byte ranges to readallocate - the function to allocate ByteBufferjava.io.IOException - any IOE.Copyright © 2008–2025 Apache Software Foundation. All rights reserved.