chore: address few review comments

This commit is contained in:
Prem Chaitanya Prathi 2024-05-01 10:10:13 +05:30
parent 028dbf3470
commit 3794b1a11a
No known key found for this signature in database
2 changed files with 14 additions and 3 deletions

View File

@ -8,6 +8,8 @@
#include <string>
#include "../negentropy_wrapper.h"
#define MAX_FRAME_SIZE 153600
void printHexBuffer(buffer buf){
for (uint64_t i = 0; i < buf.len; ++i) {
printf("%0hhx", buf.data[i]);
@ -83,23 +85,27 @@ int main(){
void* subrange = subrange_new(st2, 0 , UINT64_MAX);
if (subrange == NULL){
perror("failed to init subrange");
return;
}
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");
return;
}
printf("subrange init successful with size %d \n ", subrange_size(subrange1) );
void* ngn_inst1 = negentropy_new(subrange1, 153600);
void* ngn_inst1 = negentropy_new(subrange1, MAX_FRAME_SIZE);
if(ngn_inst1 == NULL){
perror("failed to create negentropy instance");
return;
}
void* ngn_inst2 = negentropy_new(subrange, 153600);
void* ngn_inst2 = negentropy_new(subrange, MAX_FRAME_SIZE);
if(ngn_inst2 == NULL){
perror("failed to create negentropy instance");
return;
}
@ -107,6 +113,7 @@ int main(){
int ret1 = negentropy_subrange_initiate(ngn_inst1, &res);
if(ret1 < 0){
perror("failed to initiate negentropy instance");
return;
}
printf("initiated negentropy successfully with output of len %llu \n", res.output.len);
b4.len = res.output.len;
@ -148,7 +155,7 @@ int main(){
free(b4.data);
free_result(&res1);
ret = storage_insert(st1,time(NULL),&b2);
ret = storage_insert(st1, time(NULL), &b2);
if (ret){
printf("inserted hash successfully in st1\n");
}

View File

@ -60,6 +60,7 @@ void* negentropy_new(void* storage, uint64_t frameSizeLimit){
try{
ne = new Negentropy<negentropy::storage::BTreeMem>(*lmdbStorage, frameSizeLimit);
}catch(negentropy::err e){
//TODO: Error handling
return NULL;
}
return ne;
@ -77,6 +78,7 @@ int negentropy_initiate(void* negentropy, result* result){
printHexString(std::string_view(*output)); */
} catch(negentropy::err e){
//std::cout << "Exception raised in initiate " << e.what() << std::endl;
//TODO: Error handling
return -1;
}
if (output->size() > 0 ){
@ -292,6 +294,7 @@ void* subrange_new(void* storage, uint64_t startTimeStamp, uint64_t endTimeStamp
try {
subRange = new negentropy::storage::SubRange(*st, negentropy::Bound(startTimeStamp), negentropy::Bound(endTimeStamp));
} catch (negentropy::err e){
//TODO: Error handling
return NULL;
}
return subRange;
@ -322,6 +325,7 @@ void* negentropy_subrange_new(void* subrange, uint64_t frameSizeLimit){
try{
ne = new Negentropy<negentropy::storage::SubRange>(*sub_range, frameSizeLimit);
}catch(negentropy::err e){
//TODO: Error handling
return NULL;
}
return ne;