Format Versions
Format Versions
The format version is the byte immediately after the leading magic string:
6-byte magic string "TsFile"
1-byte format versionThis guide describes 0x04. The format byte and the project release number serve different purposes: a release in the 2.x series can use file format v4. The project release label is not stored in the file header.
Version 4 uses segmented DeviceIDs and stores per-table device-index roots and Table Schemas in TsFileMetadata. Version 3 uses a single-string device identifier and a different footer. A reader needs the corresponding version's structures to parse either file correctly.
Reader Dispatch
Read the version before interpreting data markers, then select the encryption mode:
validate leading magic -> read version -> inspect optional encryption header
-> resolve encryption mode/profile -> parse the matching data/footer grammarIf the observed version is unsupported, report that before parsing the data. A familiar marker or tail magic does not establish that the rest of the file uses the expected layout.
Compatibility Contract
Within a supported version, a reader also needs the types, codecs, and encryption features used by the requested data. For example, v4 Page AEAD files have a 0x06 encryption header at offset 7, which selects an extended Chunk Header and a Page-body profile. The version byte stays 0x04; a v4 reader without this capability must report it as unsupported.
Assigned identifiers keep their meanings. Unknown footer properties have length-delimited keys and values, so their byte ranges can be consumed. Unknown data markers generally cannot be skipped because they have no common payload length. Extensibility explains these boundaries, and Encryption defines the AEAD layout.