diff --git a/c_api/IndexShards_c.cpp b/c_api/IndexShards_c.cpp index 9d9c95dfc6..03084540e8 100644 --- a/c_api/IndexShards_c.cpp +++ b/c_api/IndexShards_c.cpp @@ -59,6 +59,10 @@ int faiss_IndexShards_remove_shard(FaissIndexShards* index, FaissIndex* shard) { CATCH_AND_HANDLE } +int faiss_IndexShards_count(const FaissIndexShards* index) { + return reinterpret_cast(index)->count(); +} + FaissIndex* faiss_IndexShards_at(FaissIndexShards* index, int i) { auto shard = reinterpret_cast(index)->at(i); return reinterpret_cast(shard); diff --git a/c_api/IndexShards_c.h b/c_api/IndexShards_c.h index 8f4a4b7ab3..35e31698e6 100644 --- a/c_api/IndexShards_c.h +++ b/c_api/IndexShards_c.h @@ -37,6 +37,9 @@ int faiss_IndexShards_add_shard(FaissIndexShards* index, FaissIndex* shard); int faiss_IndexShards_remove_shard(FaissIndexShards* index, FaissIndex* shard); +/// Returns the number of sub-indices (shards) +int faiss_IndexShards_count(const FaissIndexShards* index); + FaissIndex* faiss_IndexShards_at(FaissIndexShards* index, int i); #ifdef __cplusplus