Expand description
Read and write Vortex layouts, a serialization of Vortex arrays.
A Vortex file stores a root Layout, the byte segments referenced by
that layout, an optional file-level DType and statistics, and
enough footer metadata to deserialize the tree. Layouts are recursive, so a file may organize
data by row groups, columns, dictionaries, statistics, or other writer-chosen structures without
changing the logical dtype seen by readers. The built-in layouts are:
FlatLayout: a single contiguously serialized array of buffers with a specific in-memoryAlignment.StructLayout: each column laid out at known offsets, permitting a subset of columns to be read in linear time with constant-time random access to any column.ChunkedLayout: each chunk laid out at known offsets; locating the chunks covering a row range is anN log(N)search of the offsets.DictLayout: a shared dictionary of values with a child layout holding indices.ZonedLayout: a zone-map of statistics used for filter pruning.
A layout alone is not a standalone Vortex file: it is not self-describing, so the file pairs it with the dtype and footer metadata needed to deserialize it. This crate owns the file reader/writer APIs; the byte-level format is described under File Format below and specified in full in the docs: https://docs.vortex.dev/specs/file-format.html.
§Reading
Use OpenOptionsSessionExt::open_options to create VortexOpenOptions from a session.
Opening reads or accepts a footer, builds a segment source, and returns VortexFile. Scans are
configured from VortexFile::scan with projection/filter expressions, row ranges,
Selection, split strategy, and concurrency settings from
vortex-layout.
Supplying known metadata can reduce open-time IO:
VortexOpenOptions::with_file_sizeavoids a size request.VortexOpenOptions::with_dtypeis required for files written without an embedded dtype.VortexOpenOptions::with_footercan open a file without reading footer bytes.VortexOpenOptions::with_segment_cachereuses segment buffers across scans.
§Writing
Use WriteOptionsSessionExt::write_options or VortexWriteOptions::new to write an
ArrayStream. The default WriteStrategyBuilder
repartitions rows, builds statistics layouts, dictionary-encodes suitable columns, compresses
chunks with the BtrBlocks-style compressor, and writes flat leaf layouts. Advanced users can
replace the whole strategy or override individual fields.
§File Format
A Vortex file begins and ends with the 4-byte magic VTXF. Data segments are written first, in
writer-chosen order, followed by the footer flatbuffers, a postscript, and an 8-byte
end-of-file marker:
┌────────────────────────────┐
│ Magic bytes 'VTXF' │ 4 bytes
├────────────────────────────┤
│ Segments │ serialized array chunks and per-column
│ (data & statistics) │ statistics, in writer-chosen order
├────────────────────────────┤
│ DType flatbuffer │ optional; omitted via `exclude_dtype`
├────────────────────────────┤
│ Layout flatbuffer │ required; the root Layout tree
├────────────────────────────┤
│ Statistics flatbuffer │ optional; file-level per-field statistics
├────────────────────────────┤
│ Footer flatbuffer │ required; dictionary-encoded segment map
│ │ and array/layout/compression/encryption specs
├────────────────────────────┤
│ Postscript │ offsets of the four footer segments above;
│ │ at most 65528 bytes
├────────────────────────────┤
│ 8-byte End of File │ u16 version, u16 postscript length,
│ │ 4 magic bytes 'VTXF'
└────────────────────────────┘The postscript records the offset, length, and alignment of the dtype, layout, statistics, and footer segments, so a single read of the file tail (defaulting to 64KiB) is enough to locate and parse the footer. The byte-level format is specified in full at https://docs.vortex.dev/specs/file-format.html.
A Parquet-style file is realized by nesting a chunked layout of struct layouts of chunked layouts of flat layouts: the outer chunked layout models row groups and the inner one models pages. Layouts are adaptive, so the writer is free to build arbitrarily complex layouts to trade off locality and parallelism, or to elide statistics entirely when an external index supplies them.
§Footer Deserialization
FooterDeserializer supports incremental footer reads. It returns DeserializeStep values
when it needs more bytes or a file size, and returns Footer once all required footer segments
are available. VortexOpenOptions drives this state machine for ordinary file opens.
Modules§
- multi
- Builder for constructing a
MultiLayoutDataSourcefrom multiple Vortex files. - segments
- Segment sources, caches, and sinks used by file readers and writers.
- v2
- Compatibility readers for newer file-statistics layout behavior.
Structs§
- Blocking
Write - Blocking adapter for
VortexWriteOptions. - Blocking
Writer - A blocking adapter around a
Writer, allowing incremental writing of arrays to a Vortex file. - File
Statistics - Contains statistical information about the data in a Vortex file.
- Footer
- Captures the layout information of a Vortex file.
- Footer
Deserializer - Deserialize a footer from the end of a Vortex file or created from a
crate::footer::FooterSerializer. - Footer
Serializer - Serializes a
Footerinto footer buffers and the trailing postscript/EOF marker. - Segment
Spec - The location of a segment within a Vortex file.
- Vortex
File - Represents a Vortex file, providing access to its metadata and content.
- Vortex
Open Options - Open options for a Vortex file reader.
- Vortex
Write Options - Configure a new writer, which can eventually be used to write an
ArrayStreaminto a sink that implementsVortexWrite. - Write
Strategy Builder - Build a new writer strategy to compress and reorganize chunks of a Vortex file.
- Write
Summary - Summary returned after a Vortex file is written.
- Writer
- An async API for writing Vortex files.
Enums§
- Deserialize
Step - Result of one
FooterDeserializer::deserializestep.
Constants§
- EOF_
SIZE - The size of the EOF marker in bytes
- MAGIC_
BYTES - The magic bytes for a Vortex file
- MAX_
POSTSCRIPT_ SIZE - The maximum length of a Vortex postscript in bytes
- V1_
FOOTER_ FBS_ SIZE - The size of the footer in bytes in Vortex version 1
- VERSION
- The current version of the Vortex file format
- VORTEX_
FILE_ EXTENSION - The extension for Vortex files
Statics§
- ALLOWED_
ENCODINGS - Static registry of all allowed array encodings for file writing.
Traits§
- Open
Options Session Ext - Extension trait for constructing
VortexOpenOptionsfrom a session. - Write
Options Session Ext - Extension trait for constructing
VortexWriteOptionsfrom a session.
Functions§
- register_
default_ encodings - Register the default encodings use in Vortex files with the provided session.