@NotThreadSafe public class S3AInputStream extends InputStream implements Seekable
SeekableBufferedInputStream
to improve performance.Modifier and Type | Field and Description |
---|---|
protected String |
mBucketName
Name of the bucket the object resides in.
|
protected com.amazonaws.services.s3.AmazonS3 |
mClient
Client for operations with s3.
|
protected String |
mKey
The path of the object to read.
|
protected long |
mPos
The current position of the stream.
|
protected com.amazonaws.services.s3.model.GetObjectRequest |
mReadRequest |
protected RetryPolicy |
mRetryPolicy
Policy determining the retry behavior in case the key does not exist.
|
protected byte[] |
mSingleByteHolder |
Constructor and Description |
---|
S3AInputStream(String bucketName,
String key,
com.amazonaws.services.s3.AmazonS3 client,
long position,
RetryPolicy retryPolicy)
Constructor for an input stream of an object in s3 using the aws-sdk implementation to read the
data.
|
Modifier and Type | Method and Description |
---|---|
protected com.amazonaws.services.s3.AmazonS3 |
getClient() |
long |
getPos() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int offset,
int length) |
void |
seek(long pos)
Moves the starting read position of the stream to the specified position which is relative to
the start of the stream.
|
long |
skip(long n) |
available, close, mark, markSupported, reset
protected com.amazonaws.services.s3.AmazonS3 mClient
protected final String mBucketName
protected final String mKey
protected final byte[] mSingleByteHolder
protected final com.amazonaws.services.s3.model.GetObjectRequest mReadRequest
protected long mPos
protected final RetryPolicy mRetryPolicy
public S3AInputStream(String bucketName, String key, com.amazonaws.services.s3.AmazonS3 client, long position, RetryPolicy retryPolicy)
bucketName
- the bucket the object resides inkey
- the path of the object to readclient
- the s3 client to use for operationsposition
- the position to begin reading fromretryPolicy
- retry policy in case the key does not existpublic int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] b) throws IOException
read
in class InputStream
IOException
public int read(byte[] b, int offset, int length) throws IOException
read
in class InputStream
IOException
public long skip(long n)
skip
in class InputStream
public long getPos()
getPos
in interface Positioned
public void seek(long pos)
Seekable
protected com.amazonaws.services.s3.AmazonS3 getClient()
Copyright © 2023. All Rights Reserved.