Interface InputFile
- All Superinterfaces:
AutoCloseable, Closeable
- All Known Implementing Classes:
S3InputFile
Abstraction for reading Parquet file data.
This interface decouples the read pipeline from memory-mapped local files, enabling alternative backends such as object stores or in-memory buffers.
An InputFile starts in an unopened state. The open() method
must be called before readRange(long, int) or length() can be used.
The framework (Hardwood, ParquetFileReader)
calls open() automatically; callers only need to create instances via
of(Path) and close them when done.
Implementations must be safe for concurrent use from multiple threads once opened.
The returned ByteBuffer instances are owned by the caller and may
be slices of a larger mapping or freshly allocated buffers, depending on
the implementation.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionlonglength()Returns the total size of the file in bytes.name()Returns an identifier for this file, used in log messages and JFR events.static InputFileof(ByteBuffer buffer) Creates anInputFilebacked by an in-memoryByteBuffer.static InputFileCreates an unopenedInputFilefor a local file path.ofBuffers(ByteBuffer first, ByteBuffer... more) CreatesInputFileinstances for the given in-memoryByteBuffers.ofBuffers(List<ByteBuffer> buffers) CreatesInputFileinstances for a list of in-memoryByteBuffers.Creates unopenedInputFileinstances for the given local file paths.Creates unopenedInputFileinstances for a list of local file paths.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
Performs expensive resource acquisition (e.g. memory-mapping, network connect). Must be called beforereadRange(long, int)orlength().- Throws:
IOException- if the resource cannot be acquired
-
readRange
Read a range of bytes from the file.- 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 failsIllegalStateException- ifopen()has not been calledIndexOutOfBoundsException- if offset or length is out of range
-
length
Returns the total size of the file in bytes.- Returns:
- the file size
- Throws:
IOException- if the size cannot be determinedIllegalStateException- ifopen()has not been called
-
name
String name()Returns an identifier for this file, used in log messages and JFR events.- Returns:
- a human-readable name or path
-
of
Creates an
InputFilebacked by an in-memoryByteBuffer.Since the data is already in memory, no resource acquisition is needed and
open()is a no-op.- Parameters:
buffer- the buffer containing Parquet file data- Returns:
- a new InputFile backed by the buffer
-
of
-
ofPaths
-
ofPaths
-
ofBuffers
Creates
InputFileinstances for a list of in-memoryByteBuffers.Since the data is already in memory, no resource acquisition is needed and
open()is a no-op for each instance.- Parameters:
buffers- the buffers containing Parquet file data- Returns:
- a list of new InputFile instances backed by the buffers
-
ofBuffers
Creates
InputFileinstances for the given in-memoryByteBuffers.Since the data is already in memory, no resource acquisition is needed and
open()is a no-op for each instance.- Parameters:
first- the first buffer containing Parquet file datamore- additional buffers containing Parquet file data- Returns:
- a list of new InputFile instances backed by the buffers
-