Skip to content

Hierarchical database unload format, versions 1 and 2

A portable image of one hierarchical database: its segment occurrences in hierarchic sequence (pre-order), each with its level, segment name and data exactly as stored. Written by System::export_database / oliviadb_export, read by import_database / oliviadb_import. Integers are big-endian. The magics ("HDBUNL01", "HDBUNL02") keep the spelling they were defined with; they name the format, not the product.

file    = "HDBUNL01" name_len:u16 name:name_len bytes record* 0x00
record  = level:u8 (1..)  seg_len:u8  segment_name:seg_len bytes  data_len:u32  data
  • name is the database name (ASCII); segment_name the segment's name (ASCII).
  • data is the segment's stored bytes (the program's representation: EBCDIC databases stay EBCDIC; variable-length segments include their LL field).
  • A record's level is at most one more than the previous record's; a level-1 record starts a new database record.
  • The trailing 0x00 ends the file.

Reload rebuilds everything that is not data: keys from the sequence fields (and, for hashed roots, the randomizing module), the order of twins without a unique key from the order in the file, and secondary index entries from their source segments.

Version 2: writer layouts

Written by System::export_database_layouts / oliviadb_export_layouts; import_database / oliviadb_import read both versions. It adds the layouts the stored versions were written with (spec/schema.md 4.3), so an unload and reload between OliviaDB stores keeps them.

file    = "HDBUNL02" name_len:u16 name:name_len bytes
          layout_count:u32 layout* record* 0x00
layout  = digest:32 bytes json_len:u32 json:json_len bytes
record  = level:u8 seg_len:u8 segment_name:seg_len bytes data_len:u32 data
          layout:u32 variant:u32
  • json is the layout's canonical JSON (without source), digest its SHA-256.
  • layout is the record's writer layout as an index into the table (1-based; 0: none recorded); variant the REDEFINES variant its writer recorded (1-based; 0: none).
  • Reload registers each layout of the table in the target's registry (the same layout keeps its number there, a new one gets the next: numbers are local to a store) and writes each segment with its writer layout under the target's number. Sources are not carried. A digest that does not match its JSON is refused.