search_with_masks

API Definition

void search_with_masks(Index::idx_t n, const int8_t *x, Index::idx_t k, float *distances, Index::idx_t *labels, const void *mask) const

Function

Queries feature vectors of AscendIndexInt8, and returns the distance and IDs of the most similar k features based on the input feature vectors and mask. The mask is a bit string consisting of 0 and 1. Each bit indicates whether the feature of the corresponding sequence in the base library is involved in distance calculation. 1 indicates that it is involved, and 0 indicates that it is not involved.

Input

idx_t n: number of feature vectors to be queried.

const int8_t *x: feature vector data.

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

const void* mask: filter mask of the base library.

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

  • The value of n cannot be greater than 1e9.
  • The value of k cannot be greater than 1024.
  • The x must be a non-null pointer with a length of dim x n. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.
  • The distances and labels must be non-null pointers with a length of k x n. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.
  • The mask must be a non-null pointer.