* feat(mito2): store Narthex samples in independently prunable groups Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito2): retain samples format version 1 Signed-off-by: evenyag <realevenyag@gmail.com> * style(mito2): format grouped samples test helpers Signed-off-by: evenyag <realevenyag@gmail.com> * perf(mito2): streamline grouped Narthex samples and frame exact keys Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito2): validate key directory entry alignment Signed-off-by: evenyag <realevenyag@gmail.com> * perf(mito2): reuse continued keys and coalesce sample directory reads Signed-off-by: evenyag <realevenyag@gmail.com> * style(mito2): use crate-relative key page imports Signed-off-by: evenyag <realevenyag@gmail.com> * test(mito2): inline the raw key frame wire example Signed-off-by: evenyag <realevenyag@gmail.com> * docs(mito2): clarify grouped samples integrity and version policy Signed-off-by: evenyag <realevenyag@gmail.com> --------- Signed-off-by: evenyag <realevenyag@gmail.com>
31 KiB
Narthex format: samples
The Narthex format, selected by sst_format = 'narthex', is optimized
for Prometheus-style metric data. It separates series identities and string tags
from timestamped numeric samples.
The format has two artifact roles: NarthexSamples owns sample data, and
NarthexSeriesIndex indexes exact series identities.
Region manifests serialize these roles as narthex_samples and
narthex_series_index.
Region manifest
With sst_format = 'narthex', a samples SST owns
<region_dir>/<file_id>/manifest.json and its part-<n>.samples objects.
The region manifest records the manifest size and a parts array in part-ID
order. Each part record contains its encoded file_size in bytes. The
series index specification defines coverage.
Wire specification
The samples format stores ordered groups of single-series blocks in each sample part. Every group owns its column chunks, exact sparse primary keys, and descriptor pages. The part directory locates the groups and records their ID and time bounds. As a pre-GA exception to the format versioning rule, the manifest and part header retain version 1 across this layout change. Rebuild artifacts written with the earlier embedded or unframed grouped layouts before using this reader.
Like the Mito Parquet write path, grouped samples add no application-level content checksums. This applies to the group directory, descriptor pages, exact-key frames, and column chunks. Readers validate structure, lengths, and bounds, but rely on the storage layer for byte integrity. A corrupted directory bound that still passes validation can prune matching rows. A same-length change to raw key or value bytes can silently change a series label or a Float64 value.
Samples store nullable Float64 and native histogram fields, timestamps, sequences, and operation types in single-series blocks bounded by rows and decoded bytes.
Artifact manifest
The region manifest publishes each samples file and its object sizes. The file's manifest and parts share its generation directory. Readers pin the SST while using those objects.
The source file ID and generation use existing FileId serialization. The
generation is unique for each build. A manifest contains:
| Field | Meaning |
|---|---|
format |
String columnar-samples |
version |
Integer 1 |
identity_encoding |
String exact-sparse-key-area; required, never defaulted. It names the identity and the layout that stores it, so exact-sparse-key (keys inline in the block descriptors) is different and not readable |
region_id |
Physical region ID, u64 |
source_file_id |
Physical samples SST file ID |
generation |
Physical samples SST file ID, using FileId serialization |
timestamp |
Object with column_id, name, and unit |
fields |
Ordered objects with column_id, name, type, and nullable |
files |
Ordered part descriptors, defined below |
The timestamp's ID is u32, its name is the region's time-index name, and its unit
is one of second, millisecond, microsecond, or nanosecond. Values are
signed i64 counts since the Unix epoch in that unit. There is no dataset-relative
origin, unit conversion, or timezone in the file. The timestamp is non-null.
The field list records the build-time region field schema in metadata order.
Require 1..=1,024 fields, each with type "float64" or "native_histogram" and
nullable = true. native_histogram is the canonical nullable
greptime_native_histogram Arrow struct, the same type the Parquet path stores.
A non-nullable source Float64 field is represented by this same nullable logical
type with no null values. Sparse logical-table fields may be entirely null.
Timestamp and field IDs must be distinct. All output names must be unique,
including the internal names below. Tags are not sample fields and are not stored here.
The stored logical Arrow schema is __table_id: UInt32, __tsid: UInt64, the
timestamp column with its recorded unit, __sequence: UInt64, __op_type: UInt8,
then the nullable value fields in manifest order, and finally
__primary_key: Binary naming the exact key of the block that produced each row.
The five internal columns and __primary_key are non-null; value fields stay
nullable, as the manifest declares them. __table_id/__tsid are the coarse,
hash-based prefix of that key. Tag columns are not stored; the exact key is the
identity. A reader returns that key once per output batch — each block belongs to
exactly one series — instead of materializing the column per row, and rejects a
request that projects it.
Each files entry contains part_id: u32, file_size: u64, directory_bytes: u64, num_rows: u64,
num_blocks: u64, first, last, min_timestamp: i64, and max_timestamp: i64.
first and last are inclusive { table_id: u32, tsid: u64 } bounds. Time bounds
are the minimum and maximum over all blocks in the part, not just its first
and last rows. Every part is nonempty. Part IDs start at zero, increase by one,
and derive part-<part_id>.samples names with decimal IDs and no leading zeros.
No object path is stored in a part descriptor.
Parts follow input order. Adjacent identifier ranges satisfy
previous.last <= next.first; equality is allowed because a series can continue
in another part. The shared boundary series can also have equal timestamps on
both sides. These ranges are not disjoint, unlike the series-index format.
Readers consider every matching part rather than choosing a unique owner.
ArtifactMetadata.objects records the manifest and every part as { path, file_size };
the artifact's file_size is their checked sum. An empty artifact has an empty
file list and no part files. The manifest is at most 64 MiB.
Region, source SST, and generation must match the owning SST metadata. The artifact object list must contain exactly the derived manifest and part paths, without duplicates, extra objects, or inconsistent size totals. Part order comes from the manifest.
Part file
16-byte header
group 0:
column chunks in block order
framed exact keys
descriptor leaves and optional internal root
group 1 ... group N-1 (same layout)
directory (108 bytes per group, in file order)
16-byte footer
All fixed-width numbers are little-endian, without alignment padding. Byte ranges
are half-open; offsets are absolute from the start of the part. Parse each field
explicitly. Rust struct layout, enum order, and usize are not wire contracts.
Reserved fields must be zero, and decoded structures must have no trailing bytes.
Header
| Field | Bytes | Value |
|---|---|---|
| Magic | 8 | ASCII GTSAMPLE |
| File version | 4 | 1 |
| Reserved | 4 | Zero |
Column payloads and row semantics
Each block contains exactly one series and names it by that series' exact canonical
sparse primary key, which is stored once per series in the group's key area
and referenced by the block descriptor. The key is the SST's own encoding of
(table_id, tsid, label column-id/value pairs sorted by name, non-null only), and
(table_id, tsid) is only its order-preserving prefix. Two distinct series may
share a prefix. Timestamp, sequence, operation type, and each present value field
are independent chunks; their references are in the metadata, not inline headers.
Emit chunks in that order, with value fields following manifest order.
Rows preserve delete markers, duplicate timestamps, and equal-key ties, including conflicting values at the same sequence. The format does not encode a deduplicated or snapshot-filtered view.
Block keys are nondecreasing in byte-lexicographic order, timestamps are
nondecreasing within one exact key, and sequences are nonincreasing within equal
timestamps, including across parts. A change of exact key restarts timestamps and
ordinals, even when the coarse (table_id, tsid) prefix is unchanged. Equal
ordering keys retain input order; operation type is not a sorting key. The key area
follows the same order, one copy per series in each group. Block keys never decrease, so a key that
is read must not sort before the key read before it; a repeated key must continue its
timestamps and ordinals rather than restart them. Because key bytes are read lazily,
the descriptor-only checks use the (table_id, tsid) prefix and the order, disjointness,
and reuse of key references inside one group, and only the keys a request actually loads
are checked for byte order and continuation.
Blocks split on an identity change or before the next row would exceed a packing
limit. There is no hourly split and no padding of short blocks. The default row
limit is 8,192, also the version-1 reader maximum; a writer may choose a smaller
positive limit without changing the version. With F manifest fields and N
rows, the decoded accounting size is:
N * (8 timestamp + 8 sequence + 1 operation + 8 * F values)
+ F * ceil(N / 8) validity bytes
Require this to be at most 262,144 bytes. A native histogram field counts as one 8-byte value per row here, so the formula does not bound its decoded buffers: its 18 struct children and bucket lists are bounded only by its chunk, and the reader reserves memory for them from the chunk header (see encoding 8). A writer also ends a block before a histogram chunk's encoded size bound would exceed the 1 MiB chunk limit: 1 byte plus 11 bytes per struct child and per list item for each row, and 16 bytes plus 64 bytes per child and the validity bytes for the chunk. A sample that exceeds the limit on its own is rejected when it is written to a Narthex region. Count all manifest fields, including omitted/all-null fields, and reserve validity bytes even for all-valid fields. Without histogram fields, this is a bound on decoded column buffers, not total allocator usage or RSS. The effective row cap is the largest integer satisfying both limits: 8,192 for one field and 31 for 1,024 fields. Encoded buffers and metadata have separate bounds below. Increasing the reader maximum requires an explicit compatibility decision; it is not merely a writer option in this version.
Payload reference
Every stored column and metadata page uses a 24-byte reference:
| Field | Bytes | Meaning |
|---|---|---|
| Offset | 8 | Absolute location of stored bytes |
| Stored length | 4 | Bytes to fetch |
| Decoded length | 4 | Bytes after decompression, before column/page decoding |
| Encoding ID | 2 | Sample column or metadata encoding, according to context |
| Compression ID | 2 | Compression of the encoded bytes |
| Reserved | 4 | Zero |
Lengths are nonzero. Check offset + stored_length for u64 overflow before
checking the enclosing area. u32 payload lengths do not limit the part or its
offsets to 4 GiB. Require exactly the
declared decoded length, with bounded output even if a codec frame claims more.
Key area
Each group concatenates one copy of each distinct key in block order. A descriptor
addresses this logical stream relative to payload_end: subtract payload_end
from the descriptor offset to locate its first byte. Check its nonzero length
against logical_key_end. One key can span multiple frames.
Split the stream into 65,536-byte frames with a possibly shorter final frame.
The physical key area starts at payload_end with one little-endian u32 stored
length per frame, followed by their stored bytes. The directory length is 4 * ceil(logical_bytes / 65536). A frame whose stored
length equals its decoded length is raw. A shorter frame uses Zstd level 1.
The frame lengths must exactly cover the physical area ending at key_end.
The samples writer and reader extract the fixed-width ID prefix and treat the remaining bytes as opaque. The reader checks that the ID matches the descriptor and compares full bytes for equality and ordering. It loads only frames needed for selected keys and reuses the current frame across consecutive keys.
A key reference is an offset into one group's key area, so the references of two groups are unrelated numbers and are never compared. Whether one exact series continues in another group is decided on the exact key bytes: the last key a request loaded from one group is compared with the first it loads from the next, and an equal key must continue timestamps and ordinals, while a greater key starts a new series at ordinal zero.
Because keys are only read for blocks a request selects, this content check covers the keys actually loaded: unvisited ranges are validated structurally, not by content. It is chained, though, so a selection that skips a block, a page, or a whole part cannot hide the two keys around the gap: the check compares each loaded key with the previous loaded key, not with the previous traversed block. Loaded keys must be nondecreasing. Within one exact key the ordinal must strictly increase, and only immediately adjacent blocks of that same key require it to be exactly one greater; a different key starts a new series at ordinal zero, so no ordering between the two series' ordinals is required.
Metadata pages
A leaf describes blocks. An internal page references leaves. The root is either the only leaf (depth 1) or an internal page (depth 2). Other depths are unsupported in version 1; finish the current group before a third level would be needed.
As in the series format, the entire page, including its kind and count, is encoded
and independently compressed. The reference in the parent or group directory entry supplies
its storage location, lengths, and codecs. There is no separate stored
page header. Decoded pages begin with kind: u32 and entry_count: u64:
Leaf (kind 0): Internal root (kind 1):
kind u32 kind u32
entry_count u64 entry_count u64
block descriptor 0 page reference 0 64 bytes
... ...
block descriptor N-1 page reference N-1 64 bytes
Pages are nonempty and limited to 65,536 decoded bytes, including the 12-byte
prefix. Descriptors never straddle pages, and every descriptor is fixed-width because
the key it names is not stored in it. The writer requires the 12-byte leaf prefix and
one descriptor to fit in a configured page, which for the 1,024-field maximum is
12 + 56 + 36 * 1,027 = 37,040 decoded bytes. The page limit is a bound on
descriptors only: it no longer bounds the length of a series key.
Block descriptor
| Field | Bytes | Meaning |
|---|---|---|
| Table ID | 4 | Coarse prefix of the constant key in this block |
| TSID | 8 | Coarse prefix of the constant key in this block |
| Key offset | 8 | Absolute offset of the block's exact key in the group's key area |
| Key length | 4 | Nonzero; the key's (table_id, tsid) prefix must equal the two fields above |
| Minimum timestamp | 8 | Signed i64, first row's timestamp |
| Maximum timestamp | 8 | Signed i64, last row's timestamp |
| Block ordinal | 8 | Per-identifier ordinal across the artifact |
| Row count | 4 | Nonzero, subject to decoded-block limits |
| Column count | 4 | Number of following column descriptors |
| Column descriptors | 36 each | Defined below |
The fixed prefix is 56 bytes and does not depend on the key: 4 table ID + 8 TSID + 8 key offset + 4 key length + 8 minimum timestamp + 8 maximum timestamp + 8 ordinal + 4 row count + 4 column count. Ordinals start at zero for each exact key and increase
by one across block and part boundaries while that key continues. Blocks sort by exact
key. Adjacent blocks of the same exact key share one key reference and satisfy
previous.max_timestamp <= next.min_timestamp; equality is permitted. Blocks of
different keys have no timestamp relation at all, and a new series' key copy starts at
or after the end of the previous copy.
Each column descriptor is:
| Field | Bytes | Meaning |
|---|---|---|
| Role | 4 | 1 timestamp, 2 sequence, 3 operation type, 4 value field |
| Column ID | 4 | Timestamp/field physical ID; zero for sequence/operation |
| Payload reference | 24 | Independently stored chunk |
| Null count | 4 | Number of null rows |
Role and column ID together identify a chunk. The role namespace avoids reserving
physical field IDs for internal columns. Time, sequence, and operation descriptors
are mandatory, appear first in that order, and have zero null counts. Value
descriptors follow manifest order with no repeated or unknown IDs. A value with
all rows null is omitted and synthesized as null by the reader; present value
chunks have null_count < row_count. No value statistics are stored.
A block with P present fields has C = 3 + P chunks and a descriptor of
56 + 36 * C bytes, whatever its key's length. For one present field that is
56 + 36 * 4 = 200 bytes; at the 1,024-field maximum it is 56 + 36 * 1,027 = 37,028
bytes, and the 12-byte leaf prefix makes that 37,040. Key length is therefore not
part of any page budget: a part whose exact key is far longer than a page produces the
same descriptors, and the earlier base + key_length ceiling — 65,344 bytes with no
value field, 65,300 with one, and 20,288 at the 1,024-field maximum — no longer
exists. All chunks are physically ordered and disjoint in the column area, across
blocks as well as within a block, and the key area follows the column area. There is no
inline block header or block-wide compression.
Page reference and time bounds
A page reference carries coarse series bounds, two timestamp bounds, and a payload reference:
| Field | Bytes | Meaning |
|---|---|---|
| First table ID; first TSID | 4 + 8 | Inclusive first identifier |
| Last table ID; last TSID | 4 + 8 | Inclusive last identifier |
| Minimum timestamp | 8 | Minimum over all descendant blocks |
| Maximum timestamp | 8 | Maximum over all descendant blocks |
| Payload reference | 24 | Location and codecs of the child page |
The reference is 64 bytes. Compare identifiers as integer pairs, not as serialized
little-endian bytes. Time bounds use the manifest unit. The time range is an
envelope over all identifiers in the page; it need not describe the first or last
identifier alone. This can admit extra reads, but cannot exclude matching rows.
Every part/page identifier interval requires first <= last, and all part/page/
block time intervals require min_timestamp <= max_timestamp, even when pruning
would skip their payloads.
Child pages follow block order. Their identifier bounds may touch at a shared series, just like part bounds. Do not require strict disjointness or use an exclusive next-child lower bound. Validate each loaded page's derived identifier and time bounds against its reference. At depth 2 all children must be leaves; reject an internal child. Child byte ranges are ordered, disjoint, within the metadata area, and precede the parent. The root ends at the boundary with the next group or the directory.
An internal root has 12 + 64 * N decoded bytes, so it holds at most
floor((65536 - 12) / 64) = 1,023 leaf references. The writer must account for the
next descriptor's leaf placement before writing its block. If the descriptor
would require a 1,024th leaf, finish this group and start the block in a new group.
Navigation and equal-timestamp example
For a requested qualified identity and optional half-open interval [start, end),
select every part, group and page whose identifier interval contains the identity and whose
time envelope overlaps the request:
(start is absent || max_timestamp >= start)
&& (end is absent || min_timestamp < end)
For multiple selected identities, intersect the ordered ID set with the inclusive identifier range. A table restriction also intersects this selection. Visit each selected page once per request. Apply the same overlap test to leaf blocks, then filter decoded timestamps exactly. Metadata bounds are conservative candidates. No predecessor-only or unique-child lookup is used: a shared identity or timestamp can require several adjacent children, and even several parts.
Part 0, group 0, depth 2:
Root R
├─ Leaf A: IDs [(7,42),(7,42)], times [0,100]
│ block ordinal 0: (7,42), times [0,100]
└─ Leaf B: IDs [(7,42),(7,43)], times [0,200]
block ordinal 1: (7,42), times [100,200]
block ordinal 0: (7,43), times [0,50]
Part 1, group 0:
Leaf/root C: IDs [(7,43),(7,43)], times [50,80]
block ordinal 1: (7,43), times [50,80]
For (7,42) and [100,101), visit both A and B, keeping all rows at timestamp
100 from blocks 0 and 1. Do not decode (7,43) payloads. For (7,43) and
[50,51), visit B and part 1's C: both may contain rows at 50. A [51,60) request
for (7,43) can skip B's (7,43) block even though B's time envelope overlaps.
For (7,42) and [90,95), A is still visited although its block starts before
the requested interval. Global time envelopes must not be computed from just
the first and last blocks: B's range is [0,200], not [100,50].
The series-index format has no sample timestamps or time bounds.
Group directory and footer
Every group has one fixed-width directory entry. Its ID and timestamp bounds are those of its root. Exact keys stay within the group.
| Field | Bytes | Meaning |
|---|---|---|
| Root page reference | 64 | Inclusive coarse ID and timestamp bounds, location, lengths and codecs |
| Index depth | 4 | 1 for a leaf root, 2 for an internal root |
payload_end |
8 | End of column chunks and start of exact keys |
key_end |
8 | End of exact keys and start of pages |
logical_key_end |
8 | payload_end plus decoded key bytes |
| Row count | 8 | Total rows in the group |
| Block count | 8 | Total blocks in the group |
The footer contains the eight ASCII bytes NARTGRP1, and the directory length (u64)
in little-endian order. The object size locates the
footer. The manifest records the directory length so the reader fetches both in one range and checks the lengths agree. The directory is nonempty, a multiple of 108 bytes and at most 8 MiB.
The first group starts at offset 16. Each root ends at the start of the next
group, or the directory for the final group. Each group's column, key and page
references must fall within its respective area. The reader checks the combined
group counts and bounds against the part inventory before using the directory.
The default writer uses a 4 MiB budget for pending descriptors and distinct key bytes. After 3 MiB it prefers to finish at the next series boundary. A continuing series can span groups at the hard threshold. A single key and descriptor larger than the budget occupy a group on their own. Only directory entries survive group finalization. Parts roll at a 512 MiB encoded-byte target or the directory limit. The last group's metadata and the directory can take the final size above the target.
Encodings and compression
Sample column encoding IDs below are distinct from series column encoding IDs, even where their numeric values coincide. Metadata and compression have separate namespaces as well. Never reuse an assigned ID with a different meaning.
| Namespace | ID | Meaning |
|---|---|---|
| Column encoding | 1 | Timestamp constant step |
| Column encoding | 2 | Timestamp delta-of-delta |
| Column encoding | 3 | Constant sequence |
| Column encoding | 4 | Sequence delta |
| Column encoding | 5 | Nullable Float64 XOR |
| Column encoding | 6 | Constant operation type |
| Column encoding | 7 | Raw operation types |
| Column encoding | 8 | Native histogram struct, column by child |
| Metadata encoding | 1 | Leaf/internal page layout above |
| Compression | 0 | Raw encoded bytes |
| Compression | 1 | Zstd frame |
Encode first, then compress each chunk/page independently. The default writer stores sample chunks of 128 bytes or less raw. For larger chunks and descriptor pages it tries Zstd level 1 and chooses it only if strictly smaller than the raw encoded bytes. Compression 0 requires equal stored and decoded lengths. Compression level is a writer choice; decoding information is in the frame.
Unsigned varints use base-128/LEB128: seven data bits per byte and a high
continuation bit. Writers emit the shortest representation. Readers reject
truncation, more than ten bytes, a tenth byte greater than 1, and trailing bytes
after the expected values. ZigZag maps signed i64 x to
((x as u64) << 1) ^ ((x >> 63) as u64) and reverses that mapping on decode.
All wrapping arithmetic below is modulo 2^64, not signed overflowing arithmetic.
Timestamp encodings 1 and 2
Encoding 1 contains first: i64 and step: i64, exactly 16 bytes. Use it when
every adjacent difference is the same nonnegative, representable i64. A singleton
uses step zero. Reconstruct by checked addition; reject overflow. Zero step is
valid for repeated timestamps.
Encoding 2 contains the first i64, followed for two or more rows by the first delta as a ZigZag varint, then ZigZag varints of differences between deltas. Compute deltas and delta differences with wrapping arithmetic; reconstruct in the same way. This permits differences across the full signed timestamp range. After either decoding, require nondecreasing signed timestamps and exact agreement of first/last values with the descriptor. Consume exactly the recorded row count. Use encoding 1 when applicable, otherwise encoding 2.
Sequence encodings 3 and 4
Encoding 3 contains one u64, repeated for all rows. Encoding 4 contains the first u64 followed by each wrapping u64 difference from its predecessor, reinterpreted as i64 and written as a ZigZag varint. Decode with wrapping addition. Use 3 if all sequences are equal, otherwise 4. Preserve all u64 bit patterns. Sequence need not be monotonic across different timestamps; equal-timestamp runs retain the input's nonincreasing order.
Nullable Float64 encoding 5
validity_kind <u8> # 0 = all valid, 1 = bitmap
validity <ceil(row_count/8) bytes> # only for kind 1
first_non_null_bits <u64>
xor_deltas <one uvarint per remaining non-null value>
Bitmap bit i % 8 in byte i / 8 is one for a present value; unused high bits of
the final byte are zero. Kind 0 has no bitmap and requires zero null count. Kind
1 requires 0 < null_count < row_count and an exactly matching count of unset
in-range bits. All-null columns have no descriptor or payload, so every stored
Float64 chunk contains at least one non-null value.
Process non-null values in row order. Write the first IEEE-754 bit pattern as
u64, then varints of XOR with the previous non-null bit pattern. Nulls do not
reset that previous value. Decode exactly row_count - null_count values and
scatter according to validity. Preserve all bits, including signed zero, NaN
payloads, infinities, and subnormals. Null and NaN are distinct. The unspecified
value-buffer bits behind nulls are not part of the logical preservation contract.
Native histogram encoding 8
child_count <u8>
child_kinds <u8 x child_count> # 1 Float64, 2 Int32, 3 Int64, 4 Timestamp(ms);
# 0x10 | kind for a list
list_items <uvarint> # items of all valid lists in the chunk
validity <ceil(row_count/8) bytes> # only when the descriptor null count is nonzero
per child, in struct order:
scalar: section(row_count values)
list: section(row_count lengths, null for a null list), then
section(list item values) unless the child has no items
section(n):
null_count <uvarint>
unless null_count == n:
byte_length <uvarint>
body <byte_length bytes> # encoding 5 over the n values
The struct order is fixed. The header records only child kinds, so children of the
same kind, such as zero_threshold and sum, are told apart by position alone:
| # | Child | Kind |
|---|---|---|
| 0 | schema |
Int32 |
| 1 | zero_threshold |
Float64 |
| 2 | sum |
Float64 |
| 3 | reset_hint |
Int32 |
| 4 | start_timestamp |
Timestamp(ms) |
| 5 | custom_values |
List of Float64 |
| 6 | positive_span_offsets |
List of Int32 |
| 7 | positive_span_lengths |
List of Int32 |
| 8 | negative_span_offsets |
List of Int32 |
| 9 | negative_span_lengths |
List of Int32 |
| 10 | count_i64 |
Int64 |
| 11 | zero_count_i64 |
Int64 |
| 12 | positive_buckets_i64 |
List of Int64 |
| 13 | negative_buckets_i64 |
List of Int64 |
| 14 | count_f64 |
Float64 |
| 15 | zero_count_f64 |
Float64 |
| 16 | positive_buckets_f64 |
List of Float64 |
| 17 | negative_buckets_f64 |
List of Float64 |
A chunk holds every row of the block, null rows included, one child after another. Values map to u64 before encoding 5: Float64 keeps its bit pattern; integers and timestamps are ZigZag-mapped. A null list has no items; the item section holds the items of the valid lists in row order. The descriptor's null count is the struct's own null count, and the validity bitmap follows the rules of encoding 5.
Child count and kinds must match the manifest field's struct type exactly, so a
chunk is never decoded as another type. list_items must equal the lengths read and
must not exceed 1,048,576. The reader reserves memory from row_count, the child
count and list_items before it decodes a chunk. All-null fields have no descriptor
or payload, as for Float64.
Operation encodings 6 and 7
Operation values are u8: 0 delete, 1 put, matching Mito's current OpType values.
Unknown operation values fail decoding. Encoding 6 stores one byte repeated for
the whole block; encoding 7 stores exactly one byte per row. Use 6 when all values
are equal, otherwise 7. Neither encoding filters delete rows or discards their
field values.
Limits and evolution
An individual chunk has at most 1 MiB of encoded bytes after decompression and
1 MiB plus 64 KiB of stored bytes. Pages have at most 65,536 decoded and 131,072
stored bytes. Series keys are stored in the key area rather than in a page or a
chunk, so a key's length is bounded by the part and by its u32 reference length,
not by PAGE_LIMIT; a key longer than a page is a supported part of this version. Bound sizes before allocating, fetching, or decompressing. Validate
counts against enclosing bytes before allocating descriptor vectors; row counts
must also satisfy the decoded-block formula. Null output materialization remains
subject to the same block bound even when chunks are omitted.
Unknown file versions, depths, reserved fields, roles, or metadata codecs fail open/read explicitly. Column role must agree with its encoding: time 1/2, sequence 3/4, Float64 5, native histogram 8, operation 6/7. A value chunk's known encoding must also be the one its manifest field type is stored with. An unknown column encoding or compression can be skipped if its chunk is not needed, but attempting to decode it returns an unsupported-codec error. Known encodings assigned to a different role are invalid metadata, even for an unprojected column. Unknown fields or malformed references must not be interpreted as omitted all-null columns.
New column encodings or compression methods receive new IDs. Structural changes, changed field meanings, or incompatible limits require a new version. Deeper metadata trees require an explicit reader-support and rollout decision; an unchanged layout alone does not make them readable by version-1 implementations.