forked from tecbot/gorocksdb
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gorocksdb.h
117 lines (86 loc) · 2.7 KB
/
gorocksdb.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include <stdlib.h>
#include "rocksdb/c.h"
typedef struct {
char** keys;
size_t* key_sizes;
char** values;
size_t* value_sizes;
int found;
} gorocksdb_many_keys_t;
typedef int bool;
#define FALSE 0
#define TRUE !FALSE
// This API provides convenient C wrapper functions for rocksdb client.
/* Base */
extern void gorocksdb_destruct_handler(void* state);
/* CompactionFilter */
extern rocksdb_compactionfilter_t* gorocksdb_compactionfilter_create(uintptr_t idx);
/* Comparator */
extern rocksdb_comparator_t* gorocksdb_comparator_create(uintptr_t idx);
/* Filter Policy */
extern rocksdb_filterpolicy_t* gorocksdb_filterpolicy_create(uintptr_t idx);
extern void gorocksdb_filterpolicy_delete_filter(void* state, const char* v, size_t s);
/* Merge Operator */
extern rocksdb_mergeoperator_t* gorocksdb_mergeoperator_create(uintptr_t idx);
extern void gorocksdb_mergeoperator_delete_value(void* state, const char* v, size_t s);
/* Slice Transform */
extern rocksdb_slicetransform_t* gorocksdb_slicetransform_create(uintptr_t idx);
/* Iterate many keys */
typedef struct {
char* key_prefix;
size_t key_prefix_s;
char* key_end;
size_t key_end_s;
} gorocksdb_many_keys_filter_t;
extern gorocksdb_many_keys_t* gorocksdb_iter_many_keys(rocksdb_iterator_t* iter, int limit, bool reverse, const gorocksdb_many_keys_filter_t* key_filter, int page_alloc_size);
extern void gorocksdb_destroy_many_keys(gorocksdb_many_keys_t* many_keys);
/* Batch searches */
typedef struct {
char* key_from;
size_t key_from_s;
char* key_prefix;
size_t key_prefix_s;
char* key_end;
size_t key_end_s;
int limit;
bool reverse;
bool exclude_key_from;
} gorocksdb_keys_search_t;
extern gorocksdb_many_keys_t** gorocksdb_many_search_keys(
rocksdb_iterator_t* iter,
const gorocksdb_keys_search_t* keys_searches,
int size,
int page_alloc_size
);
extern gorocksdb_many_keys_t** gorocksdb_many_search_keys_raw(
rocksdb_iterator_t* iter,
char** key_froms,
size_t* key_from_s,
char** key_prefixes,
size_t* key_prefix_s,
char** key_ends,
size_t* key_end_s,
int* limits,
bool* reverse,
int size,
int page_alloc_size
);
extern void gorocksdb_destroy_many_many_keys(gorocksdb_many_keys_t** many_many_keys, int size);
/* Batch PutMany */
void gorocksdb_writebatch_put_many(
rocksdb_writebatch_t* batch,
size_t num_pairs,
char** keys,
size_t* key_sizes,
char** values,
size_t* value_sizes
);
void gorocksdb_writebatch_put_many_cf(
rocksdb_writebatch_t* batch,
rocksdb_column_family_handle_t* cf,
size_t num_pairs,
char** keys,
size_t* key_sizes,
char** values,
size_t* value_sizes
);