pub struct BruteForceIndex<'data> { /* private fields */ }Expand description
A brute-force index that retains the dataset borrow and exact runtime binding.
Implementations§
Source§impl<'data> BruteForceIndex<'data>
impl<'data> BruteForceIndex<'data>
Sourcepub fn build(
resources: &CuvsResources,
dataset: &ValidatedDeviceTensor<'data, f32>,
metric: DistanceMetric,
) -> Result<Self>
pub fn build( resources: &CuvsResources, dataset: &ValidatedDeviceTensor<'data, f32>, metric: DistanceMetric, ) -> Result<Self>
Builds an index over dataset, a contiguous row-major or column-major
matrix on the same exact runtime binding and CUDA device as resources.
The index borrows dataset for 'data and retains resources, so the
dataset memory stays valid until the index is closed or dropped. A
failed native build destroys the partial index before the error is
returned.
Sourcepub fn search_into(
&self,
queries: &ValidatedDeviceTensor<'_, f32>,
k: usize,
neighbors: &mut DeviceBuffer<i64>,
distances: &mut DeviceBuffer<f32>,
) -> Result<KnnSearchOutput>
pub fn search_into( &self, queries: &ValidatedDeviceTensor<'_, f32>, k: usize, neighbors: &mut DeviceBuffer<i64>, distances: &mut DeviceBuffer<f32>, ) -> Result<KnnSearchOutput>
Searches queries for their k nearest indexed rows and writes the
results into neighbors and distances.
k must be nonzero and at most the indexed row count. queries must
have the index’s column count and share its binding and device. Both
output buffers must contain exactly n_queries * k elements, laid out
as [n_queries, k] row-major. Success is returned only after the
native outputs pass validation on the buffers’ execution binding: every
neighbor index lies in 0..rows() and every distance is finite.