Merge options source_compaction_factor, max_grandparent_overlap_bytes and expanded_compaction_factor into max_compaction_bytes
This commit is contained in:
parent
9e5f600150
commit
58ba17ac90
4 changed files with 55 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
Note
|
Note
|
||||||
=========
|
=========
|
||||||
The original pyrocksdb has not been updated for long time. I update the pyrocksdb to support the latest rocksdb. Please open the issues in github if you have any problem.
|
The original pyrocksdb (https://pypi.python.org/pypi/pyrocksdb/0.4) has not been updated for long time. I update pyrocksdb to support the latest rocksdb. Please open issues in github if you have any problem.
|
||||||
|
|
||||||
|
|
||||||
pyrocksdb
|
pyrocksdb
|
||||||
|
|
|
@ -36,6 +36,8 @@ from universal_compaction cimport kCompactionStopStyleTotalSize
|
||||||
|
|
||||||
from options cimport kCompactionStyleLevel
|
from options cimport kCompactionStyleLevel
|
||||||
from options cimport kCompactionStyleUniversal
|
from options cimport kCompactionStyleUniversal
|
||||||
|
from options cimport kCompactionStyleFIFO
|
||||||
|
from options cimport kCompactionStyleNone
|
||||||
|
|
||||||
from slice_ cimport Slice
|
from slice_ cimport Slice
|
||||||
from status cimport Status
|
from status cimport Status
|
||||||
|
@ -700,6 +702,10 @@ cdef class CompressionType(object):
|
||||||
bzip2_compression = u'bzip2_compression'
|
bzip2_compression = u'bzip2_compression'
|
||||||
lz4_compression = u'lz4_compression'
|
lz4_compression = u'lz4_compression'
|
||||||
lz4hc_compression = u'lz4hc_compression'
|
lz4hc_compression = u'lz4hc_compression'
|
||||||
|
xpress_compression = u'xpress_compression'
|
||||||
|
zstd_compression = u'zstd_compression'
|
||||||
|
zstdnotfinal_compression = u'zstdnotfinal_compression'
|
||||||
|
disable_compression = u'disable_compression'
|
||||||
|
|
||||||
cdef class Options(object):
|
cdef class Options(object):
|
||||||
cdef options.Options* opts
|
cdef options.Options* opts
|
||||||
|
@ -763,6 +769,12 @@ cdef class Options(object):
|
||||||
def __set__(self, value):
|
def __set__(self, value):
|
||||||
self.opts.max_write_buffer_number = value
|
self.opts.max_write_buffer_number = value
|
||||||
|
|
||||||
|
property max_compaction_bytes:
|
||||||
|
def __get__(self):
|
||||||
|
return self.opts.max_compaction_bytes
|
||||||
|
def __set__(self, value):
|
||||||
|
self.opts.max_compaction_bytes = value
|
||||||
|
|
||||||
property min_write_buffer_number_to_merge:
|
property min_write_buffer_number_to_merge:
|
||||||
def __get__(self):
|
def __get__(self):
|
||||||
return self.opts.min_write_buffer_number_to_merge
|
return self.opts.min_write_buffer_number_to_merge
|
||||||
|
@ -789,6 +801,14 @@ cdef class Options(object):
|
||||||
return CompressionType.lz4_compression
|
return CompressionType.lz4_compression
|
||||||
elif self.opts.compression == options.kLZ4HCCompression:
|
elif self.opts.compression == options.kLZ4HCCompression:
|
||||||
return CompressionType.lz4hc_compression
|
return CompressionType.lz4hc_compression
|
||||||
|
elif self.opts.compression == options.kXpressCompression:
|
||||||
|
return CompressionType.xpress_compression
|
||||||
|
elif self.opts.compression == options.kZSTD:
|
||||||
|
return CompressionType.zstd_compression
|
||||||
|
elif self.opts.compression == options.kZSTDNotFinalCompression:
|
||||||
|
return CompressionType.zstdnotfinal_compression
|
||||||
|
elif self.opts.compression == options.kDisableCompressionOption:
|
||||||
|
return CompressionType.disable_compression
|
||||||
else:
|
else:
|
||||||
raise Exception("Unknonw type: %s" % self.opts.compression)
|
raise Exception("Unknonw type: %s" % self.opts.compression)
|
||||||
|
|
||||||
|
@ -805,6 +825,12 @@ cdef class Options(object):
|
||||||
self.opts.compression = options.kLZ4Compression
|
self.opts.compression = options.kLZ4Compression
|
||||||
elif value == CompressionType.lz4hc_compression:
|
elif value == CompressionType.lz4hc_compression:
|
||||||
self.opts.compression = options.kLZ4HCCompression
|
self.opts.compression = options.kLZ4HCCompression
|
||||||
|
elif value == CompressionType.zstd_compression:
|
||||||
|
self.opts.compression = options.kZSTD
|
||||||
|
elif value == CompressionType.zstdnotfinal_compression:
|
||||||
|
self.opts.compression = options.kZSTDNotFinalCompression
|
||||||
|
elif value == CompressionType.disable_compression:
|
||||||
|
self.opts.compression = options.kDisableCompressionOption
|
||||||
else:
|
else:
|
||||||
raise TypeError("Unknown compression: %s" % value)
|
raise TypeError("Unknown compression: %s" % value)
|
||||||
|
|
||||||
|
@ -1049,6 +1075,10 @@ cdef class Options(object):
|
||||||
return 'level'
|
return 'level'
|
||||||
if self.opts.compaction_style == kCompactionStyleUniversal:
|
if self.opts.compaction_style == kCompactionStyleUniversal:
|
||||||
return 'universal'
|
return 'universal'
|
||||||
|
if self.opts.compaction_style == kCompactionStyleFIFO:
|
||||||
|
return 'fifo'
|
||||||
|
if self.opts.compaction_style == kCompactionStyleNone:
|
||||||
|
return 'none'
|
||||||
raise Exception("Unknown compaction_style")
|
raise Exception("Unknown compaction_style")
|
||||||
|
|
||||||
def __set__(self, str value):
|
def __set__(self, str value):
|
||||||
|
@ -1056,6 +1086,10 @@ cdef class Options(object):
|
||||||
self.opts.compaction_style = kCompactionStyleLevel
|
self.opts.compaction_style = kCompactionStyleLevel
|
||||||
elif value == 'universal':
|
elif value == 'universal':
|
||||||
self.opts.compaction_style = kCompactionStyleUniversal
|
self.opts.compaction_style = kCompactionStyleUniversal
|
||||||
|
elif value == 'fifo':
|
||||||
|
self.opts.compaction_style = kCompactionStyleFIFO
|
||||||
|
elif value == 'none':
|
||||||
|
self.opts.compaction_style = kCompactionStyleNone
|
||||||
else:
|
else:
|
||||||
raise Exception("Unknown compaction style")
|
raise Exception("Unknown compaction style")
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ cdef extern from "rocksdb/options.h" namespace "rocksdb":
|
||||||
ctypedef enum CompactionStyle:
|
ctypedef enum CompactionStyle:
|
||||||
kCompactionStyleLevel
|
kCompactionStyleLevel
|
||||||
kCompactionStyleUniversal
|
kCompactionStyleUniversal
|
||||||
|
kCompactionStyleFIFO
|
||||||
|
kCompactionStyleNone
|
||||||
|
|
||||||
ctypedef enum CompressionType:
|
ctypedef enum CompressionType:
|
||||||
kNoCompression
|
kNoCompression
|
||||||
|
@ -27,11 +29,21 @@ cdef extern from "rocksdb/options.h" namespace "rocksdb":
|
||||||
kBZip2Compression
|
kBZip2Compression
|
||||||
kLZ4Compression
|
kLZ4Compression
|
||||||
kLZ4HCCompression
|
kLZ4HCCompression
|
||||||
|
kXpressCompression
|
||||||
|
kZSTD
|
||||||
|
kZSTDNotFinalCompression
|
||||||
|
kDisableCompressionOption
|
||||||
|
|
||||||
ctypedef enum ReadTier:
|
ctypedef enum ReadTier:
|
||||||
kReadAllTier
|
kReadAllTier
|
||||||
kBlockCacheTier
|
kBlockCacheTier
|
||||||
|
|
||||||
|
ctypedef enum CompactionPri:
|
||||||
|
kByCompensatedSize
|
||||||
|
kOldestLargestSeqFirst
|
||||||
|
kOldestSmallestSeqFirst
|
||||||
|
kMinOverlappingRatio
|
||||||
|
|
||||||
cdef cppclass Options:
|
cdef cppclass Options:
|
||||||
const Comparator* comparator
|
const Comparator* comparator
|
||||||
shared_ptr[MergeOperator] merge_operator
|
shared_ptr[MergeOperator] merge_operator
|
||||||
|
@ -47,6 +59,7 @@ cdef extern from "rocksdb/options.h" namespace "rocksdb":
|
||||||
int min_write_buffer_number_to_merge
|
int min_write_buffer_number_to_merge
|
||||||
int max_open_files
|
int max_open_files
|
||||||
CompressionType compression
|
CompressionType compression
|
||||||
|
CompactionPri compaction_pri
|
||||||
# TODO: compression_per_level
|
# TODO: compression_per_level
|
||||||
# TODO: compression_opts
|
# TODO: compression_opts
|
||||||
shared_ptr[SliceTransform] prefix_extractor
|
shared_ptr[SliceTransform] prefix_extractor
|
||||||
|
@ -58,7 +71,7 @@ cdef extern from "rocksdb/options.h" namespace "rocksdb":
|
||||||
uint64_t target_file_size_base
|
uint64_t target_file_size_base
|
||||||
int target_file_size_multiplier
|
int target_file_size_multiplier
|
||||||
uint64_t max_bytes_for_level_base
|
uint64_t max_bytes_for_level_base
|
||||||
int max_bytes_for_level_multiplier
|
double max_bytes_for_level_multiplier
|
||||||
vector[int] max_bytes_for_level_multiplier_additional
|
vector[int] max_bytes_for_level_multiplier_additional
|
||||||
int expanded_compaction_factor
|
int expanded_compaction_factor
|
||||||
int source_compaction_factor
|
int source_compaction_factor
|
||||||
|
@ -107,6 +120,8 @@ cdef extern from "rocksdb/options.h" namespace "rocksdb":
|
||||||
cpp_bool inplace_update_support
|
cpp_bool inplace_update_support
|
||||||
size_t inplace_update_num_locks
|
size_t inplace_update_num_locks
|
||||||
shared_ptr[Cache] row_cache
|
shared_ptr[Cache] row_cache
|
||||||
|
# TODO: remove options source_compaction_factor, max_grandparent_overlap_bytes and expanded_compaction_factor from document
|
||||||
|
uint64_t max_compaction_bytes;
|
||||||
|
|
||||||
cdef cppclass WriteOptions:
|
cdef cppclass WriteOptions:
|
||||||
cpp_bool sync
|
cpp_bool sync
|
||||||
|
|
|
@ -37,9 +37,10 @@ class TestOptions(unittest.TestCase):
|
||||||
opts.comparator,
|
opts.comparator,
|
||||||
rocksdb.BytewiseComparator)
|
rocksdb.BytewiseComparator)
|
||||||
|
|
||||||
self.assertEqual('snappy_compression', opts.compression)
|
self.assertEqual(rocksdb.CompressionType.no_compression, opts.compression)
|
||||||
opts.compression = rocksdb.CompressionType.no_compression
|
|
||||||
self.assertEqual('no_compression', opts.compression)
|
opts.compression = rocksdb.CompressionType.zstd_compression
|
||||||
|
self.assertEqual(rocksdb.CompressionType.zstd_compression, opts.compression)
|
||||||
|
|
||||||
def test_block_options(self):
|
def test_block_options(self):
|
||||||
rocksdb.BlockBasedTableFactory(
|
rocksdb.BlockBasedTableFactory(
|
||||||
|
|
Loading…
Reference in a new issue