#ifndef LSM #define LSM #include #define LSM_MAX_SKIP_SIZE 8 typedef enum lsm_error { lsm_error_ok = 0, lsm_error_failed_alloc = 1, lsm_error_not_found = 2, lsm_error_already_present = 3 } lsm_error; /** * Represents a string (or really any kind of data) with a known length. Data * with length 8 or less is stored inside the pointer, and does not allocate * additional memory. */ typedef struct lsm_string { uint64_t len; union { void *ptr; char val[8]; } str; } lsm_string; /** * 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. */ typedef enum lsm_attr_type { lsm_attr_type_entry_type = 1 << 0 } lsm_attr_type; /** * A single attribute associated with an entry */ typedef struct lsm_attr { lsm_attr_type type; lsm_string str; } lsm_attr; /** * Represents a collection of attributes for an entry. A collection can only * contain one of each attribute. */ typedef struct lsm_attr_list { uint64_t count; lsm_attr *items; uint32_t bitmap; } lsm_attr_list; /** * An entry inside an LSM store */ typedef struct lsm_entry { lsm_string key; lsm_attr_list attrs; lsm_string data; } lsm_entry; /** * A store of entries, which manages its data both in-memory and on disk. */ typedef struct lsm_store lsm_store; #endif