Skip to main content

with_vector_scan

Function with_vector_scan 

Source
pub fn with_vector_scan<R>(enabled: bool, f: impl FnOnce() -> R) -> R
Expand description

Run f with the full-scan candidate path forced on or off, whatever MUSHROOMDB_VECTOR_SCAN says. Test hook, in the shape of with_hnsw_build_batch.

The override is thread-local, so f must do its work on the calling thread.

§The engine outlives the closure

This switches which candidate spec a rule is asked for, and several decisions are taken once and remembered: a rule created inside the closure with the scan forced on builds no HNSW graph, so using that same engine outside the closure leaves the rule answering from hnsw_tracked — correct, and a full scan — until something rebuilds it. Either keep the engine inside the closure, as the equivalence test does, or reopen the store afterwards.