Skip to main content

Module index_loader

Module index_loader 

Source
Expand description

Range-GET fast path: load just the HNSW/IVF-PQ index of a file’s primary vector column, without ever downloading the tabular/vector data section. Used by scanner.rs::search_one_file when the query needs nothing else from the file (no rerank, hybrid, score_fn, equality deletes, or column_filter — see Fase 16 in CLAUDE.md).

Offset discovery reads the ailake.footer_offset Parquet KV entry (via ailake_parquet::ParquetVectorReader::kv_metadata) from a speculative tail get_range of just the footer thrift, with an exact one-shot follow-up on the rare miss — never the whole file. This is the KV path, not AilakeFileReader’s AilakeTrailer bootstrap fallback: multi-column files (AilakeFileWriter::write_multi) write one self-pointing AilakeTrailer per column section, so the trailer physically nearest EOF belongs to whichever column was written last — not necessarily the primary one. The KV entry has no such ambiguity: write_multi always tags column 0 (primary) with the plain ailake.footer_offset key regardless of how many columns follow it.

The AILK header and HNSW blob are sliced straight out of the same speculative tail buffer whenever they happen to fall inside it (common for small-to-medium files, or any file where the AILK section is smaller than the tail window) instead of issuing separate get_range calls — without this, those calls would frequently re-fetch bytes the tail read already has, since the tail window’s whole purpose is landing on the footer thrift, which sits immediately after the AILK section.

Only the primary column is supported — a secondary/multimodal column’s offset lives behind ailake.<col>.footer_offset instead, and this module doesn’t thread a column name through the request, since callers already gate on vector_column == primary_col before invoking it (see scanner.rs::search_one_file).

Every failure here (parse error, missing KV, out-of-range GET) is recoverable by the caller falling back to the existing full-file GET — this module never turns a query that would have succeeded into one that fails; at worst it wastes one or two small extra get_range calls.

Functions§

load_primary_index
Loads the primary column’s HNSW/IVF-PQ index via small get_range calls (footer-thrift discovery, 64-byte AILK header, index blob) instead of one whole-file get. Returns Err for any file this fast path can’t handle — callers must treat that as “use the full-file path”, not as a hard failure.