Skip to main content

Module write

Module write 

Source
Expand description

The 0x06 assembler: super::parts::Parts in, a 0x06 file out. Every writer goes through here — the in-RAM build (via 0x05 section images), rete convert, and the memory-bounded build and merge (which hand it their spill as an address space, see extbuild_v06). recard only re-lays the front.

The front (root, card region, stats, leaf directories) is built in memory; the data region is streamed from the input reader, hashed on the way. The data is written first at its final offset, then the front at offset 0, so the output needs Write + Seek and the input is read once.

Structs§

Hooks
What assemble_with reports while it writes.
WriteOpts
Assembly options.
Written
What the assembler wrote.

Enums§

NewCard
The card a re-card writes.
QuadClustering
How quad tiles are clustered in the data region.

Constants§

MIN_FILE_LEN
The smallest 0x06 file: 1 KiB, what every reader reads first anyway.

Functions§

assemble
Assemble a 0x06 file from parts, whose payload ranges point into input.
assemble_with
assemble, reporting through hooks. The memory-bounded build deletes each spill file as soon as every range it feeds is in the output, so the output grows as the spill shrinks, and drives --progress from the byte count.
card_region_len
The card region’s length for a card and record of these stored lengths.
commit_header
Write h over the first 128 bytes (the commit of recard_in_place).
convert
Convert a 0x05 file read through input into out.
convert_image
Convert a whole 0x05 image held in memory to a 0x06 image.
convert_with_labels
convert, giving the file the LABEL_INDEX section labels (its 0x05 encoding, from label_section) when it has none.
label_section
The LABEL_INDEX section (0x05 encoding) of the default graph of rete, computed as rete build --label-index computes it — from the triples of the label predicates only, read through the index. Empty when the graph has no label predicate.
recard_in_place
Re-card a 0x06 file in place, when the new card and record fit in a free gap of its card region (beside the old pair, which stays readable until the switch): they are written there and the new header is returned, not written. The caller syncs the file, then commit_header — the 128-byte header is the one commit point, so a crash before it leaves the old file whole. A card equal to the current one stays where it is (only the record moves; the content hash does not change). Ok(None) when the pair does not fit: the caller copies instead (rewrite_card_stream).
replace_card
Replace the card (and the build record) of a 0x06 image held in memory: the front is re-laid out with the new card region; every section is copied byte for byte. The content hash follows the card.
rewrite_card_stream
Rewrite a 0x06 file read through src into out with a new card and build record — replace_card without holding the file: the front is re-laid out around the new card region, the data region copied byte for byte (its digests, and so the root, unchanged). progress receives the data bytes copied so far.
stamp_card_version
A card written into a 0x06 file says "format_version":6. The cards the core builders derive stamp the 0x05 layout they were produced for (LEGACY_FORMAT_VERSION); every card entering a 0x06 file passes here, so a build, a converted build and a re-card agree on the stamp. Only the first compact "format_version":N with N below 6 is rewritten; anything else is returned unchanged.