Skip to main content

Module sparse

Module sparse 

Source
Expand description

The sparse.bin sidecar: one segment’s raw sparse vectors, row-addressed the same way data.bin’s dense matrix is. Written by compaction only when at least one document in the segment has one (crate::compaction); read whole by Namespace::index_sparse to build the inverted index, and by the query engine’s unindexed-segment fallback.

§Layout

All integers are little-endian.

SectionContents
Headermagic ITZS, format_version u32, rows u32
Directoryrows entries: term_count u16, byte_offset u64
Rowseach row’s term_count pairs of (term_id u32, weight f32)

Row i is document i of the same segment’s data.bin, in the ascending id order crate::layer::Layer::sorted_docs both objects are built from. A row with no sparse vector has term_count 0 and no bytes of its own.

Functions§

sparse_path
Object key of a segment’s sparse sidecar: <namespace>/segments/<id>/sparse.bin. Absent when no document in the segment has a sparse vector.