ComputeVectorPQCode

API definition

int ComputeVectorPQCode(VectorArrayData *baseData, const DiskPQParams *params, uint8_t *pqCode);

Function

Quantizes the base data by using params populated with PQ data, and writes the quantized data to the buffer to which pqCode points.

Input

VectorArrayData *baseData: pointer to an VectorArrayData instance populated with base data. It cannot be a null pointer. You can determine the size of the base data based on the memory limit.

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

Output

uint8_t *pqCode: pointer to the returned compressed base vector. It cannot be a null pointer.

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 baseData are as follows:

    The size of the data pointed to by items is length × dim × sizeof(float) bytes. Note that different from ComputePQTable, you do not need to pad the data that replaces the metadata before each data record.

  • Population requirements on params:
    • 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 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.
    • 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.
    • There is no data population requirement on tablesTransposed.
    • 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 pqCode points is at least length × pqChunks bytes. length is a VectorArrayData parameter, and pqChunks is a DiskPQParams parameter.