From 80b53d72446a06cdd2c90206ff7118cc44b5b6e0 Mon Sep 17 00:00:00 2001 From: Thejas-bhat Date: Thu, 1 Feb 2024 17:26:46 +0530 Subject: [PATCH] size API for c to get the size of index --- c_api/Index_c_ex.cpp | 8 +++++++- c_api/Index_c_ex.h | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/c_api/Index_c_ex.cpp b/c_api/Index_c_ex.cpp index 569ca3236e..35ab5c97fa 100644 --- a/c_api/Index_c_ex.cpp +++ b/c_api/Index_c_ex.cpp @@ -8,7 +8,7 @@ // Copyright 2023-present Facebook. All Rights Reserved. // -*- c++ -*- -#include "Index_c.h" +#include "Index_c_ex.h" #include #include "macros_impl.h" @@ -30,4 +30,10 @@ int faiss_Index_merge_from(FaissIndex* index, FaissIndex* other, const idx_t add CATCH_AND_HANDLE } +size_t faiss_Index_size(FaissIndex* index) { + auto xIndex = reinterpret_cast(index); + size_t rv = sizeof(xIndex); + return rv; +} + } \ No newline at end of file diff --git a/c_api/Index_c_ex.h b/c_api/Index_c_ex.h index 10812c1a62..10db00e304 100644 --- a/c_api/Index_c_ex.h +++ b/c_api/Index_c_ex.h @@ -12,9 +12,11 @@ #define FAISS_INDEX_EX_C_H #include +#include #include "faiss_c.h" #include "Index_c.h" + #ifdef __cplusplus extern "C" { #endif @@ -25,6 +27,8 @@ int faiss_Index_reconstruct_batch(const FaissIndex* index, idx_t n, int faiss_Index_merge_from(FaissIndex* index, FaissIndex* other, idx_t add_id); +size_t faiss_Index_size(FaissIndex* index); + #ifdef __cplusplus } #endif