-
Notifications
You must be signed in to change notification settings - Fork 11
/
db_skiplist.h
35 lines (26 loc) · 878 Bytes
/
db_skiplist.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "rwlock/readerwriter.h"
/**
* skip lists
*/
// skip list head
struct SkipHead_ {
DbAddr head[1]; // list head
RWLock lock[1]; // reader/writer lock
};
// Skip list entry
typedef struct SkipEntry_ {
uint64_t key[1]; // entry key
uint64_t val[1]; // entry value
} SkipEntry;
// size of skip list entry array
typedef struct {
DbAddr next[1]; // next block of keys
SkipEntry array[0]; // array of key/value pairs
} SkipNode;
int skipSearch(SkipEntry *array, int high, uint64_t key);
SkipEntry *skipFind(DbMap *map, DbAddr *skip, uint64_t key);
SkipEntry *skipPush(DbMap *map, DbAddr *skip, uint64_t key);
SkipEntry *skipAdd(DbMap *map, DbAddr *skip, uint64_t key);
uint64_t skipInit(DbMap *map, int numEntries);
uint64_t skipDel(DbMap *map, DbAddr *skip, uint64_t key);
DbStatus addItemToSkiplist(DbMap *map, DbAddr *skip, uint64_t key, uint64_t item);