RinhaDeBackend::Knn
Brute-force exact KNN over the quantized reference dataset. K = 5 makes an insertion-sorted StaticArray cheaper than a heap, and the inner distance loop early-exits the moment the partial L2² already exceeds the current 5th-best distance.
Two layout paths share this class:
-
Block path (
block_count > 0): walks the AOSOA-8 dim-interleaved blocks the IVF builder writes. Used by the runtime mmap loader (References.mmap) and any spec/tool that compares brute-force to IVF. -
Row path (
block_count == 0): walks the legacy row-majorvectorsslice produced byReferences.load_from_io. Only used by spec fixtures that loadexample-references.jsondirectly.
Constants
BLOCK_LANES = References::BLOCK_LANES
K = 5
LOGICAL_DIMS = References::LOGICAL_DIMS
SLOTS_PER_BLOCK = References::SLOTS_PER_BLOCK
Constructors
new(refs : References)
SourceInstance methods
Returns how many of the K nearest neighbors carry the "fraud" label.