AddFeatureByIndice

  • This API cannot be used together with AddFeature and AddWithExtraVal.
  • If this API is used to add features by indice, APIs that depend on labels, such as GetExtraValAttrByLabel, cannot be used. AddFeatureByIndice and GetFeatureByIndice must be used together.

API definition

APP_ERROR AddFeatureByIndice(int64_t count, const void *features, const FeatureAttr *attributes, const int64_t *indices, const ExtraValAttr *extraVal = nullptr, const uint8_t *customAttr = nullptr);

Function

Adds features by indice. Currently, this API supports only FlatIP and Int8Flat (cosine distance).

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.

const int64_t *indices: index of the feature to be added.

const ExtraValAttr *extraVal: additional feature attribute to be added.

const uint8_t *customAttr: custom 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 indices must be count. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown. The value must be non-negative and in strictly increasing order. If it is less than the current feature count, the corresponding feature will be replaced; if it is greater than or equal to the current count, it indicates an addition, in which case the value must be consecutive.
  • The value of extraVal must be a null pointer or the length must be count. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown. If the value is a null pointer, no additional attribute needs to be added.
  • The value of customAttr must be a null pointer or the length must be count × customAttrLen. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown. If the value is a null pointer, no additional custom attribute needs to be added.