Table of Contents

Class ReferenceDataStore

Namespace
RinhaBackend
Assembly
Api.dll

Immutable in-memory KNN store that holds ~3 million pre-indexed reference transactions. Vectors are stored as Half (float16) for memory efficiency (~87 MB per instance). On first load the source references.json.gz is converted to a compact binary cache (references.bin) so subsequent startups skip JSON parsing entirely.

public sealed class ReferenceDataStore : IReferenceDataStore
Inheritance
ReferenceDataStore
Implements
Inherited Members

Remarks

Internal layout: _vectors[i * Dim .. i * Dim + Dim - 1] = 14-dimensional vector for entry i. _labels[i] = 1 (fraud) or 0 (legit).

Methods

ComputeFraudScore(Span<float>)

Computes the fraud score for a normalized feature vector by running a KNN search. Returns a value in [0, 1]: the fraction of the K nearest neighbors labeled as fraud.

LoadAsync(string, CancellationToken)

Loads the reference store from dataDir. Prefers the binary cache (references.bin); falls back to references.json.gz and writes the cache on first use.