Skip to main content

Module segments

Module segments 

Source
Expand description

Segment read/write helpers for the Lite array engine.

On pagedb-backed storage (as_array_segment_ext() returns Some), tile data is stored in pagedb encrypted segments under arr/tile/{name}/{id}. On WASM (where as_array_segment_ext() returns None), the legacy KV blob path is used: bytes stored in the Array namespace under segment:{name}:{id}.

The on-disk bytes are identical in both paths — the exact output of nodedb_array::SegmentWriter::finish(), which includes the header, tile frames, and footer. SegmentReader::open can parse them directly.

Functions§

collect_tile_versions_across_segments
Collect all live cells from all segments for the given hilbert_prefix at or before system_as_of — used by array_slice.
delete_segment
Delete the segment for seg_id from storage.
iter_cell_versions_across_segments
Collect all tile versions for hilbert_prefix at or before system_as_of across all segments, filtering to cells at coord. Returns raw cell bytes for each (TileId, cell_bytes) pair compatible with the ceiling resolver.
load_segment
Load segment bytes for seg_id.
open_reader
Open a SegmentReader over the given byte slice.
rewrite_segment
Compile a new merged segment from the provided (TileId, SparseTile) list and persist it, then delete the old segments.
tile_versions_from_bytes
Read all decoded cells matching hilbert_prefix at or before system_as_of from a single segment’s bytes (already loaded). Returns (TileId, TilePayload).
write_segment
Flush a batch of (TileId, SparseTile) pairs into a new segment and persist the bytes.