GetPQDistance

API definition

int GetPQDistance(const uint8_t *basecode, const DiskPQParams *params, const float *pqDistanceTable, float &pqDistance);

Function

Calculates the PQ distance between a query and a base vector based on the compressed code pointed to by basecode and pqDistanceTable obtained via the GetPQDistanceTable API.

Input

const uint8_t *basecode: pointer to the compressed code for one base vector.

const DiskPQParams *params: pointer to a DiskPQParams instance with the pqChunks value populated. It cannot be a null pointer.

const float *pqDistanceTable: pointer to the ADC PQ distance table corresponding to the query.

Output

float &pqDistance: reference value of the final PQ distance.

Return value

int: The return value 0 indicates a normal process; and -1 indicates an abnormal process, with error details output to cerr.

Restrictions

  • Ensure that the size of the data pointed to by basecode is at least pqChunks bytes.
  • In params, only the value of pqChunks needs to be populated, which corresponds to the value of pqChunks in basecode.
  • Ensure that the size of the data to which pqDistanceTable points is at least pqChunks × 256 × sizeof(float) bytes.
  • The API does not set pqDistance to 0 before use. The final value of pqDistance is its original value plus the PQ distance between the output query and base code. Therefore, the recommended input value is 0.