GetPQDistanceTable

API definition

int GetPQDistanceTable(char *vec, const DiskPQParams *params, float *pqDistanceTable);

Function

Uses params populated with PQ data to calculate the ADC PQ distance of the query data to which vec points, and writes the PQ distance table to the buffer to which pqDistanceTable points.

Input

char *vec: pointer to the query data to be calculated.

const DiskPQParams *params: pointer to a DiskPQParams instance populated with PQ parameters and trained PQ data. It cannot be a null pointer.

Output

float *pqDistanceTable: pointer to the returned distance between the query and each centroid in each chunk.

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 space to which vec points is at least dim × sizeof(float) bytes. Only the float data type is supported, that is, the openGauss vector data type.
  • Population requirements on params:
    • There is no requirement on the data to which pqTable points.
    • offsets must point to the offsets data with memory size of (pqChunks + 1) × sizeof(uint32_t) bytes. Ensure that the size of the memory to which the pointer points meets the requirements. Otherwise, a segment error may occur.
    • tablesTransposed must point to the codebook data with memory size of dim × 256 × sizeof(float) bytes. Ensure that the size of the memory to which the pointer points meets the requirements. Otherwise, a segment error may occur.
    • centroids must point to the centroids data with memory size of dim × sizeof(float) bytes. Ensure that the size of the memory to which the pointer points meets the requirements. Otherwise, a segment error may occur.
  • Ensure that the size of the space to which pqDistanceTable points is at least pqChunks × 256 × sizeof(float) bytes.