@InterfaceAudience.Private
@InterfaceStability.Evolving
public class S3AInputStream
extends org.apache.hadoop.fs.FSInputStream
implements org.apache.hadoop.fs.CanSetReadahead, org.apache.hadoop.fs.CanUnbuffer, org.apache.hadoop.fs.StreamCapabilities, org.apache.hadoop.fs.statistics.IOStatisticsSource
toString()
must also be considered unstable.Modifier and Type | Class and Description |
---|---|
static interface |
S3AInputStream.InputStreamCallbacks
Callbacks for input stream IO.
|
Modifier and Type | Field and Description |
---|---|
static String |
E_NEGATIVE_READAHEAD_VALUE |
static String |
OPERATION_OPEN |
static String |
OPERATION_REOPEN |
Constructor and Description |
---|
S3AInputStream(S3AReadOpContext ctx,
S3ObjectAttributes s3Attributes,
S3AInputStream.InputStreamCallbacks client,
S3AInputStreamStatistics streamStatistics,
ExecutorService boundedThreadPool)
Create the stream.
|
Modifier and Type | Method and Description |
---|---|
int |
available() |
void |
close()
Close the stream.
|
long |
getContentRangeFinish() |
long |
getContentRangeStart() |
S3AInputPolicy |
getInputPolicy()
Get the current input policy.
|
org.apache.hadoop.fs.statistics.IOStatistics |
getIOStatistics() |
long |
getPos() |
long |
getReadahead()
Get the current readahead value.
|
S3AInputStreamStatistics |
getS3AStreamStatistics()
Access the input stream statistics.
|
software.amazon.awssdk.core.ResponseInputStream<software.amazon.awssdk.services.s3.model.GetObjectResponse> |
getWrappedStream()
Get the wrapped stream.
|
boolean |
hasCapability(String capability) |
boolean |
isObjectStreamOpen()
Is the inner object stream open?
|
boolean |
markSupported() |
int |
maxReadSizeForVectorReads()
.
|
int |
minSeekForVectorReads()
.
|
int |
read() |
int |
read(byte[] buf,
int off,
int len)
This updates the statistics on read operations started and whether
or not the read operation "completed", that is: returned the exact
number of bytes requested.
|
void |
readFully(long position,
byte[] buffer,
int offset,
int length)
Subclass
readFully() operation which only seeks at the start
of the series of operations; seeking back at the end. |
void |
readVectored(List<? extends org.apache.hadoop.fs.FileRange> ranges,
IntFunction<ByteBuffer> allocate)
Vectored read implementation for S3AInputStream.
|
long |
remainingInCurrentRequest()
Bytes left in the current request.
|
long |
remainingInFile()
Bytes left in stream.
|
boolean |
resetConnection()
Forcibly reset the stream, by aborting the connection.
|
void |
seek(long targetPos) |
boolean |
seekToNewSource(long targetPos) |
void |
setReadahead(Long readahead) |
String |
toString()
String value includes statistics as well as stream state.
|
void |
unbuffer()
Closes the underlying S3 stream, and merges the
streamStatistics
instance associated with the stream. |
static long |
validateReadahead(Long readahead)
from a possibly null Long value, return a valid
readahead.
|
read, readFully, validatePositionedReadArgs
mark, read, reset, skip
public static final String E_NEGATIVE_READAHEAD_VALUE
public static final String OPERATION_OPEN
public static final String OPERATION_REOPEN
public S3AInputStream(S3AReadOpContext ctx, S3ObjectAttributes s3Attributes, S3AInputStream.InputStreamCallbacks client, S3AInputStreamStatistics streamStatistics, ExecutorService boundedThreadPool)
ctx
- operation contexts3Attributes
- object attributesclient
- S3 client to usestreamStatistics
- stream io stats.boundedThreadPool
- thread pool to use.@VisibleForTesting public S3AInputPolicy getInputPolicy()
public long getPos() throws IOException
getPos
in interface org.apache.hadoop.fs.Seekable
getPos
in class org.apache.hadoop.fs.FSInputStream
IOException
public void seek(long targetPos) throws IOException
seek
in interface org.apache.hadoop.fs.Seekable
seek
in class org.apache.hadoop.fs.FSInputStream
IOException
public boolean seekToNewSource(long targetPos) throws IOException
seekToNewSource
in interface org.apache.hadoop.fs.Seekable
seekToNewSource
in class org.apache.hadoop.fs.FSInputStream
IOException
@Retries.RetryTranslated public int read() throws IOException
read
in class InputStream
IOException
@Retries.RetryTranslated public int read(byte[] buf, int off, int len) throws IOException
read
in class InputStream
IOException
- if there are other problemspublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
- on any problem@InterfaceStability.Unstable public boolean resetConnection() throws IOException
read()
operation will trigger the opening of a new HTTPS
connection.
This is potentially very inefficient, and should only be invoked
in extreme circumstances. It logs at info for this reason.
Blocks until the abort is completed.IOException
- if invoked on a closed stream.public int available() throws IOException
available
in class InputStream
IOException
@InterfaceAudience.Private @InterfaceStability.Unstable public long remainingInFile()
@InterfaceAudience.Private @InterfaceStability.Unstable public long remainingInCurrentRequest()
@InterfaceAudience.Private @InterfaceStability.Unstable public long getContentRangeFinish()
@InterfaceAudience.Private @InterfaceStability.Unstable public long getContentRangeStart()
public boolean markSupported()
markSupported
in class InputStream
@InterfaceStability.Unstable public String toString()
toString
in class org.apache.hadoop.fs.FSInputStream
@Retries.RetryTranslated public void readFully(long position, byte[] buffer, int offset, int length) throws IOException
readFully()
operation which only seeks at the start
of the series of operations; seeking back at the end.
This is significantly higher performance if multiple read attempts are
needed to fetch the data, as it does not break the HTTP connection.
To maintain thread safety requirements, this operation is synchronized
for the duration of the sequence.
readFully
in interface org.apache.hadoop.fs.PositionedReadable
readFully
in class org.apache.hadoop.fs.FSInputStream
IOException
public int minSeekForVectorReads()
minSeekForVectorReads
in interface org.apache.hadoop.fs.PositionedReadable
public int maxReadSizeForVectorReads()
maxReadSizeForVectorReads
in interface org.apache.hadoop.fs.PositionedReadable
public void readVectored(List<? extends org.apache.hadoop.fs.FileRange> ranges, IntFunction<ByteBuffer> allocate) throws IOException
readVectored
in interface org.apache.hadoop.fs.PositionedReadable
ranges
- the byte ranges to read.allocate
- the function to allocate ByteBuffer.IOException
- IOE if any.@InterfaceAudience.Private @InterfaceStability.Unstable @VisibleForTesting public S3AInputStreamStatistics getS3AStreamStatistics()
public void setReadahead(Long readahead)
setReadahead
in interface org.apache.hadoop.fs.CanSetReadahead
public long getReadahead()
public static long validateReadahead(@Nullable Long readahead)
readahead
- new readaheadIllegalArgumentException
- if the range is invalid.public void unbuffer()
streamStatistics
instance associated with the stream.
Also sets the stopVectoredIOOperations
flag to true such that
active vectored read operations are terminated. However termination of
old vectored reads are not guaranteed if a new vectored read operation
is initiated after unbuffer is called.unbuffer
in interface org.apache.hadoop.fs.CanUnbuffer
public boolean hasCapability(String capability)
hasCapability
in interface org.apache.hadoop.fs.StreamCapabilities
@VisibleForTesting public boolean isObjectStreamOpen()
public org.apache.hadoop.fs.statistics.IOStatistics getIOStatistics()
getIOStatistics
in interface org.apache.hadoop.fs.statistics.IOStatisticsSource
@VisibleForTesting public software.amazon.awssdk.core.ResponseInputStream<software.amazon.awssdk.services.s3.model.GetObjectResponse> getWrappedStream()
Copyright © 2008–2024 Apache Software Foundation. All rights reserved.