add_with_ids

API definition

void add_with_ids(idx_t n, const float *x, const idx_t *ids) override;

Function

Adds feature vectors to the database and specifies the corresponding IDs.

Input

idx_t n: number of feature vectors to be added.

const float *x: feature vectors to be added.

const idx_t *ids: IDs of the feature vectors to be added.

Output

N/A

Return value

N/A

Restrictions

The length of x must be dims × n, and the length of ids must be n. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown. You need to ensure the validity of ids based on your service scenario. For example, if duplicate IDs exist in the database, label in the retrieval result cannot correspond to specific vectors.

Range of n: 0 < n < 1e9.

The performance of add_with_ids is optimized small-batch additions. However, the precision decreases depending on the dataset. It is advised to use small-batch addition primarily for existing databases.