2020-03-19 09:33:44 -07:00
# Head Chunks on Disk Format
2020-06-17 08:08:21 -07:00
The following describes the format of a chunks file, which is created in the
`chunks_head/` directory inside the data directory.
2020-03-19 09:33:44 -07:00
Chunks in the files are referenced from the index by uint64 composed of
in-file offset (lower 4 bytes) and segment sequence number (upper 4 bytes).
```
┌──────────────────────────────┐
2020-10-01 02:35:01 -07:00
│ magic(0x0130BC91) < 4 byte > │
2020-03-19 09:33:44 -07:00
├──────────────────────────────┤
│ version(1) < 1 byte > │
├──────────────────────────────┤
│ padding(0) < 3 byte > │
├──────────────────────────────┤
│ ┌──────────────────────────┐ │
│ │ Chunk 1 │ │
│ ├──────────────────────────┤ │
│ │ ... │ │
│ ├──────────────────────────┤ │
│ │ Chunk N │ │
│ └──────────────────────────┘ │
└──────────────────────────────┘
```
# Chunk
2024-05-08 08:57:09 -07:00
Unlike chunks in the on-disk blocks, here we additionally store the series
reference that each chunk belongs to and the mint/maxt of the chunks. This is
because we don't have an index associated with these chunks, hence this metadata
is used while replaying the chunks.
2020-03-19 09:33:44 -07:00
```
┌─────────────────────┬───────────────────────┬───────────────────────┬───────────────────┬───────────────┬──────────────┬────────────────┐
| series ref < 8 byte > | mint < 8 byte , uint64 > | maxt < 8 byte , uint64 > | encoding < 1 byte > | len < uvarint > | data < bytes > │ CRC32 < 4 byte > │
└─────────────────────┴───────────────────────┴───────────────────────┴───────────────────┴───────────────┴──────────────┴────────────────┘
2020-06-17 08:08:21 -07:00
```
2024-09-20 07:47:06 -07:00
## OOO encoding
Head chunks use the highest bit of the `encoding` field to indicate whether it is out-of-order (1) or not (0). This bit is not set for chunks in the on-disk blocks.