diff --git a/rocksdb/_rocksdb.pyx b/rocksdb/_rocksdb.pyx index 8f25bd6..254b209 100644 --- a/rocksdb/_rocksdb.pyx +++ b/rocksdb/_rocksdb.pyx @@ -566,6 +566,8 @@ cdef class BlockBasedTableFactory(PyTableFactory): index_type='binary_search', py_bool hash_index_allow_collision=True, checksum='crc32', + PyCache block_cache=None, + PyCache block_cache_compressed=None, no_block_cache=False, block_size=None, block_size_deviation=None, @@ -614,6 +616,12 @@ cdef class BlockBasedTableFactory(PyTableFactory): else: table_options.whole_key_filtering = False + if block_cache is not None: + table_options.block_cache = block_cache.get_cache() + + if block_cache_compressed is not None: + table_options.block_cache_compressed = block_cache_compressed.get_cache() + self.factory.reset(table_factory.NewBlockBasedTableFactory(table_options)) cdef class PlainTableFactory(PyTableFactory): @@ -694,8 +702,6 @@ cdef class Options(object): cdef PyComparator py_comparator cdef PyMergeOperator py_merge_operator cdef PyFilterPolicy py_filter_policy - cdef PyCache py_block_cache - cdef PyCache py_block_cache_compressed cdef PySliceTransform py_prefix_extractor cdef PyTableFactory py_table_factory cdef PyMemtableFactory py_memtable_factory @@ -716,8 +722,6 @@ cdef class Options(object): self.py_comparator = BytewiseComparator() self.py_merge_operator = None self.py_filter_policy = None - self.py_block_cache = None - self.py_block_cache_compressed = None self.py_prefix_extractor = None self.py_table_factory = None self.py_memtable_factory = None @@ -1218,41 +1222,6 @@ cdef class Options(object): self.py_prefix_extractor = PySliceTransform(value) self.opts.prefix_extractor = self.py_prefix_extractor.get_transformer() - property block_cache: - def __get__(self): - if self.py_block_cache is None: - return None - return self.py_block_cache.get_ob() - - def __set__(self, value): - if value is None: - self.py_block_cache = None - self.opts.block_cache.reset() - else: - if not isinstance(value, PyCache): - raise TypeError("%s is not a Cache" % value) - - self.py_block_cache = value - self.opts.block_cache = self.py_block_cache.get_cache() - - property block_cache_compressed: - def __get__(self): - if self.py_block_cache_compressed is None: - return None - return self.py_block_cache_compressed.get_ob() - - def __set__(self, value): - if value is None: - self.py_block_cache_compressed = None - self.opts.block_cache_compressed.reset() - return - - if not isinstance(value, PyCache): - raise TypeError("%s is not a Cache" % value) - - self.py_block_cache_compressed = value - self.opts.block_cache_compressed = (value).get_cache() - # Forward declaration cdef class Snapshot diff --git a/rocksdb/options.pxd b/rocksdb/options.pxd index 54abab4..b17a5ab 100644 --- a/rocksdb/options.pxd +++ b/rocksdb/options.pxd @@ -6,7 +6,6 @@ from std_memory cimport shared_ptr from comparator cimport Comparator from merge_operator cimport MergeOperator from filter_policy cimport FilterPolicy -from cache cimport Cache from logger cimport Logger from slice_ cimport Slice from snapshot cimport Snapshot @@ -45,8 +44,6 @@ cdef extern from "rocksdb/options.h" namespace "rocksdb": int max_write_buffer_number int min_write_buffer_number_to_merge int max_open_files - shared_ptr[Cache] block_cache - shared_ptr[Cache] block_cache_compressed CompressionType compression # TODO: compression_per_level # TODO: compression_opts diff --git a/rocksdb/table_factory.pxd b/rocksdb/table_factory.pxd index f5292c1..2c61e64 100644 --- a/rocksdb/table_factory.pxd +++ b/rocksdb/table_factory.pxd @@ -1,5 +1,8 @@ from libc.stdint cimport uint32_t from libcpp cimport bool as cpp_bool +from std_memory cimport shared_ptr + +from cache cimport Cache cdef extern from "rocksdb/table.h" namespace "rocksdb": cdef cppclass TableFactory: @@ -23,6 +26,8 @@ cdef extern from "rocksdb/table.h" namespace "rocksdb": int block_size_deviation int block_restart_interval cpp_bool whole_key_filtering + shared_ptr[Cache] block_cache + shared_ptr[Cache] block_cache_compressed cdef TableFactory* NewBlockBasedTableFactory(const BlockBasedTableOptions&)