SearchByThreshold
API定义 |
APP_ERROR SearchByThreshold(int n, const float16_t *queries, float threshold, int topk, int *num, idx_t *indices, float *distances, unsigned int tableLen = 0, const float *table = nullptr); |
---|---|
功能描述 |
在Search的基础上增加了阈值筛选,只返回满足阈值条件的结果,如传递有效的映射表(tableLen>0且*table为非空指针),则返回映射后的topk结果。 |
输入 |
int n:待查询特征向量的数目。 const float16_t *queries:待查询特征向量,长度为 n * dim。 float threshold:用于过滤的阈值,接口不做值域范围约束,如果传递拉伸表进行映射,则该接口先将距离映射为score,然后再按照“threshold”进行过滤。 int topk:query和底库的比对距离进行排序,返回“topk”条结果。 unsigned int tableLen:映射表长度,默认值为0,表示不做映射。目前支持配置映射表长为“10000”。 const float *table:映射表指针,指向“tableLen”长度的有效映射值存储空间,目前支持的冗余长度为“48”,即“*table”指向的空间长度为 10048 * sizeof(float) Byte。 |
输出 |
int *num:每条待查询特征向量满足阈值条件的底库向量数量,长度为n。 idx_t *indices:满足阈值条件的底库向量下标索引,每个query从前往后记录符合条件的距离,然后按“topk”补齐占用空间,“indices”总长度为n * topk。 float *distances:满足阈值条件的底库向量与待查向量距离,记录方式和长度与“indices”相同。 |
返回值 |
APP_ERROR:调用返回状态,具体请参见接口调用返回值参考。 |
约束说明 |
|