lander/lsm/include/lsm.h

82 lines
2.4 KiB
C
Raw Normal View History

2023-10-12 10:06:20 +02:00
#ifndef LSM
#define LSM
#include <stdint.h>
#define LSM_RES(x) \
{ \
lsm_error res = x; \
if (res != lsm_error_ok) \
return res; \
}
2023-10-12 10:06:20 +02:00
2023-11-16 21:52:20 +01:00
#define LSM_RES2(x, e) \
{ \
lsm_error res = x; \
if (res != lsm_error_ok) { \
e; \
return res; \
} \
}
2023-10-12 10:06:20 +02:00
typedef enum lsm_error {
2023-10-13 11:56:50 +02:00
lsm_error_ok = 0,
lsm_error_failed_alloc = 1,
lsm_error_not_found = 2,
lsm_error_already_present = 3,
lsm_error_null_value = 4,
lsm_error_failed_io = 5,
lsm_error_lock_busy = 6,
2023-12-23 10:06:02 +01:00
lsm_error_done = 7,
2023-10-12 10:06:20 +02:00
} lsm_error;
/*typedef struct lsm_string { */
/* uint64_t len; */
/* union { */
/* void *ptr; */
/* char val[8]; */
/* } str; */
/*} lsm_string; */
/*/1** */
/* * The type of an attribute. Each type is represented as a single bit of a */
/* * 32-bit integer, so they can be easily combined into a bitmap. */
/* *1/ */
/*typedef enum lsm_attr_type { lsm_attr_type_entry_type = 1 << 0 }
* lsm_attr_type; */
/*/1** */
/* * A single attribute associated with an entry */
/* *1/ */
/*typedef struct lsm_attr { */
/* lsm_attr_type type; */
/* lsm_string str; */
/*} lsm_attr; */
/*/1** */
/* * Represents a collection of attributes for an entry. A collection can only
2023-10-12 10:06:20 +02:00
*/
/* * contain one of each attribute. */
/* *1/ */
/*typedef struct lsm_attr_list { */
/* uint64_t count; */
/* lsm_attr *items; */
/* uint32_t bitmap; */
/*} lsm_attr_list; */
/*/1** */
/* * An entry inside an LSM store */
/* *1/ */
/*typedef struct lsm_entry { */
/* lsm_string key; */
/* lsm_attr_list attrs; */
/* lsm_string data; */
/*} lsm_entry; */
/*/1** */
/* * A store of entries, which manages its data both in-memory and on disk. */
/* *1/ */
/*typedef struct lsm_store lsm_store; */
2023-10-12 10:06:20 +02:00
#endif