Skip to main content

BruteForceIndex

Struct BruteForceIndex 

Source
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>

Source

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.

Source

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.

Source

pub fn rows(&self) -> usize

Source

pub fn columns(&self) -> usize

Source

pub fn close(self) -> Result<()>

Reports native destruction errors; failed destruction is retried on drop.

Trait Implementations§

Source§

impl Debug for BruteForceIndex<'_>

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for BruteForceIndex<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'data> !RefUnwindSafe for BruteForceIndex<'data>

§

impl<'data> !Send for BruteForceIndex<'data>

§

impl<'data> !Sync for BruteForceIndex<'data>

§

impl<'data> !UnwindSafe for BruteForceIndex<'data>

§

impl<'data> Freeze for BruteForceIndex<'data>

§

impl<'data> Unpin for BruteForceIndex<'data>

§

impl<'data> UnsafeUnpin for BruteForceIndex<'data>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.