Search (AscendIndexInt8)

API definition

void Search(std::vector<AscendIndexInt8 *> indexes, idx_t n, const int8_t *x, idx_t k, float *distances, idx_t *labels, bool merged);

Function

Queries the feature vectors for multiple AscendIndexInt8 libraries and returns the distance and IDs of the most similar k features based on the input feature vectors.

Currently, only the subtype AscendIndexInt8Flat derived from AscendIndexInt8 is supported.

Input

std::vector<AscendIndexInt8 *> indexes: multiple indexes to perform retrieval.

idx_t n: number of queries for retrieval.

const int8_t *x: query vectors for retrieval.

idx_t k: number of the most similar results to be returned.

bool merged: whether to merge the retrieval results of multiple indexes.

Output

float *distances: distance between a vector and the first k nearest vectors.

idx_t *labels: IDs of the first k nearest vectors that are queried.

Return value

N/A

Restrictions

  • Indexes involved in retrieval must be created on the same card.
  • Currently, indexes supports only the AscendIndexInt8 type and must meet the 0 < indexes.size() ≤ 10000 requirement.
  • The value of n cannot exceed 1024.
  • The value of k cannot exceed 1024.
  • x must be a non-null pointer with a length of dim × n. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.
  • distances and labels must be non-null pointers and meet the following requirements:
    • If merged is set to true, the length must be k × n. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.
    • If merged is set to false, the length must be indexes.size() × k × n. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.