# Parquet: encodings and compression

> Learn what Apache Parquet is, why columnar storage splits encoding from compression, how each encoding and codec works, and why those choices change file size and read speed.

Page: https://structure.fi/guides/parquet-encodings-and-compression/

Apache Parquet is an open binary file format for tabular data—rows and columns, like a trade blotter or historical quote log—that stores values **column by column** rather than row by row ([how a Parquet file is laid out](https://structure.fi/guides/parquet-file-layout/)). Researchers, data engineers, and trading firms use it to archive market-data history and run fast analytical queries over millions of rows.

Storing one column contiguously puts values of the same type—and usually similar values—right next to each other. In a trades table, the `symbol` column repeats `"BTCUSDT"` thousands of times, `price` values hover near one another, and `ts_recv` timestamps rise monotonically. That structure lets Parquet shrink a [column chunk](https://structure.fi/guides/parquet-file-layout/#column-chunks) in two separate passes:

1. **Encoding** uses knowledge of the column's type and data patterns to represent its values compactly—for example, replacing repeated ticker strings with tiny integer dictionary codes, or storing only the small differences between consecutive timestamps.
2. **Compression** then runs a general-purpose byte compressor (such as ZSTD or Snappy) over each encoded [page](https://structure.fi/guides/parquet-file-layout/#pages) body, leaving page headers uncompressed so readers can skip pages without decompressing them.

This page explains each encoding and compression codec Parquet supports, how to inspect them in the Market Data Visualizer, and why two Parquet files holding the same rows can differ in size and read speed. The [footer](https://structure.fi/guides/parquet-file-layout/#the-footer) records the encodings and codec used for every column chunk; see [how a binary message is put together](https://structure.fi/guides/binary-message/#parquet) and [prices and money in binary](https://structure.fi/guides/prices-and-times-as-integers/#decimals-in-parquet) for how Parquet handles byte order, nulls, and decimals.

## Seeing encodings and codecs in the trades sample

Open the trades sample's **File layout** view and expand row groups `rg0`–`rg4` into column chunks `c0`–`c9`. Every chunk uses `ZSTD`. Every column except boolean `is_buy` uses a dictionary—for example, `rg0/c2` (`symbol`) starts with a `dict` page and lists `PLAIN, RLE, RLE_DICTIONARY` (`PLAIN` for the dictionary page, `RLE` for levels, `RLE_DICTIONARY` for data-page indices), while `rg0/c9` (`is_buy`) lists only `PLAIN, RLE`.

[Open the trades sample's column chunks and pages](https://structure.fi/tools/market-data-visualizer/app/#open?sample=trades&place=bytes&guide=parquet-encodings-and-compression&section=block-6)

[Open the symbol column's details](https://structure.fi/tools/market-data-visualizer/app/#open?sample=trades&node=symbol&place=detail&guide=parquet-encodings-and-compression&section=block-7)

On very small chunks, compression overhead can outweigh savings: `rg0/c2` is 478 bytes uncompressed and 536 bytes compressed.

## Plain

`PLAIN` writes values back to back with no transformation: fixed-width types in [little-endian](https://structure.fi/guides/binary-message/#parquet) order (8 bytes for `INT64`), `BYTE_ARRAY` as a 4-byte length plus bytes, and `BOOLEAN` packed 1 bit per value. Every reader supports `PLAIN`, and writers fall back to it for high-cardinality or random columns.

## Dictionary

Dictionary encoding stores each distinct value once in a `PLAIN` dictionary page at the start of the chunk, then stores compact integer indices in the data pages—ideal for repeating values like ticker symbols.

- `RLE_DICTIONARY` is the current name; `PLAIN_DICTIONARY` is deprecated but still appears in older files. Both encode indices with the RLE/bit-packing hybrid below.
- If a dictionary grows past its size or cardinality cap, the writer switches the remaining pages of that chunk to `PLAIN`. The app flags dictionary fallback in its [Parquet checks](https://structure.fi/tools/market-data-visualizer/guides/problem-codes.md#parquet-files).

## RLE and bit-packing

`RLE` is a hybrid of run-length encoding and bit-packing for small unsigned integers, using only as many bits per value as the maximum requires. It alternates between:

- **Repeated runs**: one value and its repeat count.
- **Bit-packed runs**: a block of distinct values packed tightly at a shared bit width.

Parquet uses this hybrid for dictionary indices, optional booleans, and repetition/definition levels on [data pages](https://structure.fi/guides/parquet-file-layout/#pages). In an optional column such as `price` (`max_definition_level` = 1), definition levels record which rows are non-null so nulls take no space in the value stream; with no nulls, the levels collapse into one repeated run ([null values in Parquet](https://structure.fi/guides/binary-message/#parquet)). The older `BIT_PACKED` encoding is deprecated.

## Delta encodings

Delta encodings store differences between consecutive values, suiting sorted or slowly changing columns like timestamps and sequence numbers:

- `DELTA_BINARY_PACKED` (`INT32`, `INT64`): first value, then block-level bit-packed deltas relative to each block's minimum delta.
- `DELTA_LENGTH_BYTE_ARRAY` (`BYTE_ARRAY`): delta-encoded string lengths followed by concatenated string bytes.
- `DELTA_BYTE_ARRAY` (`BYTE_ARRAY`, `FIXED_LEN_BYTE_ARRAY`): shared-prefix length with the previous value plus the differing suffix—strong on sorted keys and URLs.

## Byte stream split

`BYTE_STREAM_SPLIT` transposes fixed-width values (`FLOAT`, `DOUBLE`, `INT32`, `INT64`, `FIXED_LEN_BYTE_ARRAY`) so all first bytes sit together, then all second bytes, and so on. It does not shrink data alone, but grouping similar bytes lets the subsequent compression codec achieve better ratios.

## ALP

`ALP` (Adaptive Lossless Floating-Point) encodes `FLOAT` and `DOUBLE` values that are actually decimals as scaled integers while keeping exact bits for exceptions. Verify reader support before writing ALP; for prices that must be exact, prefer a decimal column ([prices and times as integers](https://structure.fi/guides/prices-and-times-as-integers/)).

## Compression codecs

Each column chunk chooses one codec (most writers use one codec file-wide), applied to page bodies only:

- `UNCOMPRESSED`: raw encoded bytes.
- `SNAPPY`: Google's Snappy format.
- `GZIP`: RFC 1952 GZIP (not raw zlib/deflate).
- `ZSTD`: Zstandard (RFC 8878).
- `LZ4_RAW`: LZ4 block format.
- `BROTLI`: RFC 7932 Brotli.
- `LZO`: LZO library format.
- `LZ4`: deprecated (undocumented framing, incompatible across implementations; use `LZ4_RAW`).

For every codec except `LZO` and `LZ4`, the Parquet specification designates a reference library to settle ambiguities.

## How the app shows them

Select any column chunk in the **File layout** view to read its codec, encodings, compressed vs uncompressed sizes, dictionary page offset, and individual pages in the Detail pane. Check the column's [physical and logical types](https://structure.fi/guides/parquet-file-layout/#physical-and-logical-types) in the schema: `PLAIN` and dictionary apply to any type, while delta, byte stream split, and ALP apply only to the types listed above.

## What to check when sizing files

- Compare `total_uncompressed_size` and `total_compressed_size` per chunk in Detail—if compressed is larger, row groups may be too small.
- Look for `dictionary encoding fell back to plain` in Diagnostics on high-cardinality columns such as order ids or timestamps, where delta encoding or disabling dictionary helps.
- Avoid deprecated `PLAIN_DICTIONARY`, `BIT_PACKED`, and `LZ4` when configuring writers.

See [how a Parquet file is laid out](https://structure.fi/guides/parquet-file-layout/) for where chunks, pages, and the footer sit in the file.

## Sources

- https://parquet.apache.org/docs/file-format/data-pages/encodings/
- https://parquet.apache.org/docs/file-format/data-pages/compression/
- https://github.com/apache/parquet-format/blob/master/Encodings.md
- https://github.com/apache/parquet-format/blob/master/Compression.md

Reviewed by Structure on 2026-11-24. Last changed 2026-11-26.
