Neighbors Cagra Index Module
Rust module: cuvs::neighbors::cagra::index
Source: rust/cuvs/src/neighbors/cagra/index.rs
Index
A CAGRA approximate nearest neighbor index.
The lifetime 'd ties this index to the underlying dataset,
passed at construction time. The C library may store a non-owning view
of properly aligned device-resident data, so the dataset must outlive
the index. When an index is deserialized from disk, the data is
self-contained and its lifetime is 'static.
Methods
build
Builds a CAGRA index over dataset for efficient search.
dataset is a row-major matrix on the host or device implementing
[AsDlTensor]. The C++ index keeps a non-owning
view of it, so the returned [Index] borrows dataset for 'd and
cannot outlive it.
Source: rust/cuvs/src/neighbors/cagra/index.rs:45
search
Searches the index for the k nearest neighbors of each query.
queries, neighbors, and distances must reside in device memory and
implement [AsDlTensor] /
[AsDlTensorMut]. neighbors (shape
n_queries × k) receives the neighbor indices and distances their
distances; both are written in place.
Source: rust/cuvs/src/neighbors/cagra/index.rs:77
search_filtered
Searches the index with a row-level bitset filter.
Source: rust/cuvs/src/neighbors/cagra/index.rs:97
serialize
Save the CAGRA index to file.
Experimental, both the API and the serialization format are subject to change.
Arguments
res- Resources to usefilename- The file path for saving the indexinclude_dataset- Whether to write out the dataset to the file
Example:
Source: rust/cuvs/src/neighbors/cagra/index.rs:174
serialize_to_hnswlib
Save the CAGRA index to file in hnswlib format.
NOTE: The saved index can only be read by the hnswlib wrapper in cuVS, as the serialization format is not compatible with the original hnswlib.
Experimental, both the API and the serialization format are subject to change.
Arguments
res- Resources to usefilename- The file path for saving the index
Source: rust/cuvs/src/neighbors/cagra/index.rs:198
deserialize
Load a CAGRA index from file.
Experimental, both the API and the serialization format are subject to change.
Arguments
res- Resources to usefilename- The path of the file that stores the index
Source: rust/cuvs/src/neighbors/cagra/index.rs:214
Source: rust/cuvs/src/neighbors/cagra/index.rs:27