Skip to main content

Module global

Module global 

Source
Expand description

Single global HNSW per index per dense_vector field.

Per [[global-vector-indices]] Alternative B: vector indexes decouple from the segment model. Every dense_vector field gets one HNSW graph for the whole index, not one per segment.

  • Write: GlobalHnsw::add_vector appends a vector to the field’s HNSW builder and records the (segment_id, local_doc_id) the vector was attached to, so kNN hits can be returned in the segment-local doc-id space the rest of the engine speaks.
  • Read: GlobalHnsw::search runs HNSW once and returns hits as (segment_id, doc_id, distance). The bound query buckets by segment so each SegmentReader-scoped scorer sees only the docs in its own segment. A lazily-built HnswIndex cache services each search; the cache is invalidated on every mutation.
  • Persistence: GlobalHnsw::field_to_bytes / [load_field] serialize one field’s graph + resolver at a time. The bytes are stored in their own file extent via the storage layer’s write_vector_index API rather than in user_metadata.

Structs§

GlobalHit
Result of a global kNN search: which segment owns the hit, the per-segment doc_id, and the raw HNSW distance.
GlobalHnsw
One global HNSW graph per dense_vector field in the schema.