refactor(lsm): decouple attribute types

This commit is contained in:
Jef Roosens 2023-11-08 12:25:47 +01:00
parent 535b92a6b6
commit b5fc3a3612
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
6 changed files with 26 additions and 32 deletions

View file

@ -9,18 +9,6 @@
#define LSM_STORE_DISK_THRESHOLD 1024
/**
* The type of an entry attribute.
*
* Each type is represented as a single bit of an
* integer, so they can be easily combined into a bitmap.
*/
typedef enum lsm_attr_type : uint64_t {
lsm_attr_type_entry_type = 1 << 0,
lsm_attr_type_content_type = 1 << 1,
lsm_attr_type_url = 1 << 2,
} lsm_attr_type;
/**
* A handle referencing an entry inside a store. Read/write operations from/to
* the entry go through this handle.
@ -33,7 +21,7 @@ typedef struct lsm_entry_handle lsm_entry_handle;
* @param entry entry to check
* @param type type of attribute to check for
*/
bool lsm_entry_attr_present(lsm_entry_handle *handle, lsm_attr_type type);
bool lsm_entry_attr_present(lsm_entry_handle *handle, uint64_t type);
/**
* Retrieve the contents of an attribute from an entry, if present
@ -43,7 +31,7 @@ bool lsm_entry_attr_present(lsm_entry_handle *handle, lsm_attr_type type);
* @param type type of attribute to return
*/
lsm_error lsm_entry_attr_get(lsm_str **out, lsm_entry_handle *handle,
lsm_attr_type type);
uint64_t type);
/**
* Convenience wrapper around `lsm_entry_attr_get` that can be used if we know
@ -54,7 +42,7 @@ lsm_error lsm_entry_attr_get(lsm_str **out, lsm_entry_handle *handle,
* @param type type of attribute to return
*/
lsm_error lsm_entry_attr_get_num(uint64_t *out, lsm_entry_handle *handle,
lsm_attr_type type);
uint64_t type);
/**
* Add a new attribute to the entry.
@ -63,7 +51,7 @@ lsm_error lsm_entry_attr_get_num(uint64_t *out, lsm_entry_handle *handle,
* @param type type of attribute to add
* @param data data of attribute; ownership of pointer is taken over
*/
lsm_error lsm_entry_attr_insert(lsm_entry_handle *handle, lsm_attr_type type,
lsm_error lsm_entry_attr_insert(lsm_entry_handle *handle, uint64_t type,
lsm_str *data);
/**
@ -74,8 +62,8 @@ lsm_error lsm_entry_attr_insert(lsm_entry_handle *handle, lsm_attr_type type,
* @param type type of attribute to add
* @param data data of attribute
*/
lsm_error lsm_entry_attr_insert_num(lsm_entry_handle *handle,
lsm_attr_type type, uint64_t data);
lsm_error lsm_entry_attr_insert_num(lsm_entry_handle *handle, uint64_t type,
uint64_t data);
/**
* Remove an atribute from the given entry, if present.
@ -86,7 +74,7 @@ lsm_error lsm_entry_attr_insert_num(lsm_entry_handle *handle,
* @param type type of attribute to remove
*/
lsm_error lsm_entry_attr_remove(lsm_str **out, lsm_entry_handle *handle,
lsm_attr_type type);
uint64_t type);
/**
* A store consisting of LSM entries.