我要评分
获取效率
正确性
完整性
易理解

Search

API Definition

int Search(int n, const float *x, int k, float *distances, int64_t *labels, int num_thread);

Function

Searches for a graph.

Parameters

Parameter

Description

Data Type

Value Range

n

Data volume.

int

≥ 1. It is recommended that the value be less than 1 billion.

x

Data.

const float *

The value cannot be null. The expected length is n × K_features (Data volume × Feature dimension).

k

Number of nearest neighbors.

int

[1, n], where n indicates the data volume.

distances

Distance array.

float *

The value cannot be null. The expected length is n × K_features.

labels

ID array of the search result.

int64_t *

The value cannot be null. The expected length is n × K_features.

num_thread

Number of threads used for search.

int

[1,std::thread::hardware_concurrency()], where std::thread::hardware_concurrency() indicates the number of concurrent threads supported by the current system.

Return Value

Data Type

Description

int

If the parameter value is not within the value range, −1 is returned. If this API is called before calling BuildSearcher or Load/Deserialize/LoadGraph, −1 is returned. Otherwise, 0 is returned.