pub struct SparseSource { /* private fields */ }Expand description
The sparse arena, its index and the reference-walk state.
Implementations§
Source§impl SparseSource
impl SparseSource
Sourcepub fn new(preamble: Vec<u8>) -> Self
pub fn new(preamble: Vec<u8>) -> Self
Start from a preamble: the file’s HEADER followed by the records every
worker needs (see build_sparse_preamble).
Sourcepub fn with_reserve(preamble: Vec<u8>, reserve_bytes: usize) -> Self
pub fn with_reserve(preamble: Vec<u8>, reserve_bytes: usize) -> Self
Self::new, reserving reserve_bytes of arena up front.
Without a reservation the arena grows by doubling, and each growth holds the old and the new block at once: measured on a single worker, the wasm heap high-water was 2 to 5 times the arena. Reserved once, the arena never moves until it outgrows the reservation, and a reset keeps the block. Pages that are never written cost address space only.
Sourcepub fn set_inverse_edges(&mut self, targets: &[u32], referrers: &[u32])
pub fn set_inverse_edges(&mut self, targets: &[u32], referrers: &[u32])
Declare inverse edges: referrers[i] references targets[i] and must
be installed whenever the target is walked. Order is preserved per
target, so file-order precedence among referrers survives.
pub fn bytes(&self) -> Arc<Vec<u8>>
pub fn index(&self) -> Arc<SparseIndex>
pub fn stats(&self) -> SparseStats
pub fn contains(&self, id: u32) -> bool
Sourcepub fn expand(&mut self, ids: &[u32], max_depth: u32, missing: &mut Vec<u32>)
pub fn expand(&mut self, ids: &[u32], max_depth: u32, missing: &mut Vec<u32>)
Walk references from ids through the installed records and append
every id that is needed and not installed to missing (deduplicated,
ascending). After installing them, walk again from those ids.
A full walk (max_depth == u32::MAX) expands each record once per
arena lifetime, so later calls only pay for what was installed since.
A depth-limited walk follows at most max_depth reference hops and
keeps no state, so it never hides a record from a later full walk.
Sourcepub fn install(&mut self, spans: &[(u32, usize, usize)], chunk: &[u8])
pub fn install(&mut self, spans: &[(u32, usize, usize)], chunk: &[u8])
Append records. spans holds (id, offset, length) into chunk; each
record is copied with a trailing newline. An id already installed is
skipped (the first copy stays authoritative).
Sourcepub fn mark_absent(&mut self, ids: &[u32])
pub fn mark_absent(&mut self, ids: &[u32])
Ids the file does not hold (dangling references): never reported again.
Sourcepub fn take_misses(&self) -> Vec<u32>
pub fn take_misses(&self) -> Vec<u32>
Lookups that missed since the last call, without the ids already known to be absent from the file.