Call Process and Inheritance
The C++ APIs of Index SDK FeatureRetrival comply with the exception handling mechanism of the open-source Faiss APIs. Therefore, you must call APIs and handle exceptions in the try/catch statement block. For details, see the handling methods in Scanning Ports. This prevents the program from exiting due to exceptions.
Figure 1 shows the basic process of calling retrieval APIs.
FeatureRetrieval inherits indexes from Faiss and supports multiple retrieval indexes. It provides APIs for creating, querying, and deleting libraries. Figure 2 and Figure 3 show the inheritance between APIs.
- Some inputs of FeatureRetrieval are of the pointer type. Therefore, you need to ensure that pointers have a valid value to prevent potential risks and problems such as out-of-bounds read and write during the running of FeatureRetrieval. In addition, FeatureRetrieval assists Ascend AI Processors in vector retrieval and calculation. Therefore, ensure that the entered device ID is valid. Otherwise, the function may fail due to the device connection failure.
- Faiss is a vector retrieval acceleration library widely used in the industry. To help ecosystem users quickly migrate vector retrieval and clustering services from the CPU/GPU platform to the Ascend platform, the base class AscendIndex of many algorithms on the Ascend platform is inherited from the faiss::Index class. Member variables such as d and ntotal in the faiss::Index class are public. When using the subclasses of AscendIndex and AscendIndexInt8, do not modify these public member variables.
- This document does not describe the member functions and variables of the base class faiss::Index.
- resourceSize in the Config class reserves the memory, in byte, for storing intermediate results during feature retrieval. Increase the value, if the base library is large (for example, if it has more than 3 million features) and the number of query requests is large. This prevents performance jitter caused by temporary memory allocation during retrieval. You are advised to set the value to 1024 x 1024 x 1024 bytes.
When a new index is created, a comparison is performed between it and allocated resources. If there is any difference, the original memory resources will be destroyed, and new memory resources will be allocated based on the resources variable of the latest index. Therefore, ensure that all values of resources of the indexes are the same.
- You can set the MX_INDEX_SYNCHRONIZE_STREAM_TIME environment variable to set the timeout interval for operator execution. The unit is ms. The value range is [60000, 1800000], and the default value is 300000.


