Skip to content

Commit

Permalink
update to latest 24.04 cagra api
Browse files Browse the repository at this point in the history
  • Loading branch information
benfred committed Mar 4, 2024
1 parent b3a9624 commit 3eec2c3
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion rust/cuvs-sys/cuvs_c_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
// wrapper file containing all the C-API's we should automatically be creating rust
// bindings for
#include <cuvs/core/c_api.h>
#include <cuvs/neighbors/cagra_c.h>
#include <cuvs/neighbors/cagra.h>
6 changes: 3 additions & 3 deletions rust/cuvs-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ mod tests {
#[test]
fn test_create_cagra_index() {
unsafe {
let mut index = core::mem::MaybeUninit::<cagraIndex_t>::uninit();
let mut index = core::mem::MaybeUninit::<cuvsCagraIndex_t>::uninit();
assert_eq!(
cagraIndexCreate(index.as_mut_ptr()),
cuvsCagraIndexCreate(index.as_mut_ptr()),
cuvsError_t::CUVS_SUCCESS
);
let index = index.assume_init();
assert_eq!(cagraIndexDestroy(index), cuvsError_t::CUVS_SUCCESS);
assert_eq!(cuvsCagraIndexDestroy(index), cuvsError_t::CUVS_SUCCESS);
}
}

Expand Down
12 changes: 6 additions & 6 deletions rust/cuvs/src/cagra/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::error::{check_cuvs, Result};
use crate::resources::Resources;

#[derive(Debug)]
pub struct Index(ffi::cagraIndex_t);
pub struct Index(ffi::cuvsCagraIndex_t);

impl Index {
/// Builds a new index
Expand All @@ -34,16 +34,16 @@ impl Index {
let dataset: ManagedTensor = dataset.into();
let index = Index::new()?;
unsafe {
check_cuvs(ffi::cagraBuild(res.0, params.0, dataset.as_ptr(), index.0))?;
check_cuvs(ffi::cuvsCagraBuild(res.0, params.0, dataset.as_ptr(), index.0))?;
}
Ok(index)
}

/// Creates a new empty index
pub fn new() -> Result<Index> {
unsafe {
let mut index = core::mem::MaybeUninit::<ffi::cagraIndex_t>::uninit();
check_cuvs(ffi::cagraIndexCreate(index.as_mut_ptr()))?;
let mut index = core::mem::MaybeUninit::<ffi::cuvsCagraIndex_t>::uninit();
check_cuvs(ffi::cuvsCagraIndexCreate(index.as_mut_ptr()))?;
Ok(Index(index.assume_init()))
}
}
Expand All @@ -57,7 +57,7 @@ impl Index {
distances: &ManagedTensor,
) -> Result<()> {
unsafe {
check_cuvs(ffi::cagraSearch(
check_cuvs(ffi::cuvsCagraSearch(
res.0,
params.0,
self.0,
Expand All @@ -71,7 +71,7 @@ impl Index {

impl Drop for Index {
fn drop(&mut self) {
if let Err(e) = check_cuvs(unsafe { ffi::cagraIndexDestroy(self.0) }) {
if let Err(e) = check_cuvs(unsafe { ffi::cuvsCagraIndexDestroy(self.0) }) {
write!(stderr(), "failed to call cagraIndexDestroy {:?}", e)
.expect("failed to write to stderr");
}
Expand Down
2 changes: 1 addition & 1 deletion rust/cuvs/src/cagra/index_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::error::{check_cuvs, Result};
use std::fmt;
use std::io::{stderr, Write};

pub type BuildAlgo = ffi::cagraGraphBuildAlgo;
pub type BuildAlgo = ffi::cuvsCagraGraphBuildAlgo;

/// Supplemental parameters to build CAGRA Index
pub struct IndexParams(pub ffi::cuvsCagraIndexParams_t);
Expand Down
4 changes: 2 additions & 2 deletions rust/cuvs/src/cagra/search_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use crate::error::{check_cuvs, Result};
use std::fmt;
use std::io::{stderr, Write};

pub type SearchAlgo = ffi::cagraSearchAlgo;
pub type HashMode = ffi::cagraHashMode;
pub type SearchAlgo = ffi::cuvsCagraSearchAlgo;
pub type HashMode = ffi::cuvsCagraHashMode;

/// Supplemental parameters to search CAGRA index
pub struct SearchParams(pub ffi::cuvsCagraSearchParams_t);
Expand Down

0 comments on commit 3eec2c3

Please sign in to comment.