ComputeDistanceByThreshold
This API must be used together with AddFeatures(int n, const float *features, const uint32_t *indices).
API definition |
APP_ERROR ComputeDistanceByThreshold(const std::vector<uint32_t> &queryIdxArr, uint32_t codeStartIdx, uint32_t codeNum, float threshold, bool aboveFilter, std::vector<std::vector<float>> &resDistArr, std::vector<std::vector<uint32_t>> &resIdxArr); |
|---|---|
Function |
Queries the distance between a specified number of feature vectors and designated vectors in the database, filters out calculated distances based on the threshold, and returns the distances and labels that meet the conditions. |
Input |
const std::vector<uint32_t> &queryIdxArr: ID of the query vector in the database. uint32_t codeStartIdx: ID of the starting position where distance is to be calculated. uint32_t codeNum: number of base vectors whose distances are to be calculated. float threshold: threshold used for filtering. Distances smaller than the threshold are filtered out. bool aboveFilter: reserved. |
Output |
std::vector<std::vector<float>> &resDistArr: returned two-dimensional array, indicating the distance between each query vector and the base vector that meets the threshold condition. std::vector<std::vector<uint32_t>> &resIdxArr: returned two-dimensional array, indicating the label between each query vector and the base vector that meets the threshold condition. |
Return value |
APP_ERROR: return status. For details, see Return Code Reference. |
Restrictions |
|