Class 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.
When the owning S3Source is configured with
RangeBacking.SPARSE_TEMPFILE, an internal mmap-backed range cache
serves repeat reads of the same byte ranges without re-issuing HTTP
requests. The cache is invisible at the API surface — the same
counters (networkRequestCount, networkBytesFetched) reflect
only network traffic in either mode.
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.longNumber of bytes fetched from the network sinceopen().longNumber of HTTP requests issued against the object sinceopen().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
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
networkRequestCount
public long networkRequestCount()Number of HTTP requests issued against the object sinceopen(). Counts the suffix-range tail fetch fromopenplus every network-fetchreadRange(long, int)call. Tail-cache hits do not count. -
networkBytesFetched
public long networkBytesFetched()Number of bytes fetched from the network sinceopen(). The tail fetch fromopencontributes its actual response size; each network-fetchreadRange(long, int)contributes the requested length. Tail-cache hits do not count.
-