BruteForceQuery

View as Markdown

Java package: com.nvidia.cuvs

1public class BruteForceQuery

BruteForceQuery holds the query vectors to be used while invoking search.

Thread Safety: Each BruteForceQuery instance should use its own CuVSResources object that is not shared with other threads. Sharing CuVSResources between threads can lead to memory allocation errors or JVM crashes.

Public Members

BruteForceQuery

1public BruteForceQuery( float[][] queryVectors, LongToIntFunction mapping, int topK, BitSet[] prefilters, int numDocs, CuVSResources resources)

Constructs an instance of BruteForceQuery using queryVectors, mapping, and topK.

Parameters

NameDescription
queryVectors2D float query vector array
mappinga function mapping ordinals (neighbor IDs) to custom user IDs
topKthe top k results to return
prefiltersthe prefilters data to use while searching the BRUTEFORCE index
numDocsMaximum of bits in each prefilter, representing number of documents in this index. Used only when prefilter(s) is/are passed.
resourcesCuVSResources instance to use for this query

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceQuery.java:42

getQueryVectors

1public float[][] getQueryVectors()

Gets the query vector 2D float array.

Returns

2D float array

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceQuery.java:62

getMapping

1public LongToIntFunction getMapping()

Gets the function mapping ordinals (neighbor IDs) to custom user IDs

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceQuery.java:69

getTopK

1public int getTopK()

Gets the topK value.

Returns

an integer

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceQuery.java:78

getPrefilters

1public BitSet[] getPrefilters()

Gets the prefilter long array

Returns

an array of bitsets

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceQuery.java:87

getNumDocs

1public int getNumDocs()

Gets the number of documents supposed to be in this index, as used for prefilters

Returns

number of documents as an integer

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

getResources

1public CuVSResources getResources()

Gets the CuVSResources instance for this query.

Returns

the CuVSResources instance

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

Builder

1public Builder(CuVSResources resources)

Constructor that requires CuVSResources.

Important: The provided CuVSResources instance should not be shared with other threads. Each thread performing searches should create its own CuVSResources instance to avoid memory allocation conflicts and potential JVM crashes.

Parameters

NameDescription
resourcesthe CuVSResources instance to use for this query (must not be shared between threads)

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceQuery.java:143

withQueryVectors

1public Builder withQueryVectors(float[][] queryVectors)

Registers the query vectors to be passed in the search call.

Parameters

NameDescription
queryVectors2D float query vector array

Returns

an instance of this Builder

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceQuery.java:153

withMapping

1public Builder withMapping(LongToIntFunction mapping)

Sets the function used to map ordinals (neighbor IDs) to custom user IDs

Parameters

NameDescription
mappinga function mapping ordinals (neighbor IDs) to custom user IDs

Returns

an instance of this Builder

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceQuery.java:164

withTopK

1public Builder withTopK(int topK)

Registers the topK value.

Parameters

NameDescription
topKthe topK value used to retrieve the topK results

Returns

an instance of this Builder

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceQuery.java:175

withPrefilters

1public Builder withPrefilters(BitSet[] prefilters, int numDocs)

Sets the prefilters data for building the BruteForceQuery.

Parameters

NameDescription
prefiltersarray of bitsets, as many as queries, each containing as many bits as there are vectors in the index

Returns

an instance of this Builder

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceQuery.java:187

build

1public BruteForceQuery build()

Builds an instance of BruteForceQuery

Returns

an instance of BruteForceQuery

Source: java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceQuery.java:198

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