12 #include "MetaIndexes_c.h"
13 #include "MetaIndexes.h"
14 #include "macros_impl.h"
24 int faiss_IndexIDMap_new(FaissIndexIDMap** p_index, FaissIndex* index) {
26 auto out =
new IndexIDMap(reinterpret_cast<Index*>(index));
27 *p_index =
reinterpret_cast<FaissIndexIDMap*
>(out);
31 void faiss_IndexIDMap_id_map(FaissIndexIDMap* index,
long** p_id_map,
size_t* p_size) {
32 auto idx =
reinterpret_cast<IndexIDMap*
>(index);
34 *p_id_map = idx->id_map.data();
36 *p_size = idx->id_map.size();
39 int faiss_IndexIDMap2_new(FaissIndexIDMap2** p_index, FaissIndex* index) {
41 auto out =
new IndexIDMap2(reinterpret_cast<Index*>(index));
42 *p_index =
reinterpret_cast<FaissIndexIDMap2*
>(out);
46 int faiss_IndexIDMap2_construct_rev_map(FaissIndexIDMap2* index) {
48 reinterpret_cast<IndexIDMap2*
>(index)->construct_rev_map();
55 DEFINE_GETTER(IndexShards,
int, threaded)
56 DEFINE_SETTER(IndexShards,
int, threaded)
58 DEFINE_GETTER(IndexShards,
int, successive_ids)
59 DEFINE_SETTER(IndexShards,
int, successive_ids)
61 int faiss_IndexShards_new(FaissIndexShards** p_index, idx_t d) {
63 auto out =
new IndexShards(d);
64 *p_index =
reinterpret_cast<FaissIndexShards*
>(out);
68 int faiss_IndexShards_new_with_options(FaissIndexShards** p_index, idx_t d,
int threaded,
int successive_ids) {
70 auto out =
new IndexShards(d, static_cast<bool>(threaded), static_cast<bool>(successive_ids));
71 *p_index =
reinterpret_cast<FaissIndexShards*
>(out);
82 void faiss_IndexShards_shard_indexes(FaissIndexShards* index, FaissIndex** p_shard_indexes,
size_t* p_size) {
85 *p_shard_indexes =
reinterpret_cast<FaissIndex*
>(idx->shard_indexes.data());
87 *p_size = idx->shard_indexes.size();
90 int faiss_IndexShards_add_shard(FaissIndexShards* index, FaissIndex* shard) {
93 reinterpret_cast<Index*>(shard));
97 int faiss_IndexShards_sync_with_shard_indexes(FaissIndexShards* index) {
99 reinterpret_cast<IndexShards*
>(index)->sync_with_shard_indexes();
103 FaissIndex* faiss_IndexShards_at(FaissIndexShards* index,
int i) {
104 auto shard =
reinterpret_cast<IndexShards*
>(index)->at(i);
105 return reinterpret_cast<FaissIndex*
>(shard);