chore: add subrange size method

This commit is contained in:
Prem Chaitanya Prathi 2024-04-30 15:05:32 +05:30
parent 3044a30e4b
commit 19ebbdeb25
No known key found for this signature in database
3 changed files with 9 additions and 2 deletions

View File

@ -84,13 +84,13 @@ int main(){
if (subrange == NULL){ if (subrange == NULL){
perror("failed to init subrange"); 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); void* subrange1 = subrange_new(st1, 0 , UINT64_MAX);
if (subrange == NULL){ if (subrange == NULL){
perror("failed to init subrange"); 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); void* ngn_inst1 = negentropy_new(subrange1, 153600);
if(ngn_inst1 == NULL){ if(ngn_inst1 == NULL){

View File

@ -302,6 +302,11 @@ void subrange_delete(void* range){
delete subRange; delete subRange;
} }
int subrange_size(void* range){
negentropy::storage::SubRange* subrange = reinterpret_cast<negentropy::storage::SubRange*>(range);
return subrange->size();
}
void negentropy_subrange_delete(void* negentropy){ void negentropy_subrange_delete(void* negentropy){
Negentropy<negentropy::storage::SubRange>* ngn_inst = reinterpret_cast<Negentropy<negentropy::storage::SubRange>*>(negentropy); Negentropy<negentropy::storage::SubRange>* ngn_inst = reinterpret_cast<Negentropy<negentropy::storage::SubRange>*>(negentropy);
delete ngn_inst; delete ngn_inst;

View File

@ -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 reconcile_with_ids_subrange_no_cbk(void* negentropy, buffer* query, result* result);
EXTERNC int subrange_size(void* storage);
//End of SubRange methods //End of SubRange methods
#endif #endif