Interface File
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
JNIFile
A File
represents a Vortex format file that has been opened for reading.
It provides methods to inspect the file's schema, count rows, and create iterators
for scanning the data with various filtering and projection options. This interface
extends AutoCloseable
to ensure proper resource cleanup when the file
is no longer needed.
Example usage:
try (File file = VortexReader.open(path)) {
DType schema = file.getDType();
long totalRows = file.rowCount();
ScanOptions options = ScanOptions.builder()
.columns(List.of("name", "age"))
.build();
try (ArrayIterator iterator = file.newScan(options)) {
while (iterator.hasNext()) {
Array batch = iterator.next();
// Process batch
}
}
}
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes this file and releases any associated resources.getDType()
Returns the data type (schema) of this Vortex file.newScan
(ScanOptions options) Creates a new iterator for scanning this file with the specified options.long
rowCount()
Returns the total number of rows in this Vortex file.
-
Method Details
-
getDType
DType getDType()Returns the data type (schema) of this Vortex file.The returned
DType
describes the logical structure and types of the data contained in this file. For structured data, this will typically be aDType.Variant.STRUCT
containing field names and their corresponding data types. The schema remains constant for the lifetime of the file.- Returns:
- the
DType
representing the schema of this file
-
rowCount
long rowCount()Returns the total number of rows in this Vortex file.This method provides the count of logical rows contained in the file, which represents the number of records or tuples that can be read. This count is independent of any filtering or projection that may be applied during scanning operations.
- Returns:
- the total number of rows as a non-negative long value
-
newScan
Creates a new iterator for scanning this file with the specified options.This method returns an
ArrayIterator
that can be used to traverse the data in this file according to the providedScanOptions
. The scan options allow for column projection, row filtering via predicates, and row range or index selection. Each call to this method creates a new independent iterator.The returned iterator must be properly closed when no longer needed to release any underlying resources. It is recommended to use the iterator within a try-with-resources statement.
- Parameters:
options
- theScanOptions
configuring the scan behavior, including column selection, filtering, and row selection- Returns:
- a new
ArrayIterator
for scanning the file data - Throws:
RuntimeException
- if the scan options contain invalid column names or conflicting row selection criteria- See Also:
-
close
void close()Closes this file and releases any associated resources.This method should be called when the file is no longer needed to ensure proper cleanup of any underlying file handles, native memory, or other resources. After calling this method, the file should not be used for any further operations. This method is idempotent and can be called multiple times safely.
It is recommended to use this file within a try-with-resources statement to ensure automatic cleanup:
try (File file = VortexReader.open(path)) { // Use file } // close() is called automatically
- Specified by:
close
in interfaceAutoCloseable
-