Add "row_cache" to options.

This commit is contained in:
hofmockel 2015-08-30 12:21:40 +02:00
parent 6b54dc9e64
commit 01f13577ad
3 changed files with 25 additions and 0 deletions

View file

@ -708,6 +708,7 @@ cdef class Options(object):
cdef PySliceTransform py_prefix_extractor
cdef PyTableFactory py_table_factory
cdef PyMemtableFactory py_memtable_factory
cdef PyCache py_row_cache
# Used to protect sharing of Options with many DB-objects
cdef cpp_bool in_use
@ -727,6 +728,7 @@ cdef class Options(object):
self.py_prefix_extractor = None
self.py_table_factory = None
self.py_memtable_factory = None
self.py_row_cache = None
for key, value in kwargs.items():
setattr(self, key, value)
@ -1210,6 +1212,21 @@ cdef class Options(object):
self.py_prefix_extractor = PySliceTransform(value)
self.opts.prefix_extractor = self.py_prefix_extractor.get_transformer()
property row_cache:
def __get__(self):
return self.py_row_cache
def __set__(self, value):
if value is None:
self.py_row_cache = None
self.opts.row_cache.reset()
elif not isinstance(value, PyCache):
raise Exception("row_cache must be a Cache object")
else:
self.py_row_cache = value
self.opts.row_cache = self.py_row_cache.get_cache()
# Forward declaration
cdef class Snapshot

View file

@ -13,6 +13,7 @@ from slice_transform cimport SliceTransform
from table_factory cimport TableFactory
from memtablerep cimport MemTableRepFactory
from universal_compaction cimport CompactionOptionsUniversal
from cache cimport Cache
cdef extern from "rocksdb/options.h" namespace "rocksdb":
ctypedef enum CompactionStyle:
@ -105,6 +106,7 @@ cdef extern from "rocksdb/options.h" namespace "rocksdb":
# TODO: table_properties_collectors
cpp_bool inplace_update_support
size_t inplace_update_num_locks
shared_ptr[Cache] row_cache
cdef cppclass WriteOptions:
cpp_bool sync

View file

@ -96,3 +96,9 @@ class TestOptions(unittest.TestCase):
self.assertEqual(1, uopts['size_ratio'])
self.assertEqual(2, uopts['min_merge_width'])
self.assertEqual(30, uopts['max_merge_width'])
def test_row_cache(self):
opts = rocksdb.Options()
self.assertIsNone(opts.row_cache)
opts.row_cache = cache = rocksdb.LRUCache(2*1024*1024)
self.assertEqual(cache, opts.row_cache)