Vector Index Storage Format

This document describes the v1 on-disk formats written by the Rust core library. Version 1 is the first release format. Pre-release layouts are not part of the compatibility contract.

Compatibility Policy

  • All multi-byte integers and f32 values are little-endian.
  • The unified reader dispatches by the first 4-byte magic value.
  • Magic names below show the u32 constants in human-readable big-endian form. Because the fields are little-endian, the raw file bytes for those constants appear in reverse ASCII order.
  • Readers reject unknown magic values, unknown versions, unknown required flags, non-zero reserved bytes, invalid section sizes, negative counts, and malformed list payload metadata.
  • Incompatible on-disk changes require a new format version. Version 1 readers do not attempt to read future versions.
  • Reserved bytes are written as zero and must be read back as zero. Future extensions must use flags or a new format version rather than repurposing non-zero reserved bytes within v1.
  • Index files have no outer container, footer, checksum, compression envelope, or schema registry. The complete file starts at byte offset 0 with one of the headers below.
  • File integrity, including length and checksum validation, is guaranteed by the outer Paimon file/manifest layer rather than by an embedded index footer.
  • Roaring row-id filters are a query-time API payload. They are not embedded in any index file format.

Common Encodings

Delta-Varint IDs

IVF-PQ, IVF-FLAT, and IVF-RQ v1 sort each non-empty list by signed row id before writing. The first id is stored as base_id: i64. The id stream then stores one unsigned LEB128 varint per id, including the first id's zero delta. Each delta is computed with wrapping unsigned subtraction from the previous signed id. Readers reject a decoded sequence that is not monotonically non-decreasing in signed order.

HNSW Graph Section

IVF-HNSW-FLAT and IVF-HNSW-SQ store one graph section per non-empty list. The section starts with a fixed header, followed by a contiguous sequence of unsigned LEB128 varints. Neighbor ids within each adjacency group are sorted by local vector id and stored as unsigned deltas from the previous neighbor id, with an initial previous id of 0:

FieldCount
graph_magic1 little-endian u32, HWGR (0x48574752)
graph_version1 little-endian u32, currently 1
graph_flags1 little-endian u32; bit 0 delta-varint adjacency is required
graph_count1 varint
entry_point1 varint
max_observed_level1 varint
level[node]graph_count varints
degree[node][level] followed by neighbor id deltasone group for each node level

Each node has levels 0..=level[node]. A level-0 node may have at most 2 * m neighbors, and higher levels may have at most m neighbors.

IVF-PQ v1

Magic: IVPQ (0x49565051). Version: 1. Header size: 64 bytes.

OffsetSizeTypeField
04u32magic
44u32version
84i32dimension d
124i32IVF list count nlist
164i32PQ subquantizer count m
204i32centroid count per subquantizer ksub
244i32subvector dimension dsub
284u32metric (0=L2, 1=InnerProduct, 2=Cosine)
328i64total vector count
404u32flags
4420bytesreserved

Flags:

BitMeaning
0OPQ rotation matrix is present
1PQ codes are trained/stored by residual
2delta-varint ids are used; required in v1
3PQ codes are transposed by subquantizer; required in v1

Sections after the header:

  1. Optional OPQ rotation matrix: d * d f32 values when flag bit 0 is set.
  2. IVF coarse centroids: nlist * d f32 values.
  3. PQ centroids: m * ksub * dsub f32 values.
  4. Offset table: nlist entries of (offset: i64, count: i32, id_bytes_len: i32).
  5. List payloads.

For each non-empty list payload:

FieldTypeNotes
base_idi64first sorted row id
id_bytes_leni32byte length of encoded id stream
id_bytesbytesdelta-varint ids
codesbytestransposed PQ codes

For 8-bit PQ, each vector has m code bytes and the stored code layout is codes[sub][vector]. For 4-bit PQ, each byte stores two subquantizers and the stored layout is codes[pair][vector].

IVF-FLAT v1

Magic: IVFL (0x4956464C). Version: 1. Header size: 64 bytes.

OffsetSizeTypeField
04u32magic
44u32version
84i32dimension d
124i32IVF list count nlist
164u32metric (0=L2, 1=InnerProduct, 2=Cosine)
208i64total vector count
284u32flags
3232bytesreserved

Flags:

BitMeaning
0delta-varint ids are used; required in v1

Sections after the header:

  1. IVF coarse centroids: nlist * d f32 values.
  2. Offset table: nlist entries of (offset: i64, count: i32, id_bytes_len: i32).
  3. List payloads.

For each non-empty list payload:

FieldTypeNotes
base_idi64first sorted row id
id_bytes_leni32byte length of encoded id stream
id_bytesbytesdelta-varint ids
vectorscount * d f32raw stored vectors

IVF-RQ v1

Magic: IVRQ (0x49565251). Version: 1. Header size: 64 bytes.

OffsetSizeTypeField
04u32magic
44u32version
84i32dimension d
124i32IVF list count nlist
164u32metric (0=L2, 1=InnerProduct, 2=Cosine)
204u32flags
248i64total vector count
328u64deterministic rotation seed
404u32deterministic rotation rounds
444i32bytes per primary sign-code plane, ceil(d / 8)
484u32RQ num_bits; currently 1, reserved values 2, 4, and 8
524u32rotation_type; currently 1 for deterministic Kac rotation
564u32factor_layout; currently 1 for three RaBitQ f32 factors
604u32RQ format flags

Flags:

BitMeaning
0delta-varint ids are used; required in v1

RQ format flags:

BitMeaning
0optional ex_codes section is present
1optional error_factor section is present

Sections after the header:

  1. IVF coarse centroids: nlist * d f32 values.
  2. Offset table: nlist entries of (offset: i64, count: i32, id_bytes_len: i32).
  3. List payloads.

For each non-empty list payload:

FieldTypeNotes
base_idi64first sorted row id
id_bytes_leni32byte length of encoded id stream
id_bytesbytesdelta-varint ids
codescount * ceil(d / 8) bytesprimary RaBitQ sign-code plane over rotated residuals
ex_codesoptional bytesreserved for additional code planes when num_bits > 1; present when RQ format flag bit 0 is set
factorscount * 3 f32per-vector (residual_norm_sqr, vector_norm_sqr, dp_multiplier) correction factors
error_factoroptional count f32reserved per-vector refinement factor; present when RQ format flag bit 1 is set

The deterministic rotation is derived from (d, rotation_seed, rotation_rounds) and applied to both indexed residuals and query residuals. The rotation parameters are stored in the header so independently written files can use the same distance estimator after being read by any v1 reader.

Current writers emit num_bits=1, rotation_type=1, factor_layout=1, and no optional RQ sections. Current readers validate these format fields and reject reserved multi-bit or optional-section encodings until the corresponding scanner is implemented.

query_bits is a search-time IVF-RQ parameter and is not serialized. 0 uses the default float-query byte-LUT estimator; 4 and 8 quantize the rotated query residual into sign and magnitude bit planes for bitwise/popcount scanning.

IVF-HNSW-FLAT v1

Magic: IHFL (0x4948464C). Version: 1. Header size: 64 bytes.

OffsetSizeTypeField
04u32magic
44u32version
84i32dimension d
124i32IVF list count nlist
164u32metric (0=L2, 1=InnerProduct, 2=Cosine)
208i64total vector count
284i32HNSW m
324i32HNSW ef_construction
364i32HNSW max_level
404u32flags
4420bytesreserved

Flags:

BitMeaning
0sorted delta-varint ids are stored; required in v1
1HNSW graph section uses the v1 delta-varint graph encoding; required in v1

Sections after the header:

  1. IVF coarse centroids: nlist * d f32 values.
  2. Offset table: nlist entries of (offset: i64, count: i32, graph_bytes_len: i32, payload_bytes_len: i64).
  3. List payloads.

For each non-empty list payload:

FieldTypeNotes
base_idi64first sorted row id
id_bytes_leni32byte length of encoded id stream
id_bytesbytesdelta-varint ids
vectorscount * d f32raw stored vectors
graphbytesHNSW graph section

IVF-HNSW-SQ v1

Magic: IHSQ (0x49485351). Version: 1. Header size: 64 bytes.

OffsetSizeTypeField
04u32magic
44u32version
84i32dimension d
124i32IVF list count nlist
164u32metric (0=L2, 1=InnerProduct, 2=Cosine)
208i64total vector count
284i32HNSW m
324i32HNSW ef_construction
364i32HNSW max_level
404f32global minimum SQ bound summary
444f32global maximum SQ bound summary
484u32flags
5212bytesreserved

Flags:

BitMeaning
0sorted delta-varint ids are stored; required in v1
1HNSW graph section uses the v1 delta-varint graph encoding; required in v1

Sections after the header:

  1. Global SQ min bounds: d f32 values.
  2. Global SQ max bounds: d f32 values.
  3. Per-list SQ bounds: for each list, d min f32 values followed by d max f32 values.
  4. IVF coarse centroids: nlist * d f32 values.
  5. Offset table: nlist entries of (offset: i64, count: i32, graph_bytes_len: i32, payload_bytes_len: i64).
  6. List payloads.

For each non-empty list payload:

FieldTypeNotes
base_idi64first sorted row id
id_bytes_leni32byte length of encoded id stream
id_bytesbytesdelta-varint ids
codesbytesscalar quantized residual codes, count * d bytes
graphbytesHNSW graph section over decoded vectors