ComputePQTable

API definition

int ComputePQTable(VectorArrayData *sample, DiskPQParams *params);

Function

Calculates the PQ codebook based on the sampling data stored in sample and stores the codebook-related data in params.

Input

VectorArrayData *sample: pointer to a VectorArrayData instance populated with sampling data. It cannot be a null pointer.

DiskPQParams *params: pointer to the DiskPQParams instance that contains only PQ parameters and does not pad the trained PQ data. It cannot be a null pointer.

Output

N/A

Return value

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

Restrictions

  • The requirements for filling sample are as follows:

    The size of the data pointed to by items is (8 + dim) × length × sizeof(float) bytes. That is, each vector has 8-byte metadata. For non-openGauss users, add any 8-byte data to each vector.

  • The requirements for filling params are as follows:
    • In addition to the preceding restrictions, ensure that the value of dim is the same as that of the dim field in sample.
    • pqTable must be nullptr. The new [] keyword is used for internal memory allocation in the dynamic library, and delete [] is used to release the allocated memory externally. Ensure that the size of the memory allocated internally is equal to dim × 256 (number of clusters in each chunk) × sizeof(float) bytes.
    • offsets must be nullptr. The new [] keyword is used for internal memory allocation in the dynamic library, and delete [] is used to release the allocated memory externally. Ensure that the size of the memory allocated internally is equal to (pqChunks + 1) × sizeof(uint32_t) bytes.
    • tablesTransposed must be nullptr. The new [] keyword is used for internal memory allocation in the dynamic library, and delete [] is used to release the allocated memory externally. Ensure that the size of the memory allocated internally is equal to dim × 256 × sizeof(float) bytes.
    • centroids must be nullptr. The new [] keyword is used for internal memory allocation in the dynamic library, and delete [] is used to release the allocated memory externally. Ensure that the size of the memory allocated internally is equal to dim × sizeof(float) bytes.