-
Notifications
You must be signed in to change notification settings - Fork 68
/
grocksdb.c
65 lines (53 loc) · 2.69 KB
/
grocksdb.c
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
#include "grocksdb.h"
#include "_cgo_export.h"
/* Base */
void gorocksdb_destruct_handler(void* state) { }
/* Comparator */
rocksdb_comparator_t* gorocksdb_comparator_create(uintptr_t idx) {
return rocksdb_comparator_create(
(void*)idx,
gorocksdb_destruct_handler,
(int (*)(void*, const char*, size_t, const char*, size_t))(gorocksdb_comparator_compare),
(const char *(*)(void*))(gorocksdb_comparator_name));
}
rocksdb_comparator_t* gorocksdb_comparator_with_ts_create(uintptr_t idx, size_t ts_size) {
return rocksdb_comparator_with_ts_create(
(void*)idx,
gorocksdb_destruct_handler,
(int (*)(void*, const char*, size_t, const char*, size_t))(gorocksdb_comparator_compare),
(int (*)(void*, const char*, size_t, const char*, size_t))(gorocksdb_comparator_compare_ts),
(int (*)(void*, const char*, size_t, unsigned char, const char*, size_t, unsigned char))(gorocksdb_comparator_compare_without_ts),
(const char* (*)(void*))(gorocksdb_comparator_name),
ts_size);
}
/* CompactionFilter */
rocksdb_compactionfilter_t* gorocksdb_compactionfilter_create(uintptr_t idx) {
return rocksdb_compactionfilter_create(
(void*)idx,
gorocksdb_destruct_handler,
(unsigned char (*)(void*, int, const char*, size_t, const char*, size_t, char**, size_t*, unsigned char*))(gorocksdb_compactionfilter_filter),
(const char *(*)(void*))(gorocksdb_compactionfilter_name));
}
/* Merge Operator */
rocksdb_mergeoperator_t* gorocksdb_mergeoperator_create(uintptr_t idx) {
return rocksdb_mergeoperator_create(
(void*)idx,
gorocksdb_destruct_handler,
(char* (*)(void*, const char*, size_t, const char*, size_t, const char* const*, const size_t*, int, unsigned char*, size_t*))(gorocksdb_mergeoperator_full_merge),
(char* (*)(void*, const char*, size_t, const char* const*, const size_t*, int, unsigned char*, size_t*))(gorocksdb_mergeoperator_partial_merge_multi),
gorocksdb_mergeoperator_delete_value,
(const char* (*)(void*))(gorocksdb_mergeoperator_name));
}
void gorocksdb_mergeoperator_delete_value(void* id, const char* v, size_t s) {
free((char*)v);
}
/* Slice Transform */
rocksdb_slicetransform_t* gorocksdb_slicetransform_create(uintptr_t idx) {
return rocksdb_slicetransform_create(
(void*)idx,
gorocksdb_destruct_handler,
(char* (*)(void*, const char*, size_t, size_t*))(gorocksdb_slicetransform_transform),
(unsigned char (*)(void*, const char*, size_t))(gorocksdb_slicetransform_in_domain),
(unsigned char (*)(void*, const char*, size_t))(gorocksdb_slicetransform_in_range),
(const char* (*)(void*))(gorocksdb_slicetransform_name));
}