MultiSearch

API定义

APP_ERROR MultiSearch(std::vector<AscendIndexVStar*>& indexes, const AscendIndexSearchParams& params, bool merge) const;

功能描述

实现从多个AscendIndexVStar库执行特征向量查询的接口,根据输入的特征向量返回最相似的topK条特征距离及ID。

输入

std::vector<AscendIndexVStar*>& indexes:待执行检索的多个Index。

const AscendIndexSearchParams& params:检索参数,具体请参见12.5.13.6-AscendIndexSearchParams

size_t n:查询的特征向量的条数。

std::vector<float>& queryData:特征向量数据。

int topK:需要返回的最近似的结果个数。

bool merge:是否需要合并多个Index上执行检索的结果

输出

std::vector<float>& dists:查询向量与距离最近的前“topK”个向量间的距离值。

std::vector<int64_t>& labels:查询的距离最近的前“topK”个向量的ID。

返回值

APP_ERROR:调用返回状态,具体请参见接口调用返回值参考

约束说明

  • n∈(0,10000],需保证n * dim * sizeof(float)小于卡的剩余内存,否则可能内存不足导致检索失败。
  • queryData:长度应该大于等于n * dim。
  • topK∈(0,4096]。
  • dists、labels满足:
    • 当merge = true,长度应该大于等于n * topK。
    • 当merge = false,长度应该大于等于indexes.size() * n * topK。
  • “indexes”需满足:0 < indexes.size() ≤ 150