Skip to content

data/SPANS caches per-file value spans. It is a derived cache: sealed whole with AAD "stc-span-seed", written through SPANS.tmp and renamed, and ignored and rebuilt when it fails to open or carries an unknown magic.

The file starts with the magic "stspans1".

Field Encoding Meaning
magic ascii "stspans1"
nspecs u32 LE number of specs
spec, repeated nspecs times below one span spec
nfiles u32 LE number of files
file, repeated nfiles times below one file record

A spec:

Field Encoding Meaning
start u32 length, then bytes start of the key range
end u32 length, then bytes end of the key range
low u64 LE low bound
high u64 LE high bound
timestamp u8 1 if the span is a timestamp span, otherwise not

A file:

Field Encoding Meaning
id u64 LE file id
size u64 LE file size
entries u64 LE entry count of the file
nrec u32 LE number of records
record, repeated nrec times below one record

A record:

Field Encoding Meaning
spec u32 LE index of the spec
flag u8 0 = no value range, 1 = min and max follow; any other value rejects the file
min, max i64 LE each present only when flag is 1

A record whose spec is not below nspecs rejects the file. A file entry is used only when its size and entries equal those of the live file.