rdbpython 0.2.6__cp314-cp314-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rdbpy/.dylibs/libbz2.1.0.8.dylib +0 -0
- rdbpy/.dylibs/liblz4.1.9.4.dylib +0 -0
- rdbpy/.dylibs/libsnappy.1.2.1.dylib +0 -0
- rdbpy/.dylibs/libz.1.3.1.dylib +0 -0
- rdbpy/.dylibs/libzstd.1.5.6.dylib +0 -0
- rdbpy/__init__.py +1 -0
- rdbpy/backup.pxd +35 -0
- rdbpy/cache.pxd +8 -0
- rdbpy/comparator.pxd +23 -0
- rdbpy/db.pxd +230 -0
- rdbpy/env.pxd +5 -0
- rdbpy/errors.py +26 -0
- rdbpy/filter_policy.pxd +39 -0
- rdbpy/include/rdb_include/comparator_wrapper.hpp +63 -0
- rdbpy/include/rdb_include/filter_policy_wrapper.hpp +89 -0
- rdbpy/include/rdb_include/memtable_factories.hpp +15 -0
- rdbpy/include/rdb_include/merge_operator_wrapper.hpp +132 -0
- rdbpy/include/rdb_include/slice_transform_wrapper.hpp +109 -0
- rdbpy/include/rdb_include/utils.hpp +8 -0
- rdbpy/include/rdb_include/write_batch_iter_helper.hpp +65 -0
- rdbpy/interfaces.py +77 -0
- rdbpy/iterator.pxd +16 -0
- rdbpy/lib_rocksdb.cpython-314-darwin.so +0 -0
- rdbpy/lib_rocksdb.pxd +769 -0
- rdbpy/lib_rocksdb.pyi +1465 -0
- rdbpy/lib_rocksdb.pyx +3294 -0
- rdbpy/lib_utils.py +52 -0
- rdbpy/logger.pxd +5 -0
- rdbpy/memtablerep.pxd +12 -0
- rdbpy/merge_operator.pxd +46 -0
- rdbpy/merge_operators.py +25 -0
- rdbpy/options.pxd +179 -0
- rdbpy/slice_.pxd +20 -0
- rdbpy/slice_transform.pxd +37 -0
- rdbpy/snapshot.pxd +3 -0
- rdbpy/status.pxd +15 -0
- rdbpy/std_memory.pxd +7 -0
- rdbpy/table_factory.pxd +59 -0
- rdbpy/transaction.pxd +154 -0
- rdbpy/universal_compaction.pxd +15 -0
- rdbpython-0.2.6.dist-info/METADATA +98 -0
- rdbpython-0.2.6.dist-info/RECORD +45 -0
- rdbpython-0.2.6.dist-info/WHEEL +6 -0
- rdbpython-0.2.6.dist-info/licenses/LICENSE.md +201 -0
- rdbpython-0.2.6.dist-info/top_level.txt +1 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
rdbpy/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .lib_rocksdb import *
|
rdbpy/backup.pxd
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from libcpp cimport bool as cpp_bool
|
|
2
|
+
from libcpp.string cimport string
|
|
3
|
+
from libcpp.vector cimport vector
|
|
4
|
+
from libc.stdint cimport uint32_t
|
|
5
|
+
from libc.stdint cimport int64_t
|
|
6
|
+
from libc.stdint cimport uint64_t
|
|
7
|
+
|
|
8
|
+
from rdbpy.status cimport Status
|
|
9
|
+
from rdbpy.db cimport DB
|
|
10
|
+
from rdbpy.env cimport Env
|
|
11
|
+
|
|
12
|
+
cdef extern from "rocksdb/utilities/backup_engine.h" namespace "rocksdb":
|
|
13
|
+
ctypedef uint32_t BackupID
|
|
14
|
+
|
|
15
|
+
cdef cppclass BackupEngineOptions:
|
|
16
|
+
BackupEngineOptions(const string& backup_dir)
|
|
17
|
+
|
|
18
|
+
cdef struct BackupInfo:
|
|
19
|
+
BackupID backup_id
|
|
20
|
+
int64_t timestamp
|
|
21
|
+
uint64_t size
|
|
22
|
+
|
|
23
|
+
cdef cppclass BackupEngine:
|
|
24
|
+
Status CreateNewBackup(DB*, cpp_bool) nogil except+
|
|
25
|
+
Status PurgeOldBackups(uint32_t) nogil except+
|
|
26
|
+
Status DeleteBackup(BackupID) nogil except+
|
|
27
|
+
void StopBackup() nogil except+
|
|
28
|
+
void GetBackupInfo(vector[BackupInfo]*) nogil except+
|
|
29
|
+
Status RestoreDBFromBackup(BackupID, string&, string&) nogil except+
|
|
30
|
+
Status RestoreDBFromLatestBackup(string&, string&) nogil except+
|
|
31
|
+
|
|
32
|
+
cdef Status BackupEngine_Open "rocksdb::BackupEngine::Open"(
|
|
33
|
+
Env*,
|
|
34
|
+
BackupEngineOptions&,
|
|
35
|
+
BackupEngine**)
|
rdbpy/cache.pxd
ADDED
rdbpy/comparator.pxd
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from libcpp.string cimport string
|
|
2
|
+
from rdbpy.slice_ cimport Slice
|
|
3
|
+
from rdbpy.logger cimport Logger
|
|
4
|
+
from rdbpy.std_memory cimport shared_ptr
|
|
5
|
+
|
|
6
|
+
cdef extern from "rocksdb/comparator.h" namespace "rocksdb":
|
|
7
|
+
cdef cppclass Comparator:
|
|
8
|
+
const char* Name()
|
|
9
|
+
int Compare(const Slice&, const Slice&) const
|
|
10
|
+
|
|
11
|
+
cdef extern const Comparator* BytewiseComparator() nogil except +
|
|
12
|
+
|
|
13
|
+
ctypedef int (*compare_func)(
|
|
14
|
+
void*,
|
|
15
|
+
Logger*,
|
|
16
|
+
string&,
|
|
17
|
+
const Slice&,
|
|
18
|
+
const Slice&)
|
|
19
|
+
|
|
20
|
+
cdef extern from "rdb_include/comparator_wrapper.hpp" namespace "py_rocks":
|
|
21
|
+
cdef cppclass ComparatorWrapper:
|
|
22
|
+
ComparatorWrapper(string, void*, compare_func) nogil except +
|
|
23
|
+
void set_info_log(shared_ptr[Logger]) nogil except+
|
rdbpy/db.pxd
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
cimport rdbpy.options as options
|
|
2
|
+
from libc.stdint cimport uint64_t, uint32_t
|
|
3
|
+
from rdbpy.status cimport Status
|
|
4
|
+
from libcpp cimport bool as cpp_bool
|
|
5
|
+
from libcpp.string cimport string
|
|
6
|
+
from libcpp.vector cimport vector
|
|
7
|
+
from rdbpy.slice_ cimport Slice
|
|
8
|
+
from rdbpy.snapshot cimport Snapshot
|
|
9
|
+
from rdbpy.iterator cimport Iterator
|
|
10
|
+
|
|
11
|
+
cdef extern from "rocksdb/write_batch.h" namespace "rocksdb":
|
|
12
|
+
cdef cppclass WriteBatch:
|
|
13
|
+
WriteBatch() nogil except+
|
|
14
|
+
WriteBatch(string) nogil except+
|
|
15
|
+
void Put(const Slice&, const Slice&) nogil except+
|
|
16
|
+
void Put(ColumnFamilyHandle*, const Slice&, const Slice&) nogil except+
|
|
17
|
+
void Merge(const Slice&, const Slice&) nogil except+
|
|
18
|
+
void Merge(ColumnFamilyHandle*, const Slice&, const Slice&) nogil except+
|
|
19
|
+
void Delete(const Slice&) nogil except+
|
|
20
|
+
void Delete(ColumnFamilyHandle*, const Slice&) nogil except+
|
|
21
|
+
void DeleteRange(const Slice&, const Slice&) nogil except+
|
|
22
|
+
void DeleteRange(ColumnFamilyHandle*, const Slice&, const Slice&) nogil except+
|
|
23
|
+
void PutLogData(const Slice&) nogil except+
|
|
24
|
+
void Clear() nogil except+
|
|
25
|
+
const string& Data() nogil except+
|
|
26
|
+
int Count() nogil except+
|
|
27
|
+
|
|
28
|
+
cdef extern from "rdb_include/write_batch_iter_helper.hpp" namespace "py_rocks":
|
|
29
|
+
cdef enum BatchItemOp "RecordItemsHandler::Optype":
|
|
30
|
+
BatchItemOpPut "py_rocks::RecordItemsHandler::Optype::PutRecord"
|
|
31
|
+
BatchItemOpMerge "py_rocks::RecordItemsHandler::Optype::MergeRecord"
|
|
32
|
+
BatchItemOpDelte "py_rocks::RecordItemsHandler::Optype::DeleteRecord"
|
|
33
|
+
|
|
34
|
+
cdef cppclass BatchItem "py_rocks::RecordItemsHandler::BatchItem":
|
|
35
|
+
BatchItemOp op
|
|
36
|
+
uint32_t column_family_id
|
|
37
|
+
Slice key
|
|
38
|
+
Slice value
|
|
39
|
+
|
|
40
|
+
Status get_batch_items(WriteBatch* batch, vector[BatchItem]* items)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
cdef extern from "rocksdb/db.h" namespace "rocksdb":
|
|
44
|
+
ctypedef uint64_t SequenceNumber
|
|
45
|
+
string kDefaultColumnFamilyName
|
|
46
|
+
|
|
47
|
+
cdef struct LiveFileMetaData:
|
|
48
|
+
string name
|
|
49
|
+
int level
|
|
50
|
+
uint64_t size
|
|
51
|
+
string smallestkey
|
|
52
|
+
string largestkey
|
|
53
|
+
SequenceNumber smallest_seqno
|
|
54
|
+
SequenceNumber largest_seqno
|
|
55
|
+
|
|
56
|
+
cdef cppclass Range:
|
|
57
|
+
Range(const Slice&, const Slice&)
|
|
58
|
+
|
|
59
|
+
cdef cppclass DB:
|
|
60
|
+
Status Put(
|
|
61
|
+
const options.WriteOptions&,
|
|
62
|
+
ColumnFamilyHandle*,
|
|
63
|
+
const Slice&,
|
|
64
|
+
const Slice&) nogil except+
|
|
65
|
+
|
|
66
|
+
Status Delete(
|
|
67
|
+
const options.WriteOptions&,
|
|
68
|
+
ColumnFamilyHandle*,
|
|
69
|
+
const Slice&) nogil except+
|
|
70
|
+
|
|
71
|
+
Status DeleteRange(
|
|
72
|
+
const options.WriteOptions&,
|
|
73
|
+
ColumnFamilyHandle*,
|
|
74
|
+
const Slice&,
|
|
75
|
+
const Slice&) nogil except+
|
|
76
|
+
|
|
77
|
+
Status Merge(
|
|
78
|
+
const options.WriteOptions&,
|
|
79
|
+
ColumnFamilyHandle*,
|
|
80
|
+
const Slice&,
|
|
81
|
+
const Slice&) nogil except+
|
|
82
|
+
|
|
83
|
+
Status Write(
|
|
84
|
+
const options.WriteOptions&,
|
|
85
|
+
WriteBatch*) nogil except+
|
|
86
|
+
|
|
87
|
+
Status Get(
|
|
88
|
+
const options.ReadOptions&,
|
|
89
|
+
ColumnFamilyHandle*,
|
|
90
|
+
const Slice&,
|
|
91
|
+
string*) nogil except+
|
|
92
|
+
|
|
93
|
+
vector[Status] MultiGet(
|
|
94
|
+
const options.ReadOptions&,
|
|
95
|
+
const vector[ColumnFamilyHandle*]&,
|
|
96
|
+
const vector[Slice]&,
|
|
97
|
+
vector[string]*) nogil except+
|
|
98
|
+
|
|
99
|
+
cpp_bool KeyMayExist(
|
|
100
|
+
const options.ReadOptions&,
|
|
101
|
+
ColumnFamilyHandle*,
|
|
102
|
+
Slice&,
|
|
103
|
+
string*,
|
|
104
|
+
cpp_bool*) nogil except+
|
|
105
|
+
|
|
106
|
+
cpp_bool KeyMayExist(
|
|
107
|
+
const options.ReadOptions&,
|
|
108
|
+
ColumnFamilyHandle*,
|
|
109
|
+
Slice&,
|
|
110
|
+
string*) nogil except+
|
|
111
|
+
|
|
112
|
+
Iterator* NewIterator(
|
|
113
|
+
const options.ReadOptions&,
|
|
114
|
+
ColumnFamilyHandle*) nogil except+
|
|
115
|
+
|
|
116
|
+
void NewIterators(
|
|
117
|
+
const options.ReadOptions&,
|
|
118
|
+
vector[ColumnFamilyHandle*]&,
|
|
119
|
+
vector[Iterator*]*) nogil except+
|
|
120
|
+
|
|
121
|
+
const Snapshot* GetSnapshot() nogil except+
|
|
122
|
+
|
|
123
|
+
void ReleaseSnapshot(const Snapshot*) nogil except+
|
|
124
|
+
|
|
125
|
+
cpp_bool GetProperty(
|
|
126
|
+
ColumnFamilyHandle*,
|
|
127
|
+
const Slice&,
|
|
128
|
+
string*) nogil except+
|
|
129
|
+
|
|
130
|
+
void GetApproximateSizes(
|
|
131
|
+
ColumnFamilyHandle*,
|
|
132
|
+
const Range*
|
|
133
|
+
int,
|
|
134
|
+
uint64_t*) nogil except+
|
|
135
|
+
|
|
136
|
+
Status CompactRange(
|
|
137
|
+
const options.CompactRangeOptions&,
|
|
138
|
+
ColumnFamilyHandle*,
|
|
139
|
+
const Slice*,
|
|
140
|
+
const Slice*) nogil except+
|
|
141
|
+
|
|
142
|
+
Status CreateColumnFamily(
|
|
143
|
+
const options.ColumnFamilyOptions&,
|
|
144
|
+
const string&,
|
|
145
|
+
ColumnFamilyHandle**) nogil except+
|
|
146
|
+
|
|
147
|
+
Status DropColumnFamily(
|
|
148
|
+
ColumnFamilyHandle*) nogil except+
|
|
149
|
+
|
|
150
|
+
int NumberLevels(ColumnFamilyHandle*) nogil except+
|
|
151
|
+
int MaxMemCompactionLevel(ColumnFamilyHandle*) nogil except+
|
|
152
|
+
int Level0StopWriteTrigger(ColumnFamilyHandle*) nogil except+
|
|
153
|
+
const string& GetName() nogil except+
|
|
154
|
+
const options.Options& GetOptions(ColumnFamilyHandle*) nogil except+
|
|
155
|
+
Status Flush(const options.FlushOptions&, ColumnFamilyHandle*) nogil except+
|
|
156
|
+
Status FlushWAL(cpp_bool sync) nogil except+
|
|
157
|
+
Status DisableFileDeletions() nogil except+
|
|
158
|
+
Status EnableFileDeletions() nogil except+
|
|
159
|
+
|
|
160
|
+
Status TryCatchUpWithPrimary() nogil except+
|
|
161
|
+
|
|
162
|
+
# TODO: Status GetSortedWalFiles(VectorLogPtr& files)
|
|
163
|
+
# TODO: SequenceNumber GetLatestSequenceNumber()
|
|
164
|
+
# TODO: Status GetUpdatesSince(
|
|
165
|
+
# SequenceNumber seq_number,
|
|
166
|
+
# unique_ptr[TransactionLogIterator]*)
|
|
167
|
+
|
|
168
|
+
Status DeleteFile(string) nogil except+
|
|
169
|
+
void GetLiveFilesMetaData(vector[LiveFileMetaData]*) nogil except+
|
|
170
|
+
ColumnFamilyHandle* DefaultColumnFamily()
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
cdef Status DB_Open "rocksdb::DB::Open"(
|
|
174
|
+
const options.Options&,
|
|
175
|
+
const string&,
|
|
176
|
+
DB**) nogil except+
|
|
177
|
+
|
|
178
|
+
cdef Status DB_Open_ColumnFamilies "rocksdb::DB::Open"(
|
|
179
|
+
const options.Options&,
|
|
180
|
+
const string&,
|
|
181
|
+
const vector[ColumnFamilyDescriptor]&,
|
|
182
|
+
vector[ColumnFamilyHandle*]*,
|
|
183
|
+
DB**) nogil except+
|
|
184
|
+
|
|
185
|
+
cdef Status DB_OpenForReadOnly "rocksdb::DB::OpenForReadOnly"(
|
|
186
|
+
const options.Options&,
|
|
187
|
+
const string&,
|
|
188
|
+
DB**,
|
|
189
|
+
cpp_bool) nogil except+
|
|
190
|
+
|
|
191
|
+
cdef Status DB_OpenForReadOnly_ColumnFamilies "rocksdb::DB::OpenForReadOnly"(
|
|
192
|
+
const options.Options&,
|
|
193
|
+
const string&,
|
|
194
|
+
const vector[ColumnFamilyDescriptor]&,
|
|
195
|
+
vector[ColumnFamilyHandle*]*,
|
|
196
|
+
DB**,
|
|
197
|
+
cpp_bool) nogil except+
|
|
198
|
+
|
|
199
|
+
cdef Status DB_OpenAsSecondary "rocksdb::DB::OpenAsSecondary"(
|
|
200
|
+
const options.Options&,
|
|
201
|
+
const string&,
|
|
202
|
+
const string&,
|
|
203
|
+
DB**) nogil except+
|
|
204
|
+
|
|
205
|
+
cdef Status DB_OpenAsSecondary_ColumnFamilies "rocksdb::DB::OpenAsSecondary"(
|
|
206
|
+
const options.Options&,
|
|
207
|
+
const string&,
|
|
208
|
+
const string&,
|
|
209
|
+
const vector[ColumnFamilyDescriptor]&,
|
|
210
|
+
vector[ColumnFamilyHandle*]*,
|
|
211
|
+
DB**) nogil except+
|
|
212
|
+
|
|
213
|
+
cdef Status RepairDB(const string& dbname, const options.Options&)
|
|
214
|
+
|
|
215
|
+
cdef Status ListColumnFamilies "rocksdb::DB::ListColumnFamilies" (
|
|
216
|
+
const options.Options&,
|
|
217
|
+
const string&,
|
|
218
|
+
vector[string]*) nogil except+
|
|
219
|
+
|
|
220
|
+
cdef cppclass ColumnFamilyHandle:
|
|
221
|
+
const string& GetName() nogil except+
|
|
222
|
+
int GetID() nogil except+
|
|
223
|
+
|
|
224
|
+
cdef cppclass ColumnFamilyDescriptor:
|
|
225
|
+
ColumnFamilyDescriptor() nogil except+
|
|
226
|
+
ColumnFamilyDescriptor(
|
|
227
|
+
const string&,
|
|
228
|
+
const options.ColumnFamilyOptions&) nogil except+
|
|
229
|
+
string name
|
|
230
|
+
options.ColumnFamilyOptions options
|
rdbpy/env.pxd
ADDED
rdbpy/errors.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class NotFound(Exception):
|
|
2
|
+
pass
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Corruption(Exception):
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class NotSupported(Exception):
|
|
10
|
+
pass
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class InvalidArgument(Exception):
|
|
14
|
+
pass
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class RocksIOError(Exception):
|
|
18
|
+
pass
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class MergeInProgress(Exception):
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class Incomplete(Exception):
|
|
26
|
+
pass
|
rdbpy/filter_policy.pxd
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from libcpp cimport bool as cpp_bool
|
|
2
|
+
from libcpp.string cimport string
|
|
3
|
+
from libc.string cimport const_char
|
|
4
|
+
from rdbpy.slice_ cimport Slice
|
|
5
|
+
from rdbpy.std_memory cimport shared_ptr
|
|
6
|
+
from rdbpy.logger cimport Logger
|
|
7
|
+
|
|
8
|
+
cdef extern from "rocksdb/filter_policy.h" namespace "rocksdb":
|
|
9
|
+
cdef cppclass FilterPolicy:
|
|
10
|
+
void CreateFilter(const Slice*, int, string*) nogil except+
|
|
11
|
+
cpp_bool KeyMayMatch(const Slice&, const Slice&) nogil except+
|
|
12
|
+
const_char* Name() nogil except+
|
|
13
|
+
|
|
14
|
+
cdef extern const FilterPolicy* NewBloomFilterPolicy(int) nogil except+
|
|
15
|
+
|
|
16
|
+
ctypedef void (*create_filter_func)(
|
|
17
|
+
void*,
|
|
18
|
+
Logger*,
|
|
19
|
+
string&,
|
|
20
|
+
const Slice*,
|
|
21
|
+
int,
|
|
22
|
+
string*)
|
|
23
|
+
|
|
24
|
+
ctypedef cpp_bool (*key_may_match_func)(
|
|
25
|
+
void*,
|
|
26
|
+
Logger*,
|
|
27
|
+
string&,
|
|
28
|
+
const Slice&,
|
|
29
|
+
const Slice&)
|
|
30
|
+
|
|
31
|
+
cdef extern from "rdb_include/filter_policy_wrapper.hpp" namespace "py_rocks":
|
|
32
|
+
cdef cppclass FilterPolicyWrapper:
|
|
33
|
+
FilterPolicyWrapper(
|
|
34
|
+
string,
|
|
35
|
+
void*,
|
|
36
|
+
create_filter_func,
|
|
37
|
+
key_may_match_func) nogil except+
|
|
38
|
+
|
|
39
|
+
void set_info_log(shared_ptr[Logger]) nogil except+
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#include "rocksdb/comparator.h"
|
|
2
|
+
#include "rocksdb/env.h"
|
|
3
|
+
#include <stdexcept>
|
|
4
|
+
|
|
5
|
+
using std::string;
|
|
6
|
+
using rocksdb::Comparator;
|
|
7
|
+
using rocksdb::Slice;
|
|
8
|
+
using rocksdb::Logger;
|
|
9
|
+
|
|
10
|
+
namespace py_rocks {
|
|
11
|
+
class ComparatorWrapper: public Comparator {
|
|
12
|
+
public:
|
|
13
|
+
typedef int (*compare_func)(
|
|
14
|
+
void*,
|
|
15
|
+
Logger*,
|
|
16
|
+
string&,
|
|
17
|
+
const Slice&,
|
|
18
|
+
const Slice&);
|
|
19
|
+
|
|
20
|
+
ComparatorWrapper(
|
|
21
|
+
string name,
|
|
22
|
+
void* compare_context,
|
|
23
|
+
compare_func compare_callback):
|
|
24
|
+
name(name),
|
|
25
|
+
compare_context(compare_context),
|
|
26
|
+
compare_callback(compare_callback)
|
|
27
|
+
{}
|
|
28
|
+
|
|
29
|
+
virtual int Compare(const Slice& a, const Slice& b) const {
|
|
30
|
+
string error_msg;
|
|
31
|
+
int val;
|
|
32
|
+
|
|
33
|
+
val = this->compare_callback(
|
|
34
|
+
this->compare_context,
|
|
35
|
+
this->info_log.get(),
|
|
36
|
+
error_msg,
|
|
37
|
+
a,
|
|
38
|
+
b);
|
|
39
|
+
|
|
40
|
+
if (error_msg.size()) {
|
|
41
|
+
throw std::runtime_error(error_msg.c_str());
|
|
42
|
+
}
|
|
43
|
+
return val;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
virtual const char* Name() const {
|
|
47
|
+
return this->name.c_str();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
virtual void FindShortestSeparator(string*, const Slice&) const {}
|
|
51
|
+
virtual void FindShortSuccessor(string*) const {}
|
|
52
|
+
|
|
53
|
+
void set_info_log(std::shared_ptr<Logger> info_log) {
|
|
54
|
+
this->info_log = info_log;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private:
|
|
58
|
+
string name;
|
|
59
|
+
void* compare_context;
|
|
60
|
+
compare_func compare_callback;
|
|
61
|
+
std::shared_ptr<Logger> info_log;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#include "rocksdb/filter_policy.h"
|
|
2
|
+
#include "rocksdb/env.h"
|
|
3
|
+
#include <stdexcept>
|
|
4
|
+
|
|
5
|
+
using std::string;
|
|
6
|
+
using rocksdb::FilterPolicy;
|
|
7
|
+
using rocksdb::Slice;
|
|
8
|
+
using rocksdb::Logger;
|
|
9
|
+
|
|
10
|
+
namespace py_rocks {
|
|
11
|
+
class FilterPolicyWrapper: public FilterPolicy {
|
|
12
|
+
public:
|
|
13
|
+
typedef void (*create_filter_func)(
|
|
14
|
+
void* ctx,
|
|
15
|
+
Logger*,
|
|
16
|
+
string&,
|
|
17
|
+
const Slice* keys,
|
|
18
|
+
int n,
|
|
19
|
+
string* dst);
|
|
20
|
+
|
|
21
|
+
typedef bool (*key_may_match_func)(
|
|
22
|
+
void* ctx,
|
|
23
|
+
Logger*,
|
|
24
|
+
string&,
|
|
25
|
+
const Slice& key,
|
|
26
|
+
const Slice& filter);
|
|
27
|
+
|
|
28
|
+
FilterPolicyWrapper(
|
|
29
|
+
string name,
|
|
30
|
+
void* ctx,
|
|
31
|
+
create_filter_func create_filter_callback,
|
|
32
|
+
key_may_match_func key_may_match_callback):
|
|
33
|
+
name(name),
|
|
34
|
+
ctx(ctx),
|
|
35
|
+
create_filter_callback(create_filter_callback),
|
|
36
|
+
key_may_match_callback(key_may_match_callback)
|
|
37
|
+
{}
|
|
38
|
+
|
|
39
|
+
virtual void
|
|
40
|
+
CreateFilter(const Slice* keys, int n, std::string* dst) const {
|
|
41
|
+
string error_msg;
|
|
42
|
+
|
|
43
|
+
this->create_filter_callback(
|
|
44
|
+
this->ctx,
|
|
45
|
+
this->info_log.get(),
|
|
46
|
+
error_msg,
|
|
47
|
+
keys,
|
|
48
|
+
n,
|
|
49
|
+
dst);
|
|
50
|
+
|
|
51
|
+
if (error_msg.size()) {
|
|
52
|
+
throw std::runtime_error(error_msg.c_str());
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
virtual bool
|
|
57
|
+
KeyMayMatch(const Slice& key, const Slice& filter) const {
|
|
58
|
+
string error_msg;
|
|
59
|
+
bool val;
|
|
60
|
+
|
|
61
|
+
val = this->key_may_match_callback(
|
|
62
|
+
this->ctx,
|
|
63
|
+
this->info_log.get(),
|
|
64
|
+
error_msg,
|
|
65
|
+
key,
|
|
66
|
+
filter);
|
|
67
|
+
|
|
68
|
+
if (error_msg.size()) {
|
|
69
|
+
throw std::runtime_error(error_msg.c_str());
|
|
70
|
+
}
|
|
71
|
+
return val;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
virtual const char* Name() const {
|
|
75
|
+
return this->name.c_str();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
void set_info_log(std::shared_ptr<Logger> info_log) {
|
|
79
|
+
this->info_log = info_log;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
private:
|
|
83
|
+
string name;
|
|
84
|
+
void* ctx;
|
|
85
|
+
create_filter_func create_filter_callback;
|
|
86
|
+
key_may_match_func key_may_match_callback;
|
|
87
|
+
std::shared_ptr<Logger> info_log;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#include "rocksdb/memtablerep.h"
|
|
2
|
+
|
|
3
|
+
using rocksdb::MemTableRepFactory;
|
|
4
|
+
using rocksdb::VectorRepFactory;
|
|
5
|
+
using rocksdb::SkipListFactory;
|
|
6
|
+
|
|
7
|
+
namespace py_rocks {
|
|
8
|
+
MemTableRepFactory* NewVectorRepFactory(size_t count = 0) {
|
|
9
|
+
return new VectorRepFactory(count);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
MemTableRepFactory* NewSkipListFactory() {
|
|
13
|
+
return new SkipListFactory();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#include "rocksdb/merge_operator.h"
|
|
2
|
+
|
|
3
|
+
using std::string;
|
|
4
|
+
using std::deque;
|
|
5
|
+
using rocksdb::Slice;
|
|
6
|
+
using rocksdb::Logger;
|
|
7
|
+
using rocksdb::MergeOperator;
|
|
8
|
+
using rocksdb::AssociativeMergeOperator;
|
|
9
|
+
|
|
10
|
+
namespace py_rocks {
|
|
11
|
+
class AssociativeMergeOperatorWrapper: public AssociativeMergeOperator {
|
|
12
|
+
public:
|
|
13
|
+
typedef bool (*merge_func)(
|
|
14
|
+
void*,
|
|
15
|
+
const Slice& key,
|
|
16
|
+
const Slice* existing_value,
|
|
17
|
+
const Slice& value,
|
|
18
|
+
std::string* new_value,
|
|
19
|
+
Logger* logger);
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
AssociativeMergeOperatorWrapper(
|
|
23
|
+
string name,
|
|
24
|
+
void* merge_context,
|
|
25
|
+
merge_func merge_callback):
|
|
26
|
+
name(name),
|
|
27
|
+
merge_context(merge_context),
|
|
28
|
+
merge_callback(merge_callback)
|
|
29
|
+
{}
|
|
30
|
+
|
|
31
|
+
virtual bool Merge(
|
|
32
|
+
const Slice& key,
|
|
33
|
+
const Slice* existing_value,
|
|
34
|
+
const Slice& value,
|
|
35
|
+
std::string* new_value,
|
|
36
|
+
Logger* logger) const
|
|
37
|
+
{
|
|
38
|
+
return this->merge_callback(
|
|
39
|
+
this->merge_context,
|
|
40
|
+
key,
|
|
41
|
+
existing_value,
|
|
42
|
+
value,
|
|
43
|
+
new_value,
|
|
44
|
+
logger);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
virtual const char* Name() const {
|
|
48
|
+
return this->name.c_str();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private:
|
|
52
|
+
string name;
|
|
53
|
+
void* merge_context;
|
|
54
|
+
merge_func merge_callback;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
class MergeOperatorWrapper: public MergeOperator {
|
|
58
|
+
public:
|
|
59
|
+
typedef bool (*full_merge_func)(
|
|
60
|
+
void* ctx,
|
|
61
|
+
const Slice& key,
|
|
62
|
+
const Slice* existing_value,
|
|
63
|
+
const deque<string>& operand_list,
|
|
64
|
+
string* new_value,
|
|
65
|
+
Logger* logger);
|
|
66
|
+
|
|
67
|
+
typedef bool (*partial_merge_func)(
|
|
68
|
+
void* ctx,
|
|
69
|
+
const Slice& key,
|
|
70
|
+
const Slice& left_op,
|
|
71
|
+
const Slice& right_op,
|
|
72
|
+
string* new_value,
|
|
73
|
+
Logger* logger);
|
|
74
|
+
|
|
75
|
+
MergeOperatorWrapper(
|
|
76
|
+
string name,
|
|
77
|
+
void* full_merge_context,
|
|
78
|
+
void* partial_merge_context,
|
|
79
|
+
full_merge_func full_merge_callback,
|
|
80
|
+
partial_merge_func partial_merge_callback):
|
|
81
|
+
name(name),
|
|
82
|
+
full_merge_context(full_merge_context),
|
|
83
|
+
partial_merge_context(partial_merge_context),
|
|
84
|
+
full_merge_callback(full_merge_callback),
|
|
85
|
+
partial_merge_callback(partial_merge_callback)
|
|
86
|
+
{}
|
|
87
|
+
|
|
88
|
+
virtual bool FullMerge(
|
|
89
|
+
const Slice& key,
|
|
90
|
+
const Slice* existing_value,
|
|
91
|
+
const deque<string>& operand_list,
|
|
92
|
+
string* new_value,
|
|
93
|
+
Logger* logger) const
|
|
94
|
+
{
|
|
95
|
+
return this->full_merge_callback(
|
|
96
|
+
this->full_merge_context,
|
|
97
|
+
key,
|
|
98
|
+
existing_value,
|
|
99
|
+
operand_list,
|
|
100
|
+
new_value,
|
|
101
|
+
logger);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
virtual bool PartialMerge (
|
|
105
|
+
const Slice& key,
|
|
106
|
+
const Slice& left_operand,
|
|
107
|
+
const Slice& right_operand,
|
|
108
|
+
string* new_value,
|
|
109
|
+
Logger* logger) const
|
|
110
|
+
{
|
|
111
|
+
return this->partial_merge_callback(
|
|
112
|
+
this->partial_merge_context,
|
|
113
|
+
key,
|
|
114
|
+
left_operand,
|
|
115
|
+
right_operand,
|
|
116
|
+
new_value,
|
|
117
|
+
logger);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
virtual const char* Name() const {
|
|
121
|
+
return this->name.c_str();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
private:
|
|
125
|
+
string name;
|
|
126
|
+
void* full_merge_context;
|
|
127
|
+
void* partial_merge_context;
|
|
128
|
+
full_merge_func full_merge_callback;
|
|
129
|
+
partial_merge_func partial_merge_callback;
|
|
130
|
+
|
|
131
|
+
};
|
|
132
|
+
}
|