chore:added storage size method

This commit is contained in:
Prem Chaitanya Prathi 2024-03-11 14:01:21 +05:30
parent c49d60ddee
commit 1411f20219
No known key found for this signature in database
3 changed files with 11 additions and 2 deletions

View File

@ -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);
}
}

View File

@ -39,6 +39,11 @@ void storage_delete(void* storage){
delete lmdbStorage;
}
int storage_size(void* storage){
negentropy::storage::BTreeMem* lmdbStorage = reinterpret_cast<negentropy::storage::BTreeMem*>(storage);
return lmdbStorage->size();
}
void negentropy_delete(void* negentropy){
Negentropy<negentropy::storage::BTreeMem>* ngn_inst = reinterpret_cast<Negentropy<negentropy::storage::BTreeMem>*>(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;
}

View File

@ -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);