Skip to main content

Module indexing

Module indexing 

Source
Expand description

Flat spatial index with brute-force nearest-neighbour and radius search.

Supports Euclidean, Manhattan, and Cosine distance metrics. Designed as a lightweight, dependency-free baseline that can be swapped for an HNSW implementation when the dataset outgrows brute-force search.

§Optimizations

  • Points stored in a flat Vec<f32> buffer (stride = dimensions) for cache locality and zero per-point heap allocation.
  • Euclidean kNN uses squared distances for comparison, deferring the sqrt to only the final k results.
  • Cosine distance computed in a single fused loop (dot, norm_a, norm_b).

Structs§

SpatialIndex
A flat spatial index that stores points in a contiguous f32 buffer.

Enums§

IndexError
Errors returned by SpatialIndex operations.