From 19ebbdeb25d99589906ff8646d5c583fedc35436 Mon Sep 17 00:00:00 2001 From: Prem Chaitanya Prathi Date: Tue, 30 Apr 2024 15:05:32 +0530 Subject: [PATCH] chore: add subrange size method --- cpp/example/test.c | 4 ++-- cpp/negentropy_wrapper.c | 5 +++++ cpp/negentropy_wrapper.h | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cpp/example/test.c b/cpp/example/test.c index c4efd44..56b2cff 100644 --- a/cpp/example/test.c +++ b/cpp/example/test.c @@ -84,13 +84,13 @@ int main(){ if (subrange == NULL){ perror("failed to init subrange"); } - printf("subrange init successful"); + printf("subrange init successful with size %d \n ", subrange_size(subrange) ); void* subrange1 = subrange_new(st1, 0 , UINT64_MAX); if (subrange == NULL){ perror("failed to init subrange"); } - printf("subrange init successful"); + printf("subrange init successful with size %d \n ", subrange_size(subrange1) ); void* ngn_inst1 = negentropy_new(subrange1, 153600); if(ngn_inst1 == NULL){ diff --git a/cpp/negentropy_wrapper.c b/cpp/negentropy_wrapper.c index 409751f..b907125 100644 --- a/cpp/negentropy_wrapper.c +++ b/cpp/negentropy_wrapper.c @@ -302,6 +302,11 @@ void subrange_delete(void* range){ delete subRange; } +int subrange_size(void* range){ + negentropy::storage::SubRange* subrange = reinterpret_cast(range); + return subrange->size(); +} + void negentropy_subrange_delete(void* negentropy){ Negentropy* ngn_inst = reinterpret_cast*>(negentropy); delete ngn_inst; diff --git a/cpp/negentropy_wrapper.h b/cpp/negentropy_wrapper.h index a0ae44a..6cccab7 100644 --- a/cpp/negentropy_wrapper.h +++ b/cpp/negentropy_wrapper.h @@ -68,6 +68,8 @@ EXTERNC int reconcile_subrange(void* negentropy, buffer* query, result* result); EXTERNC int reconcile_with_ids_subrange_no_cbk(void* negentropy, buffer* query, result* result); +EXTERNC int subrange_size(void* storage); + //End of SubRange methods #endif