add ReaderOptions

- `iterate_lower_bound`
- `iterate_upper_bound`
- `readahead_size`
- `prefix_same_as_start`
- `auto_prefix_mode`
This commit is contained in:
Jack Robison 2022-01-13 21:54:50 -05:00
parent c77770e2c4
commit 283bfd1f28
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
2 changed files with 23 additions and 3 deletions

View file

@ -2277,18 +2277,30 @@ cdef class DB(object):
@staticmethod @staticmethod
def __parse_read_opts( def __parse_read_opts(
iterate_lower_bound=None,
iterate_upper_bound=None,
readahead_size=0,
prefix_same_as_start=False,
verify_checksums=False, verify_checksums=False,
fill_cache=True, fill_cache=True,
snapshot=None, snapshot=None,
read_tier="all"): read_tier="all",
auto_prefix_mode=False):
# TODO: Is this really effiencet ? # TODO: Is this really effiencet ?
return locals() return locals()
cdef options.ReadOptions build_read_opts(self, dict py_opts): cdef options.ReadOptions build_read_opts(self, dict py_opts):
cdef options.ReadOptions opts cdef options.ReadOptions opts
cdef Slice iterate_lower_bound
cdef Slice iterate_upper_bound
opts.verify_checksums = py_opts['verify_checksums'] opts.verify_checksums = py_opts['verify_checksums']
opts.fill_cache = py_opts['fill_cache'] opts.fill_cache = py_opts['fill_cache']
opts.readahead_size = py_opts['readahead_size']
opts.prefix_same_as_start = py_opts['prefix_same_as_start']
opts.auto_prefix_mode = py_opts['auto_prefix_mode']
if py_opts['snapshot'] is not None: if py_opts['snapshot'] is not None:
opts.snapshot = (<Snapshot?>(py_opts['snapshot'])).ptr opts.snapshot = (<Snapshot?>(py_opts['snapshot'])).ptr
@ -2298,7 +2310,10 @@ cdef class DB(object):
opts.read_tier = options.kBlockCacheTier opts.read_tier = options.kBlockCacheTier
else: else:
raise ValueError("Invalid read_tier") raise ValueError("Invalid read_tier")
if py_opts['iterate_lower_bound'] is not None:
opts.iterate_lower_bound = new Slice(PyBytes_AsString(py_opts['iterate_lower_bound']), PyBytes_Size(py_opts['iterate_lower_bound']))
if py_opts['iterate_upper_bound'] is not None:
opts.iterate_upper_bound = new Slice(PyBytes_AsString(py_opts['iterate_upper_bound']), PyBytes_Size(py_opts['iterate_upper_bound']))
return opts return opts
property options: property options:

View file

@ -172,10 +172,15 @@ cdef extern from "rocksdb/options.h" namespace "rocksdb":
cpp_bool disableWAL cpp_bool disableWAL
cdef cppclass ReadOptions: cdef cppclass ReadOptions:
const Snapshot* snapshot
const Slice* iterate_lower_bound
const Slice* iterate_upper_bound
size_t readahead_size
cpp_bool verify_checksums cpp_bool verify_checksums
cpp_bool fill_cache cpp_bool fill_cache
const Snapshot* snapshot
ReadTier read_tier ReadTier read_tier
cpp_bool prefix_same_as_start
cpp_bool auto_prefix_mode
cdef cppclass FlushOptions: cdef cppclass FlushOptions:
cpp_bool wait cpp_bool wait