wpi
Some checks failed
ci/woodpecker/push/build Pipeline failed

This commit is contained in:
Jef Roosens 2024-08-30 19:32:17 +02:00
parent 80281c702b
commit 68f217d8e9
Signed by: Jef Roosens
GPG key ID: 02D4C0997E74717B
9 changed files with 146 additions and 213 deletions

View file

@ -19,12 +19,6 @@ typedef struct lsm_read_handle lsm_read_handle;
*/
typedef struct lsm_write_handle lsm_write_handle;
/**
* A handle referencing an entry inside a store. Read/write operations from/to
* the entry go through this handle.
*/
typedef struct lsm_entry_handle lsm_entry_handle;
/**
* A store consisting of LSM entries.
*
@ -86,23 +80,6 @@ lsm_error lsm_store_open_read(lsm_read_handle **out, lsm_store *store,
lsm_error lsm_store_open_write(lsm_write_handle **out, lsm_store *store,
const lsm_str *key);
/**
* Commit any changes to the persistent storage. Any changes, insertions or
* deletions that occured without a commit are reverted when the handle is
* closed.
*
* @param handle handle to the entry
*/
lsm_error lsm_entry_commit(lsm_entry_handle *handle);
/**
* Close an open entry handle.
*
* @param store store the handle's entry is stored in
* @param handle handle to close
*/
void lsm_entry_close(lsm_entry_handle *handle);
/**
* Insert a new entry into the store, returning a write handle to the newly
* created entry.
@ -111,57 +88,41 @@ void lsm_entry_close(lsm_entry_handle *handle);
* @param store store to modify
* @param key key to add; ownership of key pointer is taken over
*/
lsm_error lsm_store_insert(lsm_entry_handle **out, lsm_store *store,
lsm_str *key);
lsm_error lsm_store_open_new(lsm_write_handle **out, lsm_store *store,
lsm_str *key);
/**
* Mark the entry as removed.
*
* @param handle handle to entry to remove
*/
void lsm_entry_remove(lsm_entry_handle *handle);
bool lsm_read_attr_present(lsm_read_handle *handle, uint8_t type);
lsm_error lsm_read_attr_get(const lsm_str **out, const lsm_read_handle *handle,
uint8_t type);
lsm_error lsm_read_attr_get_uint64_t(uint64_t *out,
const lsm_read_handle *handle,
uint8_t type);
lsm_error lsm_read_attr_get_uint8_t(uint8_t *out, const lsm_read_handle *handle,
uint8_t type);
lsm_error lsm_read_data_read(uint64_t *out, char *buf, lsm_read_handle *handle,
uint64_t len);
void lsm_read_close(lsm_read_handle *handle);
/**
* 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_entry_data_append(lsm_entry_handle *handle, const lsm_str *data);
/**
* Same as `lsm_entry_data_append`, except that it takes a direct char array.
*
* @param store store the entry is stored in
* @param entry entry to append data to
* @param data data to append
* @param len length of data array
*/
lsm_error lsm_entry_data_append_raw(lsm_entry_handle *handle, char *data,
uint64_t len);
/**
* Read a number of bytes from the entry's data field. The position from which
* data is read is dependent on previous read calls.
*
* @param out where to write how many bytes were read
* @param buf buffer to store read data in
* @param handle entry handle to read from
* @param len how many bytes to read at most
*/
lsm_error lsm_entry_data_read(uint64_t *out, char *buf, lsm_read_handle *handle,
uint64_t len);
/**
* Return the length of the entry's data.
*
* @param handle entry handle to return length for
* @return length of the data
*/
uint64_t lsm_entry_data_len(lsm_entry_handle *handle);
bool lsm_write_attr_present(const lsm_write_handle *handle, uint8_t type);
lsm_error lsm_write_attr_get(const lsm_str **out,
const lsm_write_handle *handle, uint8_t type);
lsm_error lsm_write_attr_get_uint64_t(uint64_t *out,
const lsm_write_handle *handle,
uint8_t type);
lsm_error lsm_write_attr_get_uint8_t(uint8_t *out,
const lsm_write_handle *handle,
uint8_t type);
lsm_error lsm_write_attr_remove(lsm_str **out, lsm_write_handle *handle,
uint8_t type);
lsm_error lsm_write_attr_insert(lsm_write_handle *handle, uint8_t type,
lsm_str *data);
lsm_error lsm_write_attr_insert_uint64_t(lsm_write_handle *handle, uint8_t type,
uint64_t data);
lsm_error lsm_write_attr_insert_uint8_t(lsm_write_handle *handle, uint8_t type,
uint8_t data);
lsm_error lsm_write_data_append(lsm_write_handle *handle, const lsm_str *data);
void lsm_write_remove(lsm_write_handle *handle);
void lsm_write_close(lsm_write_handle *handle);
lsm_error lsm_write_commit(lsm_write_handle *handle);
#endif