HnswIndex

View as Markdown

Java package: com.nvidia.cuvs

1public interface HnswIndex extends AutoCloseable

HnswIndex encapsulates a HNSW index, along with methods to interact with it.

Public Members

close

1@Override void close() throws Exception

Invokes the native destroy_hnsw_index to de-allocate the HNSW index

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/HnswIndex.java:21

1SearchResults search(HnswQuery query) throws Throwable

Invokes the native search_hnsw_index via the Panama API for searching a HNSW index.

Parameters

NameDescription
queryan instance of HnswQuery holding the query vectors and other parameters

Returns

an instance of SearchResults containing the results

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/HnswIndex.java:32

newBuilder

1static HnswIndex.Builder newBuilder(CuVSResources cuvsResources)

Creates a new Builder with an instance of CuVSResources.

Parameters

NameDescription
cuvsResourcesan instance of CuVSResources

Throws

TypeDescription
UnsupportedOperationExceptionif the provider does not cuvs

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/HnswIndex.java:40

fromCagra

1static HnswIndex fromCagra(HnswIndexParams hnswParams, CagraIndex cagraIndex) throws Throwable

Creates an HNSW index from an existing CAGRA index.

Parameters

NameDescription
hnswParamsParameters for the HNSW index
cagraIndexThe CAGRA index to convert from

Returns

A new HNSW index

Throws

TypeDescription
Throwableif an error occurs during conversion

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/HnswIndex.java:53

build

1static HnswIndex build(CuVSResources resources, HnswIndexParams hnswParams, CuVSMatrix dataset) throws Throwable

Builds an HNSW index using the ACE (Augmented Core Extraction) algorithm.

ACE enables building HNSW indexes for datasets too large to fit in GPU memory by partitioning the dataset and building sub-indexes for each partition independently.

NOTE: This method requires hnswParams.getAceParams() to be set with an instance of HnswAceParams.

Parameters

NameDescription
resourcesThe CuVS resources
hnswParamsParameters for the HNSW index with ACE configuration
datasetThe dataset to build the index from

Returns

A new HNSW index ready for search

Throws

TypeDescription
Throwableif an error occurs during building

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/HnswIndex.java:75

from

1Builder from(InputStream inputStream)

Sets an instance of InputStream typically used when index deserialization is needed.

Parameters

NameDescription
inputStreaman instance of InputStream

Returns

an instance of this Builder

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/HnswIndex.java:96

withIndexParams

1Builder withIndexParams(HnswIndexParams hnswIndexParameters)

Registers an instance of configured HnswIndexParams with this Builder.

Parameters

NameDescription
hnswIndexParametersAn instance of HnswIndexParams.

Returns

An instance of this Builder.

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/HnswIndex.java:105

build

1HnswIndex build() throws Throwable

Builds and returns an instance of CagraIndex.

Returns

an instance of CagraIndex

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/HnswIndex.java:112

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/HnswIndex.java:17