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

krl_reorder_2_vector

Interface Definition

int krl_reorder_2_vector(const KRLDistanceHandle* kdh, int64_t base_k, float* base_dis, int64_t* base_idx, const float* query_vector, int64_t k, float* dis, int64_t* idx, size_t query_vector_size);

Function

Computes high-accuracy distances between a single query vector and multiple non-contiguous base vectors, and returns the results sorted by distance.

Parameters

Parameter

Data Type

Description

Value Range

kdh

const KRLDistanceHandle*

Pointer to a KRLDistanceHandle instance.

The value cannot be null. This instance is initialized by krl_create_reorder_handle.

base_k

int64_t

The number of candidate base vectors selected by a low-accuracy retrieval algorithm.

It falls within [k, codes_num], where codes_num is the number of base vectors.

base_dis

float*

Low-accuracy distance obtained using the low-accuracy retrieval algorithm.

The size is specified by base_k.

base_idx

int64_t*

ID of the candidate point obtained using the low-accuracy retrieval algorithm.

The size is specified by base_k. It falls within [-1, codes_num]. The IDs increase monotonically. If a placeholder value of -1 is used to indicate positions that should not be computed, those entries must be placed at the end of the vector array.

query_vector

const float*

Query vector data.

The size is specified by query_vector_size.

k

int64_t

The number of the nearest neighbors to return after computation.

It falls within [1, base_k].

dis

float*

Stores the computed distances between the query vector and its nearest neighbors.

The value is specified by k. The memory needs to be allocated in advance.

idx

int64_t*

Stores IDs of the nearest neighbors.

The value is specified by k. The memory needs to be allocated in advance.

query_vector_size

size_t

Size of the query vector array.

The value is specified by dim, the vector dimension.

Return Values

Data Type

Description

int

0 is returned on successful execution. In case of failure, an error code is returned to indicate the specific issue: