Move the block_cache* from options to block_based_table_factory.
This commit is contained in:
parent
14dd1c785a
commit
5550ed91e7
3 changed files with 13 additions and 42 deletions
|
@ -566,6 +566,8 @@ cdef class BlockBasedTableFactory(PyTableFactory):
|
||||||
index_type='binary_search',
|
index_type='binary_search',
|
||||||
py_bool hash_index_allow_collision=True,
|
py_bool hash_index_allow_collision=True,
|
||||||
checksum='crc32',
|
checksum='crc32',
|
||||||
|
PyCache block_cache=None,
|
||||||
|
PyCache block_cache_compressed=None,
|
||||||
no_block_cache=False,
|
no_block_cache=False,
|
||||||
block_size=None,
|
block_size=None,
|
||||||
block_size_deviation=None,
|
block_size_deviation=None,
|
||||||
|
@ -614,6 +616,12 @@ cdef class BlockBasedTableFactory(PyTableFactory):
|
||||||
else:
|
else:
|
||||||
table_options.whole_key_filtering = False
|
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))
|
self.factory.reset(table_factory.NewBlockBasedTableFactory(table_options))
|
||||||
|
|
||||||
cdef class PlainTableFactory(PyTableFactory):
|
cdef class PlainTableFactory(PyTableFactory):
|
||||||
|
@ -694,8 +702,6 @@ cdef class Options(object):
|
||||||
cdef PyComparator py_comparator
|
cdef PyComparator py_comparator
|
||||||
cdef PyMergeOperator py_merge_operator
|
cdef PyMergeOperator py_merge_operator
|
||||||
cdef PyFilterPolicy py_filter_policy
|
cdef PyFilterPolicy py_filter_policy
|
||||||
cdef PyCache py_block_cache
|
|
||||||
cdef PyCache py_block_cache_compressed
|
|
||||||
cdef PySliceTransform py_prefix_extractor
|
cdef PySliceTransform py_prefix_extractor
|
||||||
cdef PyTableFactory py_table_factory
|
cdef PyTableFactory py_table_factory
|
||||||
cdef PyMemtableFactory py_memtable_factory
|
cdef PyMemtableFactory py_memtable_factory
|
||||||
|
@ -716,8 +722,6 @@ cdef class Options(object):
|
||||||
self.py_comparator = BytewiseComparator()
|
self.py_comparator = BytewiseComparator()
|
||||||
self.py_merge_operator = None
|
self.py_merge_operator = None
|
||||||
self.py_filter_policy = None
|
self.py_filter_policy = None
|
||||||
self.py_block_cache = None
|
|
||||||
self.py_block_cache_compressed = None
|
|
||||||
self.py_prefix_extractor = None
|
self.py_prefix_extractor = None
|
||||||
self.py_table_factory = None
|
self.py_table_factory = None
|
||||||
self.py_memtable_factory = None
|
self.py_memtable_factory = None
|
||||||
|
@ -1218,41 +1222,6 @@ cdef class Options(object):
|
||||||
self.py_prefix_extractor = PySliceTransform(value)
|
self.py_prefix_extractor = PySliceTransform(value)
|
||||||
self.opts.prefix_extractor = self.py_prefix_extractor.get_transformer()
|
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 = (<PyCache>value).get_cache()
|
|
||||||
|
|
||||||
# Forward declaration
|
# Forward declaration
|
||||||
cdef class Snapshot
|
cdef class Snapshot
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ from std_memory cimport shared_ptr
|
||||||
from comparator cimport Comparator
|
from comparator cimport Comparator
|
||||||
from merge_operator cimport MergeOperator
|
from merge_operator cimport MergeOperator
|
||||||
from filter_policy cimport FilterPolicy
|
from filter_policy cimport FilterPolicy
|
||||||
from cache cimport Cache
|
|
||||||
from logger cimport Logger
|
from logger cimport Logger
|
||||||
from slice_ cimport Slice
|
from slice_ cimport Slice
|
||||||
from snapshot cimport Snapshot
|
from snapshot cimport Snapshot
|
||||||
|
@ -45,8 +44,6 @@ cdef extern from "rocksdb/options.h" namespace "rocksdb":
|
||||||
int max_write_buffer_number
|
int max_write_buffer_number
|
||||||
int min_write_buffer_number_to_merge
|
int min_write_buffer_number_to_merge
|
||||||
int max_open_files
|
int max_open_files
|
||||||
shared_ptr[Cache] block_cache
|
|
||||||
shared_ptr[Cache] block_cache_compressed
|
|
||||||
CompressionType compression
|
CompressionType compression
|
||||||
# TODO: compression_per_level
|
# TODO: compression_per_level
|
||||||
# TODO: compression_opts
|
# TODO: compression_opts
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
from libc.stdint cimport uint32_t
|
from libc.stdint cimport uint32_t
|
||||||
from libcpp cimport bool as cpp_bool
|
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 extern from "rocksdb/table.h" namespace "rocksdb":
|
||||||
cdef cppclass TableFactory:
|
cdef cppclass TableFactory:
|
||||||
|
@ -23,6 +26,8 @@ cdef extern from "rocksdb/table.h" namespace "rocksdb":
|
||||||
int block_size_deviation
|
int block_size_deviation
|
||||||
int block_restart_interval
|
int block_restart_interval
|
||||||
cpp_bool whole_key_filtering
|
cpp_bool whole_key_filtering
|
||||||
|
shared_ptr[Cache] block_cache
|
||||||
|
shared_ptr[Cache] block_cache_compressed
|
||||||
|
|
||||||
cdef TableFactory* NewBlockBasedTableFactory(const BlockBasedTableOptions&)
|
cdef TableFactory* NewBlockBasedTableFactory(const BlockBasedTableOptions&)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue