public class S3APrefetchingInputStream extends ObjectInputStream implements org.apache.hadoop.fs.CanSetReadahead, org.apache.hadoop.fs.StreamCapabilities, org.apache.hadoop.fs.statistics.IOStatisticsSource
InputStream for reading from S3.
This implementation provides improved read throughput by asynchronously prefetching
blocks of configurable size from the underlying S3 file.| Constructor and Description |
|---|
S3APrefetchingInputStream(ObjectReadParameters parameters,
org.apache.hadoop.conf.Configuration conf,
PrefetchOptions prefetchOptions)
Initializes a new instance of the
S3APrefetchingInputStream class. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
abortInFinalizer()
Brute force stream close; invoked by
LeakReporter. |
int |
available()
Returns the number of bytes available for reading without blocking.
|
void |
close()
Closes this stream and releases all acquired resources.
|
org.apache.hadoop.fs.statistics.IOStatistics |
getIOStatistics()
Gets the internal IO statistics.
|
long |
getPos()
Gets the current position.
|
S3AInputStreamStatistics |
getS3AStreamStatistics()
Access the input stream statistics.
|
boolean |
hasCapability(String capability)
Indicates whether the given
capability is supported by this stream. |
protected boolean |
isClosed() |
protected boolean |
isStreamOpen()
Probe for stream being open.
|
boolean |
markSupported() |
int |
read()
Reads and returns one byte from this stream.
|
int |
read(byte[] buffer,
int offset,
int len)
Reads up to
len bytes from this stream and copies them into
the given buffer starting at the given offset. |
void |
seek(long pos)
Updates internal data such that the next read will take place at the given
pos. |
boolean |
seekToNewSource(long targetPos) |
void |
setReadahead(Long readahead)
Sets the number of bytes to read ahead each time.
|
protected void |
throwIfClosed() |
finalize, getBoundedThreadPool, getBucket, getCallbacks, getContentLength, getContext, getInputPolicy, getKey, getObjectAttributes, getPathStr, getThreadIOStatistics, getUri, getVectoredIOContext, maxReadSizeForVectorReads, mergeThreadIOStatistics, minSeekForVectorReads, setInputPolicy, streamType, toStringread, readFully, readFully, validatePositionedReadArgsmark, read, reset, skippublic S3APrefetchingInputStream(ObjectReadParameters parameters, org.apache.hadoop.conf.Configuration conf, PrefetchOptions prefetchOptions)
S3APrefetchingInputStream class.parameters - creation parameters.conf - the configuration.prefetchOptions - prefetch stream specific optionsNullPointerException - if a required parameter is null.public int available()
throws IOException
available in class InputStreamIOException - if there is an IO error during this operation.public long getPos()
throws IOException
getPos in interface org.apache.hadoop.fs.SeekablegetPos in class org.apache.hadoop.fs.FSInputStreamIOException - if there is an IO error during this operation.public int read()
throws IOException
read in class InputStreamIOException - if there is an IO error during this operation.public int read(byte[] buffer,
int offset,
int len)
throws IOException
len bytes from this stream and copies them into
the given buffer starting at the given offset.
Returns the number of bytes actually copied in to the given buffer.read in class InputStreambuffer - the buffer to copy data into.offset - data is copied starting at this offset.len - max number of bytes to copy.IOException - if there is an IO error during this operation.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class ObjectInputStreamIOException - if there is an IO error during this operation.protected boolean isStreamOpen()
ObjectInputStreamisStreamOpen in class ObjectInputStreamprotected void abortInFinalizer()
ObjectInputStreamLeakReporter.
All exceptions raised are ignored.abortInFinalizer in class ObjectInputStreampublic void seek(long pos)
throws IOException
pos.seek in interface org.apache.hadoop.fs.Seekableseek in class org.apache.hadoop.fs.FSInputStreampos - new read position.IOException - if there is an IO error during this operation.public void setReadahead(Long readahead)
setReadahead in interface org.apache.hadoop.fs.CanSetReadaheadreadahead - the number of bytes to read ahead each time..public boolean hasCapability(String capability)
capability is supported by this stream.hasCapability in interface org.apache.hadoop.fs.StreamCapabilitieshasCapability in class ObjectInputStreamcapability - the capability to check.capability is supported by this stream, false otherwise.@InterfaceAudience.Private @InterfaceStability.Unstable @VisibleForTesting public S3AInputStreamStatistics getS3AStreamStatistics()
getS3AStreamStatistics in class ObjectInputStreampublic org.apache.hadoop.fs.statistics.IOStatistics getIOStatistics()
getIOStatistics in interface org.apache.hadoop.fs.statistics.IOStatisticsSourcegetIOStatistics in class ObjectInputStreamprotected boolean isClosed()
protected void throwIfClosed()
throws IOException
IOExceptionpublic boolean seekToNewSource(long targetPos)
throws IOException
seekToNewSource in interface org.apache.hadoop.fs.SeekableseekToNewSource in class org.apache.hadoop.fs.FSInputStreamIOExceptionpublic boolean markSupported()
markSupported in class InputStreamCopyright © 2008–2025 Apache Software Foundation. All rights reserved.