File format
metatable file is composed from frames and structure of frames written at the end of file. Frames are named, name of frame consists from 4 bytes (there is possibility to have at most 2^32 frames if ever needed). Data itself are stored as sorted set of fixed-size records in data
frame. Values of type string
are stored in another frame called strs
. The last basic frame is indx
where „indexes“ are stored.
All integers are stored in big-endian format.
Structure of frames (end of file)
Zero or more frame triples (name : string4, size : integer, used : integer)
followed by count of frames frame_count : integer
. Then version of metatable format format_version : integer
and at the end of string "metatable"
:
(name : string4, size : integer, used : integer)*
frame_count : integer
format_version : integer
"metatable"
data
frame
Fixed-size records, each record 256 bytes long:
row
(124 bytes) – NUL right padded string; row namecol
(124 bytes) – NUL right padded string; col nametype
(4 bytes) – integer:1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
– string, other bits are string size (string can be at most 2^31 bytes long); offset instrs
table is invalue
field01000000000000000000000000000000
– integer; value invalue
field00100000000000000000000000000000
– true;value
field is 000010000000000000000000000000000
– false;value
field is 0
value
(4 bytes) – depends ontype
Records are stored in ascending order by row and col.
strs
frame
Raw value of strings stacked up one after another. Have to be referenced from data
records.
indx
frame
Fixed-size records, each record 128 bytes long:
index
(120 bytes) – NUL right padded string; start of row namelower
(4 bytes) – integer; lower bound position of row (offset_in_data_frame = lower * 256
)upper
(4 bytes) – integer; upper bound position of row (end_in_data_frame = upper * 256
)