rdbpython 0.2.1__cp313-cp313-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-313-darwin.so +0 -0
- rdbpy/lib_rocksdb.pxd +768 -0
- rdbpy/lib_rocksdb.pyi +1465 -0
- rdbpy/lib_rocksdb.pyx +3221 -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 +50 -0
- rdbpy/transaction.pxd +154 -0
- rdbpy/universal_compaction.pxd +15 -0
- rdbpython-0.2.1.dist-info/METADATA +104 -0
- rdbpython-0.2.1.dist-info/RECORD +45 -0
- rdbpython-0.2.1.dist-info/WHEEL +5 -0
- rdbpython-0.2.1.dist-info/licenses/LICENSE.md +21 -0
- rdbpython-0.2.1.dist-info/top_level.txt +1 -0
rdbpy/lib_utils.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import ctypes
|
|
2
|
+
import os
|
|
3
|
+
import platform
|
|
4
|
+
from glob import glob
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def get_include_dir():
|
|
8
|
+
dirname = os.path.dirname(__file__)
|
|
9
|
+
abs_dirname = os.path.abspath(dirname)
|
|
10
|
+
path = os.path.join(abs_dirname, "include")
|
|
11
|
+
return path
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def get_lib_dir():
|
|
15
|
+
dirname = os.path.dirname(__file__)
|
|
16
|
+
abs_dirname = os.path.abspath(dirname)
|
|
17
|
+
path = abs_dirname
|
|
18
|
+
return path
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def get_libs():
|
|
22
|
+
return [
|
|
23
|
+
"rocksdb",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def get_lib_filename(name, lib_dir):
|
|
28
|
+
if platform.system() == "Darwin":
|
|
29
|
+
pattern = f"lib{name}*.dylib"
|
|
30
|
+
else:
|
|
31
|
+
pattern = f"lib{name}*.so*"
|
|
32
|
+
|
|
33
|
+
files = glob(os.path.join(lib_dir, pattern))
|
|
34
|
+
assert len(files) == 1
|
|
35
|
+
return os.path.basename(files[0])
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def get_lib_filenames():
|
|
39
|
+
local_lib_dir = get_lib_dir()
|
|
40
|
+
return [get_lib_filename(name, local_lib_dir) for name in get_libs()]
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def load_lib(filename) -> None:
|
|
44
|
+
local_lib_dir = get_lib_dir()
|
|
45
|
+
path = os.path.join(local_lib_dir, filename)
|
|
46
|
+
print(f"Loading runtime library from {path}")
|
|
47
|
+
ctypes.CDLL(path)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def load_libs() -> None:
|
|
51
|
+
for filename in get_lib_filenames():
|
|
52
|
+
load_lib(filename)
|
rdbpy/logger.pxd
ADDED
rdbpy/memtablerep.pxd
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from libc.stdint cimport int32_t
|
|
2
|
+
|
|
3
|
+
cdef extern from "rocksdb/memtablerep.h" namespace "rocksdb":
|
|
4
|
+
cdef cppclass MemTableRepFactory:
|
|
5
|
+
MemTableRepFactory()
|
|
6
|
+
|
|
7
|
+
cdef MemTableRepFactory* NewHashSkipListRepFactory(size_t, int32_t, int32_t)
|
|
8
|
+
cdef MemTableRepFactory* NewHashLinkListRepFactory(size_t)
|
|
9
|
+
|
|
10
|
+
cdef extern from "rdb_include/memtable_factories.hpp" namespace "py_rocks":
|
|
11
|
+
cdef MemTableRepFactory* NewVectorRepFactory(size_t)
|
|
12
|
+
cdef MemTableRepFactory* NewSkipListFactory()
|
rdbpy/merge_operator.pxd
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from libcpp.string cimport string
|
|
2
|
+
from libcpp cimport bool as cpp_bool
|
|
3
|
+
from libcpp.deque cimport deque
|
|
4
|
+
from rdbpy.slice_ cimport Slice
|
|
5
|
+
from rdbpy.logger cimport Logger
|
|
6
|
+
from rdbpy.std_memory cimport shared_ptr
|
|
7
|
+
|
|
8
|
+
cdef extern from "rocksdb/merge_operator.h" namespace "rocksdb":
|
|
9
|
+
cdef cppclass MergeOperator:
|
|
10
|
+
pass
|
|
11
|
+
|
|
12
|
+
ctypedef cpp_bool (*merge_func)(
|
|
13
|
+
void*,
|
|
14
|
+
const Slice&,
|
|
15
|
+
const Slice*,
|
|
16
|
+
const Slice&,
|
|
17
|
+
string*,
|
|
18
|
+
Logger*)
|
|
19
|
+
|
|
20
|
+
ctypedef cpp_bool (*full_merge_func)(
|
|
21
|
+
void* ctx,
|
|
22
|
+
const Slice& key,
|
|
23
|
+
const Slice* existing_value,
|
|
24
|
+
const deque[string]& operand_list,
|
|
25
|
+
string* new_value,
|
|
26
|
+
Logger* logger)
|
|
27
|
+
|
|
28
|
+
ctypedef cpp_bool (*partial_merge_func)(
|
|
29
|
+
void* ctx,
|
|
30
|
+
const Slice& key,
|
|
31
|
+
const Slice& left_op,
|
|
32
|
+
const Slice& right_op,
|
|
33
|
+
string* new_value,
|
|
34
|
+
Logger* logger)
|
|
35
|
+
|
|
36
|
+
cdef extern from "rdb_include/merge_operator_wrapper.hpp" namespace "py_rocks":
|
|
37
|
+
cdef cppclass AssociativeMergeOperatorWrapper:
|
|
38
|
+
AssociativeMergeOperatorWrapper(string, void*, merge_func) nogil except+
|
|
39
|
+
|
|
40
|
+
cdef cppclass MergeOperatorWrapper:
|
|
41
|
+
MergeOperatorWrapper(
|
|
42
|
+
string,
|
|
43
|
+
void*,
|
|
44
|
+
void*,
|
|
45
|
+
full_merge_func,
|
|
46
|
+
partial_merge_func) nogil except+
|
rdbpy/merge_operators.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import struct as py_struct
|
|
2
|
+
|
|
3
|
+
from rdbpy.interfaces import AssociativeMergeOperator
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class UintAddOperator(AssociativeMergeOperator):
|
|
7
|
+
def merge(self, key, existing_value, value):
|
|
8
|
+
if existing_value:
|
|
9
|
+
s = py_struct.unpack("Q", existing_value)[0] + py_struct.unpack("Q", value)[0]
|
|
10
|
+
return (True, py_struct.pack("Q", s))
|
|
11
|
+
return (True, value)
|
|
12
|
+
|
|
13
|
+
def name(self) -> bytes:
|
|
14
|
+
return b"uint64add"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class StringAppendOperator(AssociativeMergeOperator):
|
|
18
|
+
def merge(self, key, existing_value, value):
|
|
19
|
+
if existing_value:
|
|
20
|
+
s = existing_value + b"," + value
|
|
21
|
+
return (True, s)
|
|
22
|
+
return (True, value)
|
|
23
|
+
|
|
24
|
+
def name(self) -> bytes:
|
|
25
|
+
return b"StringAppendOperator"
|
rdbpy/options.pxd
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
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 uint64_t
|
|
5
|
+
from libc.stdint cimport uint32_t
|
|
6
|
+
from rdbpy.std_memory cimport shared_ptr
|
|
7
|
+
from rdbpy.comparator cimport Comparator
|
|
8
|
+
from rdbpy.merge_operator cimport MergeOperator
|
|
9
|
+
from rdbpy.logger cimport Logger
|
|
10
|
+
from rdbpy.slice_ cimport Slice
|
|
11
|
+
from rdbpy.snapshot cimport Snapshot
|
|
12
|
+
from rdbpy.slice_transform cimport SliceTransform
|
|
13
|
+
from rdbpy.table_factory cimport TableFactory
|
|
14
|
+
from rdbpy.memtablerep cimport MemTableRepFactory
|
|
15
|
+
from rdbpy.universal_compaction cimport CompactionOptionsUniversal
|
|
16
|
+
from rdbpy.cache cimport Cache
|
|
17
|
+
|
|
18
|
+
cdef extern from "rocksdb/options.h" namespace "rocksdb":
|
|
19
|
+
cdef cppclass CompressionOptions:
|
|
20
|
+
int window_bits;
|
|
21
|
+
int level;
|
|
22
|
+
int strategy;
|
|
23
|
+
uint32_t max_dict_bytes
|
|
24
|
+
CompressionOptions() except +
|
|
25
|
+
CompressionOptions(int, int, int, int) except +
|
|
26
|
+
|
|
27
|
+
ctypedef enum CompactionStyle:
|
|
28
|
+
kCompactionStyleLevel
|
|
29
|
+
kCompactionStyleUniversal
|
|
30
|
+
kCompactionStyleFIFO
|
|
31
|
+
kCompactionStyleNone
|
|
32
|
+
|
|
33
|
+
ctypedef enum CompressionType:
|
|
34
|
+
kNoCompression
|
|
35
|
+
kSnappyCompression
|
|
36
|
+
kZlibCompression
|
|
37
|
+
kBZip2Compression
|
|
38
|
+
kLZ4Compression
|
|
39
|
+
kLZ4HCCompression
|
|
40
|
+
kXpressCompression
|
|
41
|
+
kZSTD
|
|
42
|
+
kZSTDNotFinalCompression
|
|
43
|
+
kDisableCompressionOption
|
|
44
|
+
|
|
45
|
+
ctypedef enum ReadTier:
|
|
46
|
+
kReadAllTier
|
|
47
|
+
kBlockCacheTier
|
|
48
|
+
|
|
49
|
+
ctypedef enum CompactionPri:
|
|
50
|
+
kByCompensatedSize
|
|
51
|
+
kOldestLargestSeqFirst
|
|
52
|
+
kOldestSmallestSeqFirst
|
|
53
|
+
kMinOverlappingRatio
|
|
54
|
+
|
|
55
|
+
# This needs to be in _rocksdb.pxd so it will export into python
|
|
56
|
+
#cpdef enum AccessHint "rocksdb::DBOptions::AccessHint":
|
|
57
|
+
# NONE,
|
|
58
|
+
# NORMAL,
|
|
59
|
+
# SEQUENTIAL,
|
|
60
|
+
# WILLNEED
|
|
61
|
+
|
|
62
|
+
cdef cppclass DBOptions:
|
|
63
|
+
cpp_bool create_if_missing
|
|
64
|
+
cpp_bool create_missing_column_families
|
|
65
|
+
cpp_bool error_if_exists
|
|
66
|
+
cpp_bool paranoid_checks
|
|
67
|
+
# TODO: env
|
|
68
|
+
shared_ptr[Logger] info_log
|
|
69
|
+
int max_open_files
|
|
70
|
+
int max_file_opening_threads
|
|
71
|
+
# TODO: statistics
|
|
72
|
+
cpp_bool use_fsync
|
|
73
|
+
string db_log_dir
|
|
74
|
+
string wal_dir
|
|
75
|
+
uint64_t delete_obsolete_files_period_micros
|
|
76
|
+
int max_background_jobs
|
|
77
|
+
int max_background_compactions
|
|
78
|
+
uint32_t max_subcompactions
|
|
79
|
+
int max_background_flushes
|
|
80
|
+
size_t max_log_file_size
|
|
81
|
+
size_t log_file_time_to_roll
|
|
82
|
+
size_t keep_log_file_num
|
|
83
|
+
size_t recycle_log_file_num
|
|
84
|
+
uint64_t max_manifest_file_size
|
|
85
|
+
int table_cache_numshardbits
|
|
86
|
+
uint64_t WAL_ttl_seconds
|
|
87
|
+
uint64_t WAL_size_limit_MB
|
|
88
|
+
size_t manifest_preallocation_size
|
|
89
|
+
cpp_bool allow_mmap_reads
|
|
90
|
+
cpp_bool allow_mmap_writes
|
|
91
|
+
cpp_bool use_direct_reads
|
|
92
|
+
cpp_bool use_direct_io_for_flush_and_compaction
|
|
93
|
+
cpp_bool allow_fallocate
|
|
94
|
+
cpp_bool is_fd_close_on_exec
|
|
95
|
+
unsigned int stats_dump_period_sec
|
|
96
|
+
cpp_bool advise_random_on_open
|
|
97
|
+
size_t db_write_buffer_size
|
|
98
|
+
# AccessHint access_hint_on_compaction_start
|
|
99
|
+
cpp_bool use_adaptive_mutex
|
|
100
|
+
uint64_t bytes_per_sync
|
|
101
|
+
cpp_bool allow_concurrent_memtable_write
|
|
102
|
+
cpp_bool enable_write_thread_adaptive_yield
|
|
103
|
+
shared_ptr[Cache] row_cache
|
|
104
|
+
|
|
105
|
+
cpp_bool skip_checking_sst_file_sizes_on_db_open
|
|
106
|
+
cpp_bool skip_stats_update_on_db_open
|
|
107
|
+
|
|
108
|
+
cdef cppclass ColumnFamilyOptions:
|
|
109
|
+
ColumnFamilyOptions()
|
|
110
|
+
ColumnFamilyOptions(const Options& options)
|
|
111
|
+
const Comparator* comparator
|
|
112
|
+
shared_ptr[MergeOperator] merge_operator
|
|
113
|
+
# TODO: compaction_filter
|
|
114
|
+
# TODO: compaction_filter_factory
|
|
115
|
+
size_t write_buffer_size
|
|
116
|
+
int max_write_buffer_number
|
|
117
|
+
int min_write_buffer_number_to_merge
|
|
118
|
+
CompressionType compression
|
|
119
|
+
CompactionPri compaction_pri
|
|
120
|
+
# TODO: compression_per_level
|
|
121
|
+
shared_ptr[SliceTransform] prefix_extractor
|
|
122
|
+
int num_levels
|
|
123
|
+
int level0_file_num_compaction_trigger
|
|
124
|
+
int level0_slowdown_writes_trigger
|
|
125
|
+
int level0_stop_writes_trigger
|
|
126
|
+
int max_mem_compaction_level
|
|
127
|
+
uint64_t target_file_size_base
|
|
128
|
+
int target_file_size_multiplier
|
|
129
|
+
uint64_t max_bytes_for_level_base
|
|
130
|
+
double max_bytes_for_level_multiplier
|
|
131
|
+
vector[int] max_bytes_for_level_multiplier_additional
|
|
132
|
+
int expanded_compaction_factor
|
|
133
|
+
int source_compaction_factor
|
|
134
|
+
int max_grandparent_overlap_factor
|
|
135
|
+
cpp_bool disableDataSync
|
|
136
|
+
size_t arena_block_size
|
|
137
|
+
# TODO: PrepareForBulkLoad()
|
|
138
|
+
cpp_bool disable_auto_compactions
|
|
139
|
+
cpp_bool allow_os_buffer
|
|
140
|
+
cpp_bool verify_checksums_in_compaction
|
|
141
|
+
CompactionStyle compaction_style
|
|
142
|
+
CompactionOptionsUniversal compaction_options_universal
|
|
143
|
+
cpp_bool filter_deletes
|
|
144
|
+
uint64_t max_sequential_skip_in_iterations
|
|
145
|
+
shared_ptr[MemTableRepFactory] memtable_factory
|
|
146
|
+
shared_ptr[TableFactory] table_factory
|
|
147
|
+
# TODO: table_properties_collectors
|
|
148
|
+
cpp_bool inplace_update_support
|
|
149
|
+
size_t inplace_update_num_locks
|
|
150
|
+
# TODO: remove options source_compaction_factor, max_grandparent_overlap_bytes and expanded_compaction_factor from document
|
|
151
|
+
uint64_t max_compaction_bytes
|
|
152
|
+
CompressionOptions compression_opts
|
|
153
|
+
|
|
154
|
+
cdef cppclass Options(DBOptions, ColumnFamilyOptions):
|
|
155
|
+
pass
|
|
156
|
+
|
|
157
|
+
cdef cppclass WriteOptions:
|
|
158
|
+
cpp_bool sync
|
|
159
|
+
cpp_bool disableWAL
|
|
160
|
+
|
|
161
|
+
cdef cppclass ReadOptions:
|
|
162
|
+
cpp_bool verify_checksums
|
|
163
|
+
cpp_bool fill_cache
|
|
164
|
+
const Snapshot* snapshot
|
|
165
|
+
ReadTier read_tier
|
|
166
|
+
|
|
167
|
+
cdef cppclass FlushOptions:
|
|
168
|
+
cpp_bool wait
|
|
169
|
+
|
|
170
|
+
ctypedef enum BottommostLevelCompaction:
|
|
171
|
+
blc_skip "rocksdb::BottommostLevelCompaction::kSkip"
|
|
172
|
+
blc_is_filter "rocksdb::BottommostLevelCompaction::kIfHaveCompactionFilter"
|
|
173
|
+
blc_force "rocksdb::BottommostLevelCompaction::kForce"
|
|
174
|
+
|
|
175
|
+
cdef cppclass CompactRangeOptions:
|
|
176
|
+
cpp_bool change_level
|
|
177
|
+
int target_level
|
|
178
|
+
uint32_t target_path_id
|
|
179
|
+
BottommostLevelCompaction bottommost_level_compaction
|
rdbpy/slice_.pxd
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from libcpp.string cimport string
|
|
2
|
+
from libcpp cimport bool as cpp_bool
|
|
3
|
+
|
|
4
|
+
cdef extern from "rocksdb/slice.h" namespace "rocksdb":
|
|
5
|
+
cdef cppclass Slice:
|
|
6
|
+
Slice() nogil
|
|
7
|
+
Slice(const char*, size_t) nogil
|
|
8
|
+
Slice(const string&) nogil
|
|
9
|
+
Slice(const char*) nogil
|
|
10
|
+
|
|
11
|
+
const char* data() nogil
|
|
12
|
+
size_t size() nogil
|
|
13
|
+
cpp_bool empty() nogil
|
|
14
|
+
char operator[](int) nogil
|
|
15
|
+
void clear() nogil
|
|
16
|
+
void remove_prefix(size_t) nogil
|
|
17
|
+
string ToString() nogil
|
|
18
|
+
string ToString(cpp_bool) nogil
|
|
19
|
+
int compare(const Slice&) nogil
|
|
20
|
+
cpp_bool starts_with(const Slice&) nogil
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from rdbpy.slice_ cimport Slice
|
|
2
|
+
from libcpp.string cimport string
|
|
3
|
+
from libcpp cimport bool as cpp_bool
|
|
4
|
+
from rdbpy.logger cimport Logger
|
|
5
|
+
from rdbpy.std_memory cimport shared_ptr
|
|
6
|
+
|
|
7
|
+
cdef extern from "rocksdb/slice_transform.h" namespace "rocksdb":
|
|
8
|
+
cdef cppclass SliceTransform:
|
|
9
|
+
pass
|
|
10
|
+
|
|
11
|
+
ctypedef Slice (*transform_func)(
|
|
12
|
+
void*,
|
|
13
|
+
Logger*,
|
|
14
|
+
string&,
|
|
15
|
+
const Slice&)
|
|
16
|
+
|
|
17
|
+
ctypedef cpp_bool (*in_domain_func)(
|
|
18
|
+
void*,
|
|
19
|
+
Logger*,
|
|
20
|
+
string&,
|
|
21
|
+
const Slice&)
|
|
22
|
+
|
|
23
|
+
ctypedef cpp_bool (*in_range_func)(
|
|
24
|
+
void*,
|
|
25
|
+
Logger*,
|
|
26
|
+
string&,
|
|
27
|
+
const Slice&)
|
|
28
|
+
|
|
29
|
+
cdef extern from "rdb_include/slice_transform_wrapper.hpp" namespace "py_rocks":
|
|
30
|
+
cdef cppclass SliceTransformWrapper:
|
|
31
|
+
SliceTransformWrapper(
|
|
32
|
+
string name,
|
|
33
|
+
void*,
|
|
34
|
+
transform_func,
|
|
35
|
+
in_domain_func,
|
|
36
|
+
in_range_func) nogil except+
|
|
37
|
+
void set_info_log(shared_ptr[Logger]) nogil except+
|
rdbpy/snapshot.pxd
ADDED
rdbpy/status.pxd
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from libcpp cimport bool as cpp_bool
|
|
2
|
+
from libcpp.string cimport string
|
|
3
|
+
|
|
4
|
+
cdef extern from "rocksdb/status.h" namespace "rocksdb":
|
|
5
|
+
cdef cppclass Status:
|
|
6
|
+
Status()
|
|
7
|
+
cpp_bool ok() nogil
|
|
8
|
+
cpp_bool IsNotFound() nogil const
|
|
9
|
+
cpp_bool IsCorruption() nogil const
|
|
10
|
+
cpp_bool IsNotSupported() nogil const
|
|
11
|
+
cpp_bool IsInvalidArgument() nogil const
|
|
12
|
+
cpp_bool IsIOError() nogil const
|
|
13
|
+
cpp_bool IsMergeInProgress() nogil const
|
|
14
|
+
cpp_bool IsIncomplete() nogil const
|
|
15
|
+
string ToString() nogil except+
|
rdbpy/std_memory.pxd
ADDED
rdbpy/table_factory.pxd
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from libc.stdint cimport uint32_t
|
|
2
|
+
from libcpp cimport bool as cpp_bool
|
|
3
|
+
from rdbpy.std_memory cimport shared_ptr
|
|
4
|
+
|
|
5
|
+
from rdbpy.cache cimport Cache
|
|
6
|
+
from rdbpy.filter_policy cimport FilterPolicy
|
|
7
|
+
|
|
8
|
+
cdef extern from "rocksdb/table.h" namespace "rocksdb":
|
|
9
|
+
cdef cppclass TableFactory:
|
|
10
|
+
TableFactory()
|
|
11
|
+
|
|
12
|
+
ctypedef enum BlockBasedTableIndexType:
|
|
13
|
+
kBinarySearch "rocksdb::BlockBasedTableOptions::IndexType::kBinarySearch"
|
|
14
|
+
kHashSearch "rocksdb::BlockBasedTableOptions::IndexType::kHashSearch"
|
|
15
|
+
|
|
16
|
+
ctypedef enum ChecksumType:
|
|
17
|
+
kCRC32c
|
|
18
|
+
kxxHash
|
|
19
|
+
|
|
20
|
+
cdef cppclass BlockBasedTableOptions:
|
|
21
|
+
BlockBasedTableOptions()
|
|
22
|
+
BlockBasedTableIndexType index_type
|
|
23
|
+
cpp_bool hash_index_allow_collision
|
|
24
|
+
ChecksumType checksum
|
|
25
|
+
cpp_bool no_block_cache
|
|
26
|
+
size_t block_size
|
|
27
|
+
int block_size_deviation
|
|
28
|
+
int block_restart_interval
|
|
29
|
+
cpp_bool whole_key_filtering
|
|
30
|
+
shared_ptr[Cache] block_cache
|
|
31
|
+
shared_ptr[Cache] block_cache_compressed
|
|
32
|
+
shared_ptr[FilterPolicy] filter_policy
|
|
33
|
+
|
|
34
|
+
cdef TableFactory* NewBlockBasedTableFactory(const BlockBasedTableOptions&)
|
|
35
|
+
|
|
36
|
+
ctypedef enum EncodingType:
|
|
37
|
+
kPlain
|
|
38
|
+
kPrefix
|
|
39
|
+
|
|
40
|
+
cdef cppclass PlainTableOptions:
|
|
41
|
+
uint32_t user_key_len
|
|
42
|
+
int bloom_bits_per_key
|
|
43
|
+
double hash_table_ratio
|
|
44
|
+
size_t index_sparseness
|
|
45
|
+
size_t huge_page_tlb_size
|
|
46
|
+
EncodingType encoding_type
|
|
47
|
+
cpp_bool full_scan_mode
|
|
48
|
+
cpp_bool store_index_in_file
|
|
49
|
+
|
|
50
|
+
cdef TableFactory* NewPlainTableFactory(const PlainTableOptions&)
|
rdbpy/transaction.pxd
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
from libc.stddef cimport size_t
|
|
2
|
+
from libc.stdint cimport int64_t, uint32_t, uint64_t
|
|
3
|
+
from libcpp cimport bool as cpp_bool
|
|
4
|
+
from libcpp.string cimport string
|
|
5
|
+
from libcpp.vector cimport vector
|
|
6
|
+
|
|
7
|
+
from rdbpy.slice_ cimport Slice
|
|
8
|
+
from rdbpy.snapshot cimport Snapshot
|
|
9
|
+
from rdbpy.status cimport Status
|
|
10
|
+
from rdbpy.std_memory cimport shared_ptr
|
|
11
|
+
|
|
12
|
+
cimport rdbpy.db as db
|
|
13
|
+
cimport rdbpy.iterator as iterator
|
|
14
|
+
cimport rdbpy.options as options
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
cdef extern from "rocksdb/utilities/transaction_db_mutex.h" namespace "rocksdb":
|
|
18
|
+
cdef cppclass TransactionDBMutexFactory:
|
|
19
|
+
pass
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
cdef extern from "rocksdb/utilities/transaction_db.h" namespace "rocksdb":
|
|
23
|
+
ctypedef uint64_t TransactionID
|
|
24
|
+
ctypedef string TransactionName
|
|
25
|
+
|
|
26
|
+
cdef enum TxnDBWritePolicy:
|
|
27
|
+
WRITE_COMMITTED
|
|
28
|
+
WRITE_PREPARED
|
|
29
|
+
WRITE_UNPREPARED
|
|
30
|
+
|
|
31
|
+
cdef cppclass LockManager:
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
cdef cppclass LockManagerHandle:
|
|
35
|
+
LockManager* getLockManager() nogil except+
|
|
36
|
+
|
|
37
|
+
cdef cppclass TransactionDBOptions:
|
|
38
|
+
TransactionDBOptions() nogil except+
|
|
39
|
+
int64_t max_num_locks
|
|
40
|
+
uint32_t max_num_deadlocks
|
|
41
|
+
size_t num_stripes
|
|
42
|
+
int64_t transaction_lock_timeout
|
|
43
|
+
int64_t default_lock_timeout
|
|
44
|
+
shared_ptr[TransactionDBMutexFactory] custom_mutex_factory
|
|
45
|
+
TxnDBWritePolicy write_policy
|
|
46
|
+
cpp_bool rollback_merge_operands
|
|
47
|
+
shared_ptr[LockManagerHandle] lock_mgr_handle
|
|
48
|
+
cpp_bool skip_concurrency_control
|
|
49
|
+
int64_t default_write_batch_flush_threshold
|
|
50
|
+
|
|
51
|
+
cdef cppclass TransactionDBWriteOptimizations:
|
|
52
|
+
TransactionDBWriteOptimizations() nogil except+
|
|
53
|
+
cpp_bool skip_concurrency_control
|
|
54
|
+
cpp_bool skip_duplicate_key_check
|
|
55
|
+
|
|
56
|
+
cdef cppclass TransactionOptions:
|
|
57
|
+
TransactionOptions() nogil except+
|
|
58
|
+
cpp_bool set_snapshot
|
|
59
|
+
cpp_bool deadlock_detect
|
|
60
|
+
cpp_bool use_only_the_last_commit_time_batch_for_recovery
|
|
61
|
+
int64_t lock_timeout
|
|
62
|
+
int64_t expiration
|
|
63
|
+
int64_t deadlock_detect_depth
|
|
64
|
+
size_t max_write_batch_size
|
|
65
|
+
cpp_bool skip_concurrency_control
|
|
66
|
+
cpp_bool skip_prepare
|
|
67
|
+
int64_t write_batch_flush_threshold
|
|
68
|
+
|
|
69
|
+
cdef cppclass Transaction:
|
|
70
|
+
Status Commit() nogil except+
|
|
71
|
+
Status Rollback() nogil except+
|
|
72
|
+
Status Prepare() nogil except+
|
|
73
|
+
void SetSnapshot() nogil except+
|
|
74
|
+
const Snapshot* GetSnapshot() nogil except+
|
|
75
|
+
void ClearSnapshot() nogil except+
|
|
76
|
+
Status SetName(const TransactionName&) nogil except+
|
|
77
|
+
TransactionName GetName() nogil except+
|
|
78
|
+
TransactionID GetID() nogil except+
|
|
79
|
+
void SetSavePoint() nogil except+
|
|
80
|
+
Status PopSavePoint() nogil except+
|
|
81
|
+
Status RollbackToSavePoint() nogil except+
|
|
82
|
+
void DisableIndexing() nogil except+
|
|
83
|
+
void EnableIndexing() nogil except+
|
|
84
|
+
Status Put(db.ColumnFamilyHandle*, const Slice&, const Slice&, cpp_bool assume_tracked) nogil except+
|
|
85
|
+
Status Put(const Slice&, const Slice&) nogil except+
|
|
86
|
+
Status Merge(db.ColumnFamilyHandle*, const Slice&, const Slice&, cpp_bool assume_tracked) nogil except+
|
|
87
|
+
Status Merge(const Slice&, const Slice&) nogil except+
|
|
88
|
+
Status Delete(db.ColumnFamilyHandle*, const Slice&, cpp_bool assume_tracked) nogil except+
|
|
89
|
+
Status Delete(const Slice&) nogil except+
|
|
90
|
+
Status SingleDelete(db.ColumnFamilyHandle*, const Slice&, cpp_bool assume_tracked) nogil except+
|
|
91
|
+
Status SingleDelete(const Slice&) nogil except+
|
|
92
|
+
Status Get(const options.ReadOptions&, db.ColumnFamilyHandle*, const Slice&, string*) nogil except+
|
|
93
|
+
Status Get(const options.ReadOptions&, const Slice&, string*) nogil except+
|
|
94
|
+
vector[Status] MultiGet(
|
|
95
|
+
const options.ReadOptions&,
|
|
96
|
+
const vector[db.ColumnFamilyHandle*]&,
|
|
97
|
+
const vector[Slice]&,
|
|
98
|
+
vector[string]*) nogil except+
|
|
99
|
+
vector[Status] MultiGet(
|
|
100
|
+
const options.ReadOptions&,
|
|
101
|
+
const vector[Slice]&,
|
|
102
|
+
vector[string]*) nogil except+
|
|
103
|
+
iterator.Iterator* GetIterator(const options.ReadOptions&) nogil except+
|
|
104
|
+
iterator.Iterator* GetIterator(const options.ReadOptions&, db.ColumnFamilyHandle*) nogil except+
|
|
105
|
+
|
|
106
|
+
cdef cppclass CppTransactionDB "rocksdb::TransactionDB"(db.DB):
|
|
107
|
+
Transaction* BeginTransaction(
|
|
108
|
+
const options.WriteOptions&,
|
|
109
|
+
const TransactionOptions&,
|
|
110
|
+
Transaction* old_txn) nogil except+
|
|
111
|
+
Transaction* BeginTransaction(
|
|
112
|
+
const options.WriteOptions&,
|
|
113
|
+
const TransactionOptions&) nogil except+
|
|
114
|
+
Transaction* GetTransactionByName(const TransactionName&) nogil except+
|
|
115
|
+
void GetAllPreparedTransactions(vector[Transaction*]*) nogil except+
|
|
116
|
+
|
|
117
|
+
cdef Status TransactionDB_Open "rocksdb::TransactionDB::Open"(
|
|
118
|
+
const options.Options&,
|
|
119
|
+
const TransactionDBOptions&,
|
|
120
|
+
const string&,
|
|
121
|
+
CppTransactionDB**) nogil except+
|
|
122
|
+
|
|
123
|
+
cdef Status TransactionDB_Open_CF "rocksdb::TransactionDB::Open"(
|
|
124
|
+
const options.DBOptions&,
|
|
125
|
+
const TransactionDBOptions&,
|
|
126
|
+
const string&,
|
|
127
|
+
const vector[db.ColumnFamilyDescriptor]&,
|
|
128
|
+
vector[db.ColumnFamilyHandle*]*,
|
|
129
|
+
CppTransactionDB**) nogil except+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
# Helper functions to disambiguate overloaded Transaction methods
|
|
133
|
+
cdef extern from "rocksdb/utilities/transaction.h":
|
|
134
|
+
"""
|
|
135
|
+
static inline rocksdb::Iterator* Transaction_GetIterator(
|
|
136
|
+
rocksdb::Transaction* txn,
|
|
137
|
+
const rocksdb::ReadOptions& opts) {
|
|
138
|
+
return txn->GetIterator(opts);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
static inline rocksdb::Iterator* Transaction_GetIterator_CF(
|
|
142
|
+
rocksdb::Transaction* txn,
|
|
143
|
+
const rocksdb::ReadOptions& opts,
|
|
144
|
+
rocksdb::ColumnFamilyHandle* cf) {
|
|
145
|
+
return txn->GetIterator(opts, cf);
|
|
146
|
+
}
|
|
147
|
+
"""
|
|
148
|
+
iterator.Iterator* Transaction_GetIterator(
|
|
149
|
+
Transaction*,
|
|
150
|
+
const options.ReadOptions&) nogil except+
|
|
151
|
+
iterator.Iterator* Transaction_GetIterator_CF(
|
|
152
|
+
Transaction*,
|
|
153
|
+
const options.ReadOptions&,
|
|
154
|
+
db.ColumnFamilyHandle*) nogil except+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
cdef extern from "rocksdb/universal_compaction.h" namespace "rocksdb":
|
|
2
|
+
|
|
3
|
+
ctypedef enum CompactionStopStyle:
|
|
4
|
+
kCompactionStopStyleSimilarSize
|
|
5
|
+
kCompactionStopStyleTotalSize
|
|
6
|
+
|
|
7
|
+
cdef cppclass CompactionOptionsUniversal:
|
|
8
|
+
CompactionOptionsUniversal()
|
|
9
|
+
|
|
10
|
+
unsigned int size_ratio
|
|
11
|
+
unsigned int min_merge_width
|
|
12
|
+
unsigned int max_merge_width
|
|
13
|
+
unsigned int max_size_amplification_percent
|
|
14
|
+
int compression_size_percent
|
|
15
|
+
CompactionStopStyle stop_style
|