feat(lsm): some more string functions; start of data streaming api
This commit is contained in:
parent
fca8495de4
commit
b552e0a81b
9 changed files with 199 additions and 17 deletions
|
|
@ -3,7 +3,12 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#define LSM_MAX_SKIP_SIZE 8
|
||||
#define LSM_RES(x) \
|
||||
{ \
|
||||
lsm_error res = x; \
|
||||
if (res != lsm_error_ok) \
|
||||
return res; \
|
||||
}
|
||||
|
||||
typedef enum lsm_error {
|
||||
lsm_error_ok = 0,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
#include "lsm.h"
|
||||
#include "lsm/str.h"
|
||||
|
||||
#define LSM_STORE_DISK_THRESHOLD 1024
|
||||
|
||||
/**
|
||||
* The type of an entry attribute.
|
||||
*
|
||||
|
|
@ -73,7 +75,7 @@ lsm_error lsm_entry_attr_insert(lsm_entry *entry, lsm_attr_type type,
|
|||
* Remove an atribute from the given entry, if present.
|
||||
*
|
||||
* @param out pointer to store removed data pointer in. If NULL, data pointer
|
||||
* can get leaked.
|
||||
* will be leaked.
|
||||
* @param entry entry to remove attribute from
|
||||
* @param type type of attribute to remove
|
||||
*/
|
||||
|
|
@ -95,6 +97,15 @@ typedef struct lsm_store lsm_store;
|
|||
*/
|
||||
lsm_error lsm_store_init(lsm_store **ptr);
|
||||
|
||||
/**
|
||||
* Open the given database file and load it into a new store object.
|
||||
*
|
||||
* @param ptr pointer to store newly allocated store
|
||||
* @param db_path path to the database file
|
||||
* @param data_path path to the data directory
|
||||
*/
|
||||
lsm_error lsm_store_open(lsm_store **ptr, char *db_path, char *data_path);
|
||||
|
||||
/**
|
||||
* Dealocate an existing lsm_store object.
|
||||
*
|
||||
|
|
@ -102,4 +113,34 @@ lsm_error lsm_store_init(lsm_store **ptr);
|
|||
*/
|
||||
void lsm_store_free(lsm_store *store);
|
||||
|
||||
/**
|
||||
* Search for an entry in the store.
|
||||
*
|
||||
* @param out pointer to store entry pointer in
|
||||
* @param store store to search in
|
||||
* @param key key to look with
|
||||
*/
|
||||
lsm_error lsm_store_search(lsm_entry **out, lsm_store *store, lsm_str *key);
|
||||
|
||||
/**
|
||||
* Allocate a new entry in the store with the specified key.
|
||||
*
|
||||
* @param out pointer to store new entry pointer in
|
||||
* @param store store to modify
|
||||
* @param key key to add; ownership of key pointer is taken over
|
||||
*/
|
||||
lsm_error lsm_store_insert(lsm_entry **out, lsm_store *store, lsm_str *key);
|
||||
|
||||
/**
|
||||
* Append new data to the given entry, which is expected to be in the store.
|
||||
*
|
||||
* This function will append either to disk or to memory, depending on the
|
||||
* length of the entry's data.
|
||||
*
|
||||
* @param store store the entry is stored in
|
||||
* @param entry entry to append data to
|
||||
* @param data data to append
|
||||
*/
|
||||
lsm_error lsm_store_data_append(lsm_store *store, lsm_entry *entry, lsm_str *data);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -151,4 +151,12 @@ lsm_error lsm_str_truncate(lsm_str *s, uint64_t new_len);
|
|||
*/
|
||||
lsm_error lsm_str_split(lsm_str *s, lsm_str *s2, uint64_t index);
|
||||
|
||||
/**
|
||||
* Append s2 to s. s2 is left untouched.
|
||||
*
|
||||
* @param s string to append s2 to
|
||||
* @param s2 string to append to s
|
||||
*/
|
||||
lsm_error lsm_str_append(lsm_str *s, lsm_str *s2);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue