draft: subrange apis

This commit is contained in:
Prem Chaitanya Prathi 2024-03-15 15:24:33 +05:30
parent 2a0f2c6156
commit 8ae48ebf9e
No known key found for this signature in database
3 changed files with 27 additions and 0 deletions

View File

@ -129,4 +129,10 @@ int main(){
free(b3.data);
free(b4.data);
free_result(&res1);
void* subrange = subrange_new(st1, 0 , UINT64_MAX);
if (subrange == NULL){
perror("failed to init subrange");
}
printf("subrange init successful");
}

View File

@ -4,6 +4,7 @@
#include "negentropy.h"
#include "negentropy/storage/BTreeMem.h"
#include "negentropy_wrapper.h"
#include "negentropy/storage/SubRange.h"
//This is a C-wrapper for the C++ library that helps in integrating negentropy with nim code.
//TODO: Do error handling by catching exceptions
@ -44,6 +45,22 @@ int storage_size(void* storage){
return lmdbStorage->size();
}
void* subrange_new(void* storage, uint64_t startTimeStamp, uint64_t endTimeStamp){
negentropy::storage::BTreeMem* st = reinterpret_cast<negentropy::storage::BTreeMem*>(storage);
negentropy::storage::SubRange* subRange = NULL;
try {
subRange = new negentropy::storage::SubRange(*st, negentropy::Bound(startTimeStamp), negentropy::Bound(endTimeStamp));
} catch (negentropy::err e){
return NULL;
}
return subRange;
}
void subrange_delete(void* range){
negentropy::storage::SubRange* subRange = reinterpret_cast<negentropy::storage::SubRange*>(range);
delete subRange;
}
void negentropy_delete(void* negentropy){
Negentropy<negentropy::storage::BTreeMem>* ngn_inst = reinterpret_cast<Negentropy<negentropy::storage::BTreeMem>*>(negentropy);
delete ngn_inst;

View File

@ -31,6 +31,10 @@ EXTERNC void storage_delete(void* storage);
EXTERNC int storage_size(void* storage);
EXTERNC void* subrange_new(void* storage, uint64_t startTimeStamp, uint64_t endTimeStamp);
EXTERNC void subrange_delete(void* range);
EXTERNC void* negentropy_new(void* storage, uint64_t frameSizeLimit);
EXTERNC void negentropy_delete(void* negentropy);