AddFeature

API definition

APP_ERROR AddFeature(int64_t count, const void *features, const FeatureAttr *attributes, const int64_t *labels, const uint8_t *customAttr = nullptr);

Function

Adds features.

Input

int64_t count: number of features to be added.

const void *features: feature to be added. The Hamming distance requires data of the uint8_t type, Int8Flat requires data of the int8_t type, and FP16Flat requires data of the float type.

const FeatureAttr *attributes: feature attribute to be added. For details, see FeatureAttr.

const int64_t *labels: feature label to be added. Ensure that the label is unique in the index instance.

const uint8_t *customAttr: custom d feature attribute to be added.

Output

N/A

Return value

APP_ERROR: return status. For details, see Return Code Reference.

Restrictions

  • The value of count ranges from 1 to 1e6 at a time. The maximum value is 1e9.
  • The length of features must be count × dim (vector dimension). Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.
  • The length of attributes must be count. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.
  • The length of labels must be count, and each element is unique and is not in the database. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.
  • The value of customAttr must be a null pointer or its length must be count × customAttrLen (set in Init or InitWithExtraVal). Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.

AddFeature and AddWithExtraVal cannot be used together.