2023-10-12 10:06:20 +02:00
|
|
|
#ifndef LSM
|
|
|
|
#define LSM
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2023-10-28 15:48:28 +02:00
|
|
|
#define LSM_RES(x) \
|
|
|
|
{ \
|
|
|
|
lsm_error res = x; \
|
|
|
|
if (res != lsm_error_ok) \
|
|
|
|
return res; \
|
2023-10-25 10:57:45 +02:00
|
|
|
}
|
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; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2024-08-29 11:12:56 +02:00
|
|
|
#define LSM_MAX(x, y) ((x) > (y) ? (x) : (y))
|
|
|
|
|
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,
|
2023-10-13 21:10:31 +02:00
|
|
|
lsm_error_already_present = 3,
|
2023-10-28 15:48:28 +02:00
|
|
|
lsm_error_null_value = 4,
|
|
|
|
lsm_error_failed_io = 5,
|
|
|
|
lsm_error_lock_busy = 6,
|
2023-10-12 10:06:20 +02:00
|
|
|
} lsm_error;
|
|
|
|
|
2023-10-13 12:45:48 +02:00
|
|
|
/*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
|
|
|
*/
|
2023-10-13 12:45:48 +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
|