public abstract class S3ARemoteInputStream extends InputStream implements org.apache.hadoop.fs.CanSetReadahead, org.apache.hadoop.fs.StreamCapabilities, org.apache.hadoop.fs.statistics.IOStatisticsSource
InputStream that allows reading from an S3 file.| Constructor and Description |
|---|
S3ARemoteInputStream(S3AReadOpContext context,
S3ObjectAttributes s3Attributes,
S3AInputStream.InputStreamCallbacks client,
S3AInputStreamStatistics streamStatistics)
Initializes a new instance of the
S3ARemoteInputStream class. |
| Modifier and Type | Method and Description |
|---|---|
int |
available()
Returns the number of bytes that can read from this stream without blocking.
|
void |
close()
Closes this stream and releases all acquired resources.
|
protected abstract boolean |
ensureCurrentBuffer()
Ensures that a non-empty valid buffer is available for immediate reading.
|
protected org.apache.hadoop.fs.impl.prefetch.BlockData |
getBlockData() |
protected S3AReadOpContext |
getContext() |
protected S3ARemoteObject |
getFile() |
protected org.apache.hadoop.fs.impl.prefetch.FilePosition |
getFilePosition() |
org.apache.hadoop.fs.statistics.IOStatistics |
getIOStatistics()
Gets the internal IO statistics.
|
protected String |
getName() |
protected long |
getNextReadPos() |
protected String |
getOffsetStr(long offset) |
long |
getPos()
Gets the current position.
|
protected S3ARemoteObjectReader |
getReader() |
S3AInputStreamStatistics |
getS3AStreamStatistics()
Access the input stream statistics.
|
protected S3ARemoteObject |
getS3File() |
protected S3ObjectAttributes |
getS3ObjectAttributes() |
boolean |
hasCapability(String capability)
Indicates whether the given
capability is supported by this stream. |
protected boolean |
isClosed() |
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] buffer)
Reads bytes from this stream and copies them into
the given
buffer starting at the beginning (offset 0). |
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 |
reset() |
void |
seek(long pos)
Moves the current read position so that the next read will occur at
pos. |
void |
setReadahead(Long readahead)
Sets the number of bytes to read ahead each time.
|
long |
skip(long n) |
protected void |
throwIfClosed() |
protected void |
throwIfInvalidSeek(long pos) |
String |
toString() |
public S3ARemoteInputStream(S3AReadOpContext context, S3ObjectAttributes s3Attributes, S3AInputStream.InputStreamCallbacks client, S3AInputStreamStatistics streamStatistics)
S3ARemoteInputStream 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.IllegalArgumentException - if context is null.IllegalArgumentException - if s3Attributes is null.IllegalArgumentException - if client is null.public org.apache.hadoop.fs.statistics.IOStatistics getIOStatistics()
getIOStatistics in interface org.apache.hadoop.fs.statistics.IOStatisticsSource@InterfaceAudience.Private @InterfaceStability.Unstable public S3AInputStreamStatistics getS3AStreamStatistics()
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.public int available()
throws IOException
available in class InputStreamIOExceptionpublic long getPos()
throws IOException
IOException - if there is an IO error during this operation.public void seek(long pos)
throws IOException
pos.pos - the absolute position to seek to.IOException - if there an error during this operation.IllegalArgumentException - if pos is outside of the range [0, file size].protected abstract boolean ensureCurrentBuffer()
throws IOException
IOException - if there is an IO error during this operation.public int read()
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] buffer)
throws IOException
buffer starting at the beginning (offset 0).
Returns the number of bytes actually copied in to the given buffer.read in class InputStreambuffer - the buffer to copy data into.IOException - 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.protected S3ARemoteObject getFile()
protected S3ARemoteObjectReader getReader()
protected S3ObjectAttributes getS3ObjectAttributes()
protected org.apache.hadoop.fs.impl.prefetch.FilePosition getFilePosition()
protected String getName()
protected boolean isClosed()
protected long getNextReadPos()
protected org.apache.hadoop.fs.impl.prefetch.BlockData getBlockData()
protected S3AReadOpContext getContext()
protected S3ARemoteObject getS3File()
protected String getOffsetStr(long offset)
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 boolean markSupported()
markSupported in class InputStreamprotected void throwIfClosed()
throws IOException
IOExceptionprotected void throwIfInvalidSeek(long pos)
throws EOFException
EOFExceptionpublic void mark(int readlimit)
mark in class InputStreampublic void reset()
reset in class InputStreampublic long skip(long n)
skip in class InputStreamCopyright © 2008–2024 Apache Software Foundation. All rights reserved.