Skip to content

Commit

Permalink
fixup! chore: Update ASCII diagram of chunk binary encoding
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Haudum <[email protected]>
  • Loading branch information
chaudum committed Dec 14, 2024
1 parent dc8b06a commit 92edc35
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 25 deletions.
77 changes: 52 additions & 25 deletions docs/sources/operations/storage/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,29 +135,56 @@ See the [IBM Cloud Object Storage section](https://grafana.com/docs/loki/<LOKI_V
## Chunk Format

```
-------------------------------------------------------------------
| | |
| MagicNumber(4b) | version(1b) |
| | |
-------------------------------------------------------------------
| block-1 bytes | checksum (4b) |
-------------------------------------------------------------------
| block-2 bytes | checksum (4b) |
-------------------------------------------------------------------
| block-n bytes | checksum (4b) |
-------------------------------------------------------------------
| #blocks (uvarint) |
-------------------------------------------------------------------
| #entries(uvarint) | mint, maxt (varint) | offset, len (uvarint) |
-------------------------------------------------------------------
| #entries(uvarint) | mint, maxt (varint) | offset, len (uvarint) |
-------------------------------------------------------------------
| #entries(uvarint) | mint, maxt (varint) | offset, len (uvarint) |
-------------------------------------------------------------------
| #entries(uvarint) | mint, maxt (varint) | offset, len (uvarint) |
-------------------------------------------------------------------
| checksum(from #blocks) |
-------------------------------------------------------------------
| metasOffset - offset to the point with #blocks |
-------------------------------------------------------------------
// Header
+-----------------------------------+
| Magic Number (uint32, 4 bytes) |
+-----------------------------------+
| Version (1 byte) |
+-----------------------------------+
| Encoding (1 byte) |
+-----------------------------------+
// Blocks
+--------------------+----------------------------+
| block 1 (n bytes) | checksum (uint32, 4 bytes) |
+--------------------+----------------------------+
| block 1 (n bytes) | checksum (uint32, 4 bytes) |
+--------------------+----------------------------+
| ... |
+--------------------+----------------------------+
| block N (n bytes) | checksum (uint32, 4 bytes) |
+--------------------+----------------------------+
// Metas
+------------------------------------------------------------------------------------------------------------------------+
| #blocks (uvarint) |
+--------------------+-----------------+-----------------+------------------+---------------+----------------------------+
| #entries (uvarint) | minTs (uvarint) | maxTs (uvarint) | offset (uvarint) | len (uvarint) | uncompressedSize (uvarint) |
+--------------------+-----------------+-----------------+------------------+---------------+----------------------------+
| #entries (uvarint) | minTs (uvarint) | maxTs (uvarint) | offset (uvarint) | len (uvarint) | uncompressedSize (uvarint) |
+--------------------+-----------------+-----------------+------------------+---------------+----------------------------+
| ... |
+--------------------+-----------------+-----------------+------------------+---------------+----------------------------+
| #entries (uvarint) | minTs (uvarint) | maxTs (uvarint) | offset (uvarint) | len (uvarint) | uncompressedSize (uvarint) |
+--------------------+-----------------+-----------------+------------------+---------------+----------------------------+
| checksum (uint32, 4 bytes) |
+------------------------------------------------------------------------------------------------------------------------+
// Structured Metadata
+---------------------------------+
| #labels (uvarint) |
+---------------+-----------------+
| len (uvarint) | value (n bytes) |
+---------------+-----------------+
| ... |
+---------------+-----------------+
| checksum (uint32, 4 bytes) |
+---------------------------------+
// Footer
+-----------------------+--------------------------+
| len (uint64, 8 bytes) | offset (uint64, 8 bytes) | // offset to Structured Metadata
+-----------------------+--------------------------+
| len (uint64, 8 bytes) | offset (uint64, 8 bytes) | // offset to Metas
+-----------------------+--------------------------+
```
2 changes: 2 additions & 0 deletions pkg/chunkenc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
+---------------+-----------------+
| len (uvarint) | value (n bytes) |
+---------------+-----------------+
| ... |
+---------------+-----------------+
| checksum (uint32, 4 bytes) |
+---------------------------------+
Expand Down

0 comments on commit 92edc35

Please sign in to comment.