Class S3InputFile
java.lang.Object
dev.hardwood.s3.S3InputFile
- All Implemented Interfaces:
InputFile, Closeable, AutoCloseable
InputFile backed by an object in Amazon S3 (or an S3-compatible service).
Each readRange(long, int) call issues a signed HTTP GET request with a
byte-range header, so only the requested bytes are transferred.
open() uses a suffix-range GET instead of a HEAD request. This
discovers the file length from the Content-Range response header
and pre-fetches the Parquet footer (which sits at the end of the file) in
the same round-trip — eliminating a separate HEAD request per file.
Thread-safe once open() has been called.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()longlength()Returns the total size of the file in bytes.name()Returns an identifier for this file, used in log messages and JFR events.voidopen()Performs expensive resource acquisition (e.g. memory-mapping, network connect).readRange(long offset, int length) Read a range of bytes from the file.
-
Method Details
-
open
Description copied from interface:InputFilePerforms expensive resource acquisition (e.g. memory-mapping, network connect). Must be called beforeInputFile.readRange(long, int)orInputFile.length().- Specified by:
openin interfaceInputFile- Throws:
IOException- if the resource cannot be acquired
-
readRange
Description copied from interface:InputFileRead a range of bytes from the file.- Specified by:
readRangein interfaceInputFile- Parameters:
offset- the byte offset to start reading fromlength- the number of bytes to read- Returns:
- a
ByteBuffercontaining the requested data - Throws:
IOException- if the read fails
-
length
-
name
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-