Module sparse_source

Module sparse_source 

Source
Expand description

Out-of-core source: a decoder’s content that holds only the records a worker has needed so far, instead of the whole file.

The arena is itself a valid STEP file: the original HEADER, then a subset of the DATA records in the order they were installed. Every reader that takes content: &[u8] therefore works on it unchanged, and a reader that scans by type sees the subset that was installed. The host fetches records by byte range (a File slice, an OPFS handle, a shared buffer) and installs them here; SparseSource::expand names the records a set of roots still needs by walking #id references through what is already present.

A lookup of an id that is not installed is recorded (SparseIndex::take_misses), so a reference the forward walk cannot see (an inverse relation the caller did not declare) is detected rather than silently read as “entity not found”.

Structs§

SparseIndex
Id to arena span, with a record of every id asked for and not found.
SparseSource
The sparse arena, its index and the reference-walk state.
SparseStats
Counters for the host’s budget decision and for the report.

Functions§

build_sparse_preamble
Build the preamble every sparse worker starts from: the bytes before the first DATA record (the HEADER, which declares the schema), the closure roots with every record they reference, and the records roots alone, all in file order. lookup resolves an id to its span in content.
for_each_record_ref
Call visit with every #id reference in one STEP record’s attribute list. Quoted strings and /* */ comments are skipped; the record’s own #id= is not reported. A reference wider than u32 is ignored, as the decoder refuses it anyway.