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

@ -12,7 +12,7 @@
#define LSM_IDX_FILE_NAME "lsm.idx"
typedef struct lsm_attr {
lsm_attr_type type;
uint64_t type;
lsm_str *str;
} lsm_attr;

View file

@ -56,12 +56,12 @@ void lsm_entry_close(lsm_entry_handle *handle) {
free(handle);
}
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) {
return (handle->wrapper->entry->attrs.bitmap & type) != 0;
}
lsm_error lsm_entry_attr_get(lsm_str **out, lsm_entry_handle *handle,
lsm_attr_type type) {
uint64_t type) {
if (!lsm_entry_attr_present(handle, type)) {
return lsm_error_not_found;
}
@ -79,7 +79,7 @@ lsm_error lsm_entry_attr_get(lsm_str **out, lsm_entry_handle *handle,
}
lsm_error lsm_entry_attr_get_num(uint64_t *out, lsm_entry_handle *handle,
lsm_attr_type type) {
uint64_t type) {
lsm_str *s;
LSM_RES(lsm_entry_attr_get(&s, handle, type));
@ -96,7 +96,7 @@ lsm_error lsm_entry_attr_get_num(uint64_t *out, lsm_entry_handle *handle,
}
lsm_error lsm_entry_attr_remove(lsm_str **out, lsm_entry_handle *handle,
lsm_attr_type type) {
uint64_t type) {
if (!lsm_entry_attr_present(handle, type)) {
return lsm_error_not_found;
}
@ -143,7 +143,7 @@ lsm_error lsm_entry_attr_remove(lsm_str **out, lsm_entry_handle *handle,
return lsm_error_ok;
}
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) {
if (lsm_entry_attr_present(handle, type)) {
return lsm_error_already_present;
@ -168,8 +168,8 @@ lsm_error lsm_entry_attr_insert(lsm_entry_handle *handle, lsm_attr_type type,
return lsm_error_ok;
}
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) {
lsm_str *s;
LSM_RES(
lsm_str_init_copy_n(&s, (char *)&data, sizeof(uint64_t) / sizeof(char)));