Build your own vector database
Persistence & segments·6 min

What's in a segment

0 / 1

A vector DB you can't reload is a cache. Qdrant stores a collection as one or more segments, each a self-contained unit with its own vector storage, payload storage, and HNSW index. To persist, you serialize a segment's bytes; to load, you read them back and reconstruct the in-memory graph.

Our segment format

A flat binary segment (little-endian)
header:   magic "MQDR" (4 bytes) | u32 version | u32 N | u32 dim
          u32 topLayer | i32 entryPoint                 (24 bytes total)
vectors:  N * dim float32
levels:   N * i32
adjacency: for each layer (topLayer+1):
            for each node: u32 degree | degree * u32 neighborId
payload:  u32 byteLength | UTF-8 JSON (array of Payload, or empty)