public class S3APrefetchingInputStream
extends org.apache.hadoop.fs.FSInputStream
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(S3AReadOpContext context,
S3ObjectAttributes s3Attributes,
S3AInputStream.InputStreamCallbacks client,
S3AInputStreamStatistics streamStatistics,
org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.LocalDirAllocator localDirAllocator)
Initializes a new instance of the
S3APrefetchingInputStream class. |
| Modifier and Type | Method and Description |
|---|---|
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() |
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() |
read, readFully, readFully, toString, validatePositionedReadArgsmark, read, reset, skippublic S3APrefetchingInputStream(S3AReadOpContext context, S3ObjectAttributes s3Attributes, S3AInputStream.InputStreamCallbacks client, S3AInputStreamStatistics streamStatistics, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.LocalDirAllocator localDirAllocator)
S3APrefetchingInputStream class.context - read-specific operation context.s3Attributes - attributes of the S3 object being read.client - callbacks used for interacting with the underlying S3 client.streamStatistics - statistics for this stream.conf - the configuration.localDirAllocator - the local dir allocator instance retrieved from S3A FS.IllegalArgumentException - if context is null.IllegalArgumentException - if s3Attributes is null.IllegalArgumentException - if client 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 InputStreamIOException - if there is an IO error during this operation.public 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.StreamCapabilitiescapability - the capability to check.capability is supported by this stream, false otherwise.@InterfaceAudience.Private @InterfaceStability.Unstable @VisibleForTesting public S3AInputStreamStatistics getS3AStreamStatistics()
public org.apache.hadoop.fs.statistics.IOStatistics getIOStatistics()
getIOStatistics in interface org.apache.hadoop.fs.statistics.IOStatisticsSourceprotected 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–2024 Apache Software Foundation. All rights reserved.