loadAllData

API definition

void loadAllData(const char *dataPath);

Function

Reads the index structure from the drive to the device, including the feature vectors after compression and dimension reduction, as well as codebook data.

Input

const char *dataPath: data file path.

Output

N/A

Return value

N/A

Restrictions

The file corresponding to dataPath must be the flushed file obtained by calling saveAllData. The program running user must have the read permission on the file. In addition, the file cannot be a soft link.

This API cannot share codebooks. To share codebooks, you are advised to use the following loadAllData.

API definition

static std::shared_ptr<AscendIndexIVFSP> loadAllData(const AscendIndexIVFSPConfig &config, const uint8_t *data, size_t dataLen, const AscendIndexIVFSP *codeBookSharedIdx = nullptr);

Function

Restores the AscendIndexIVFSP object from the memory.

Input

  • const AscendIndexIVFSPConfig &config: resource configurations on the device. Currently, only config.deviceList and config.resourceSize need to be set. Other parameters will be restored from the memory.
  • const uint8_t *data: memory pointer obtained by calling saveAllData.
  • size_t dataLen: actual length of the data pointer.
  • const AscendIndexIVFSP *codeBookSharedIdx: AscendIndexIVFSP pointer of the shared codebook. The default value is nullptr, indicating that the codebook is not shared.

Output

N/A

Return value

AscendIndexIVFSP smart pointer object restored from the memory.

Restrictions

  • data must be a valid non-null pointer.
  • dataLen must be the actual length of data. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.
  • The codebook configuration of codeBookSharedIdx must be the same as that of the current Index, and the same device resources must be configured.