Skip to main content

spatial_prefilter

Function spatial_prefilter 

Source
pub fn spatial_prefilter(
    rtree: &RTree,
    query_geometry: &Geometry,
    distance_meters: Option<f64>,
    exact_geometries: &dyn Fn(u64) -> Option<Geometry>,
    governor: Option<&Arc<MemoryGovernor>>,
) -> SpatialPreFilterResult
Expand description

Execute the spatial pre-filter phase.

  1. Compute search bounding box from query geometry + optional distance expansion
  2. R-tree range search → rough candidates
  3. For each candidate, load geometry and apply exact predicate
  4. Return filtered entry IDs

The caller (vector engine) uses the candidate IDs to build a RoaringBitmap that restricts HNSW graph traversal.

When governor is Some, the candidate_ids allocation is budgeted via MemoryGovernor::reserve before the Vec::with_capacity. Budget pressure is a backpressure signal; the allocation still proceeds on budget exhaustion.