From 1411f20219a0bf15fb7af456e06b92a879862e51 Mon Sep 17 00:00:00 2001 From: Prem Chaitanya Prathi Date: Mon, 11 Mar 2024 14:01:21 +0530 Subject: [PATCH] chore:added storage size method --- cpp/example/test.c | 4 +++- cpp/negentropy_wrapper.c | 7 ++++++- cpp/negentropy_wrapper.h | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cpp/example/test.c b/cpp/example/test.c index f3511db..7d77e93 100644 --- a/cpp/example/test.c +++ b/cpp/example/test.c @@ -83,6 +83,8 @@ int main(){ buffer b4 ; b4.len = 153600; b4.data = (unsigned char*)malloc(153600); + + printf("storage size of st2 is %d \n",storage_size(st2)); size_t outSize = negentropy_initiate(ngn_inst1, &b4); if(outSize == 0){ @@ -120,4 +122,4 @@ int main(){ free(b3.data); free(b4.data); -} \ No newline at end of file +} diff --git a/cpp/negentropy_wrapper.c b/cpp/negentropy_wrapper.c index 46585b5..697b645 100644 --- a/cpp/negentropy_wrapper.c +++ b/cpp/negentropy_wrapper.c @@ -39,6 +39,11 @@ void storage_delete(void* storage){ delete lmdbStorage; } +int storage_size(void* storage){ + negentropy::storage::BTreeMem* lmdbStorage = reinterpret_cast(storage); + return lmdbStorage->size(); +} + void negentropy_delete(void* negentropy){ Negentropy* ngn_inst = reinterpret_cast*>(negentropy); delete ngn_inst; @@ -229,7 +234,7 @@ void reconcile_with_ids_no_cbk(void* negentropy, buffer* query, result* result) /* std::cout << "reconcile_with_ids output of reconcile is, len:" << out.value().size() << ", output:"; printHexString(std::string_view(out.value())); */ }else { - std::cout << "reconcile_with_ids_no_cbk output is empty " << std::endl; + //std::cout << "reconcile_with_ids_no_cbk output is empty " << std::endl; result->output.len = 0; result->output.data = NULL; } diff --git a/cpp/negentropy_wrapper.h b/cpp/negentropy_wrapper.h index 41c2a1c..985bfa2 100644 --- a/cpp/negentropy_wrapper.h +++ b/cpp/negentropy_wrapper.h @@ -28,6 +28,8 @@ EXTERNC void* storage_new(const char* db_path, const char* name); EXTERNC void storage_delete(void* storage); +EXTERNC int storage_size(void* storage); + EXTERNC void* negentropy_new(void* storage, uint64_t frameSizeLimit); EXTERNC void negentropy_delete(void* negentropy);