pub unsafe extern "C" fn cuvsHnswSerialize(
res: cuvsResources_t,
filename: *const c_char,
index: cuvsHnswIndex_t,
) -> cuvsError_tExpand description
@brief Serialize a CAGRA index to a file as an hnswlib index
NOTE: When hierarchy is NONE, the saved hnswlib index is immutable and can only be read by
the hnswlib wrapper in cuVS, as the serialization format is not compatible with the original
hnswlib. However, when hierarchy is CPU, the saved hnswlib index is compatible with the
original hnswlib library.
@param[in] res cuvsResources_t opaque C handle @param[in] filename the name of the file to save the index @param[in] index cuvsHnswIndex_t to serialize @return cuvsError_t
@code{.c} #include <cuvs/core/c_api.h> #include <cuvs/neighbors/cagra.h> #include <cuvs/neighbors/hnsw.h>
// Create cuvsResources_t cuvsResources_t res; cuvsError_t res_create_status = cuvsResourcesCreate(&res);
// create an index with cuvsCagraBuild
// Convert the CAGRA index to an HNSW index cuvsHnswIndex_t hnsw_index; cuvsHnswIndexCreate(&hnsw_index); cuvsHnswIndexParams_t hnsw_params; cuvsHnswIndexParamsCreate(&hnsw_params); cuvsHnswFromCagra(res, hnsw_params, cagra_index, hnsw_index);
// Serialize the HNSW index cuvsHnswSerialize(res, “/path/to/index”, hnsw_index);
// de-allocate hnsw_params, hnsw_index and res
cuvsError_t hnsw_params_destroy_status = cuvsHnswIndexParamsDestroy(hnsw_params);
cuvsError_t hnsw_index_destroy_status = cuvsHnswIndexDestroy(hnsw_index);
cuvsError_t res_destroy_status = cuvsResourcesDestroy(res);
@endcode