What is Thrift?
Apache Thrift is an interface-definition language and a family of serialisation protocols. A schema gives each field a number and a type; Compact Protocol packs that information into small binary structures.
Every Parquet file carries a compact map of its own data. We walk the Thrift metadata without building object trees, decode column pages incrementally, then reconstruct real values from dictionary IDs, float bytes and boolean bits.
Apache Thrift is an interface-definition language and a family of serialisation protocols. A schema gives each field a number and a type; Compact Protocol packs that information into small binary structures.
Parquet defines metadata in parquet.thrift and stores its Compact-encoded form in file footers and page headers. It uses Thrift as a file format encoding—not for network RPC, and not for the encoded column values.
Parquet stores the serialized FileMetaData near the end of the object. You can locate it with two small range reads instead of downloading the whole dataset.
The opening four bytes identify a standard unencrypted Parquet file. The footer locator checks the final four bytes separately.
bytes=1048568-10485754-byte little-endian footer length + PAR1bytes=1046520-10485672,048 bytes, held by the transportscan_footer(&bytes, visitor)Offsets, compression, row groups and statisticsApache Thrift defines typed fields and a compact binary encoding. Parquet uses its Compact Protocol to store file metadata and page headers. Step through the actual wire rules—not a screenshot of a parser.
The reader advances over a borrowed &[u8] and never constructs a complete generated Thrift object graph.
The high nibble is the delta from the previous field ID; the low nibble identifies the wire type. A delta of zero means an explicit field ID follows.
Negative and positive integers become small unsigned numbers before LEB128-style variable-length encoding. −1 → 1, 1 → 2.
Every nested struct has its own delta context. The reader uses a scoped cursor, not a heap-allocated object tree or a heap-allocated nesting stack.
The input footer already exists as bytes in the transport's buffer. WCOL holds a borrowed slice, advances an offset, and emits a temporary view of each interesting column to a callback.
The same borrowed footer is visited column by column. The codec does not allocate metadata objects. The application can choose whether to retain each result.
scan_footer uses a fixed inline stack array of ColumnChunkInfo. Wider groups take a bounded rewind-and-visit path rather than building a heap collection. The codec still requires the footer to be available as a contiguous borrowed slice.The same Compact Protocol is used for Parquet page headers. The compressed page payloads use separate Parquet encodings and codecs. WCOL deliberately keeps these layers apart.
An R2 or S3 range request supplies a slice of the object. The transport owns the input and the limits on how much is buffered.
Footer bytes must be buffered contiguously for the current metadata parser. Streaming page decoders may need caller-owned scratch, presence bitmaps and decompression history.
Depth is bounded (64 by default); offsets, tags and varints are checked. Global footer-size and collection-count limits belong to the caller.
The parser can recursively skip unknown values or borrow their raw encoded bytes for rewriting. No full schema-generated object model is required.
The Thrift PageHeader only tells us how the next bytes are encoded. The actual values pass through a separate, incremental decoder. These are the paths implemented by this crate.
In V1, an optional column's definition levels and encoded values are compressed together as one page body.
The page header tells the decoder which encoding and compression path follows.
src/pages/frame.rsALLOCATION MODELCaller-owned header scratchA FLOAT value is represented by four IEEE-754 little-endian bytes. The Rust decoder reads borrowed input and emits Value::F32.
src/values/plain.rsNo per-value heap allocation. A partially received fixed-width value needs at most 12 bytes of carry.
| ENCODING | PHYSICAL TYPES / ROLE | DECODER / CONSTRAINT |
|---|---|---|
| PLAIN | BOOLEAN, INT32, INT64, INT96, FLOAT, DOUBLE, BYTE_ARRAY, FIXED_LEN_BYTE_ARRAY | PlainBool / PlainValues / ByteArrays / FixedByteArrays |
| RLE | BOOLEAN; definition levels | RleBool; Levels. Boolean RLE has a 4-byte length prefix in V1 and V2 |
| RLE_DICTIONARY (8), PLAIN_DICTIONARY (2) | Dictionary-encoded data pages | DictionaryIds emits checked IDs; caller resolves strings or other values |
| DELTA_BINARY_PACKED (5) | INT32, INT64 | DeltaBinary with caller-provided mini-block width workspace |
| DELTA_LENGTH_BYTE_ARRAY (6) | BYTE_ARRAY | DeltaLengthByteArrays; caller supplies lengths array |
| DELTA_BYTE_ARRAY (7) | BYTE_ARRAY, FIXED_LEN_BYTE_ARRAY | DeltaByteArrays; caller supplies prefix/suffix and previous-value scratch |
| DICTIONARY_PAGE | PLAIN (0), legacy PLAIN_DICTIONARY (2) | Entries emitted at Location::Dictionary(index), caller retains the dictionary |
| PAGE COMPRESSION | UNCOMPRESSED (0), SNAPPY (1) | Identity or RawSnappy; other codecs require custom Inflate |
compact-parquet-thrift page layer, not every Parquet feature or every decoder elsewhere in the WCOL repository. Nested/repeated data and BYTE_STREAM_SPLIT are not included here.Identity forwards borrowed bytes; RawSnappy uses caller-provided history and output buffers. Other codecs require an external Inflate implementation.
Definition levels 0 or 1, repetition level 0. One-bit-per-row presence workspace for nullable columns. Nested/repeated pages are outside this assembler.
No built-in ZSTD, GZIP or BYTE_STREAM_SPLIT value decoder here. These are limits of this crate, not general Parquet limitations.
Parquet stores columns separately, not row-shaped records. Choose a row below, then advance the decoder to see one dictionary-encoded string, one FLOAT, and one BOOLEAN rejoin at their shared row position.
| ROW | COUNTRY BYTE_ARRAY / DICT | TEMP °C FLOAT / PLAIN | ACTIVE BOOLEAN / PLAIN |
|---|
Each selected value lives in a separate column chunk.
The dictionary page decodes to caller-managed entries. The data page returns DictionaryId(index); the caller chooses when to resolve it.
PlainValues<f32> accepts fragmented input and retains at most a fixed-size partial value.
PlainBool reads the bits least-significant first and emits each row's boolean independently.
Borrow the metadata. Decode page bytes incrementally. Keep scratch memory caller-owned. Reconstruct only the rows and values the query needs—that is the compact I/O foundation for WCOL.