Class S3Source
- All Implemented Interfaces:
Closeable, AutoCloseable
A configured connection to an S3-compatible object store, the source of the files read from it and written to it.
Holds the region, endpoint, credentials (or anonymous access), and HTTP client needed
to create S3InputFile instances for reading and S3OutputFile instances for writing.
Reuse a single S3Source across multiple files, in either direction, for connection
pooling and credential reuse.
URL styles:
- Virtual-hosted (default):
https://{bucket}.s3.{region}.amazonaws.com/{key} - Path-style (opt-in via
S3Source.Builder.pathStyle):{endpoint}/{bucket}/{key}
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic S3Source.Builderbuilder()Creates a newS3Source.Builder.voidclose()Creates anS3InputFilefrom ans3://bucket/keyURI.Creates anS3InputFilefor the given bucket and key.inputFiles(String... uris) CreatesS3InputFileinstances froms3://URIs (may span buckets).inputFilesInBucket(String bucket, String... keys) CreatesS3InputFileinstances for multiple keys in the same bucket.outputFile(String uri) Creates anS3OutputFilefrom ans3://bucket/keyURI.outputFile(String bucket, String key) Creates anS3OutputFilethat writes the object at the given bucket and key, forParquetFileWriter.
-
Method Details
-
inputFile
Creates anS3InputFilefor the given bucket and key. When the source is configured withRangeBacking.SPARSE_TEMPFILE, the returned file transparently caches fetched byte ranges in a mmap-backed sparse temp file; the cache is an internal implementation detail and does not change the returned type. -
inputFile
Creates anS3InputFilefrom ans3://bucket/keyURI. SeeinputFile(String, String)for theRangeBackingpolicy. -
outputFile
Creates an
S3OutputFilethat writes the object at the given bucket and key, forParquetFileWriter.The output collects the file in parts of
S3Source.Builder.uploadPartSize(int)bytes. An object smaller than one part is sent in a singlePUTon close; a larger one is sent as a multipart upload, with up to four parts uploading in the background while the writer fills the next, and completed on close. An output holds up to five parts in memory. Nothing is visible at the key before close, and a successful close replaces any object already there. Discarding the output aborts the multipart upload. The bucket must exist.When close fails after its final request reached S3 but its response was lost, the object may have been published although close throws.
- Throws:
IllegalStateException- if the source sends requests unsigned (S3Source.Builder.anonymous())
-
outputFile
-
inputFilesInBucket
CreatesS3InputFileinstances for multiple keys in the same bucket. -
inputFiles
CreatesS3InputFileinstances froms3://URIs (may span buckets). -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
builder
Creates a newS3Source.Builder.
-