diff --git a/rocksdb/compaction_filter.pxd b/rocksdb/compaction_filter.pxd new file mode 100644 index 0000000..cfc901d --- /dev/null +++ b/rocksdb/compaction_filter.pxd @@ -0,0 +1,54 @@ +from libcpp cimport bool as cpp_bool +from libcpp.string cimport string +from libcpp.vector cimport vector +from libcpp.memory cimport unique_ptr +from libc.stdint cimport uint32_t +from .slice_ cimport Slice + +cdef extern from "rocksdb/compaction_filter.h" namespace "rocksdb": + cdef cppclass CompactionFilterContext: + cpp_bool is_full_compaction + cpp_bool is_manual_compaction + + cdef enum ValueType "rocksdb::CompactionFilter::ValueType": + ValueType_kValue "rocksdb::CompactionFilter::ValueType::kValue" + ValueType_kMergeOperand "rocksdb::CompactionFilter::ValueType::kMergeOperand" + ValueType_kBlobIndex "rocksdb::CompactionFilter::ValueType::kBlobIndex" + + cdef enum Decision "rocksdb::CompactionFilter::Decision": + Decision_kKeep "rocksdb::CompactionFilter::Decision::kKeep" + Decision_kRemove "rocksdb::CompactionFilter::Decision::kRemove" + Decision_kChangeValue "rocksdb::CompactionFilter::Decision::kChangeValue" + Decision_kRemoveAndSkipUntil "rocksdb::CompactionFilter::Decision::kRemoveAndSkipUntil" + + cdef enum BlobDecision "rocksdb::CompactionFilter::BlobDecision": + BlobDecision_kKeep "rocksdb::CompactionFilter::BlobDecision::kKeep" + BlobDecision_kChangeValue "rocksdb::CompactionFilter::BlobDecision::kChangeValue" + BlobDecision_kCorruption "rocksdb::CompactionFilter::BlobDecision::kCorruption" + BlobDecision_kIOError "rocksdb::CompactionFilter::BlobDecision::kIOError" + + cdef cppclass Context "rocksdb::CompactionFilter::Context": + cpp_bool is_full_compaction + cpp_bool is_manual_compaction + uint32_t column_family_id + + cdef cppclass CompactionFilter: + cpp_bool Filter(int, const Slice&, + const Slice&, + string*, + cpp_bool*) nogil except+ + cpp_bool FilterMergeOperand(int, const Slice&, + const Slice&) nogil except+ + Decision FilterV2(int level, const Slice&, ValueType, + const Slice&, string*, + string*) + BlobDecision PrepareBlobOutput(const Slice&, + const Slice&, + string*) + cpp_bool IgnoreSnapshots() + const char* Name() + + cdef cppclass CompactionFilterFactory: + unique_ptr[CompactionFilter] CreateCompactionFilter( + const Context&) + const char* Name() diff --git a/rocksdb/concurrent_task_limiter.pxd b/rocksdb/concurrent_task_limiter.pxd new file mode 100644 index 0000000..b1320b4 --- /dev/null +++ b/rocksdb/concurrent_task_limiter.pxd @@ -0,0 +1,11 @@ +from libcpp.string cimport string +from libc.stdint cimport int32_t + +cdef extern from "rocksdb/concurrent_task_limiter.h" namespace "rocksdb": + cdef cppclass ConcurrentTaskLimiter: + const string& GetName() + void SetMaxOutstandingTask(int32_t) + void ResetMaxOutstandingTask() + int32_t GetOutstandingTask() + + ConcurrentTaskLimiter* NewConcurrentTaskLimiter(const string&, int32_t) diff --git a/rocksdb/options.pxd b/rocksdb/options.pxd index 722b71a..75797c3 100644 --- a/rocksdb/options.pxd +++ b/rocksdb/options.pxd @@ -20,6 +20,8 @@ from .advanced_options cimport CompressionOptions from .advanced_options cimport AdvancedColumnFamilyOptions from .env cimport Env from .types cimport SequenceNumber +from .compaction_filter cimport CompactionFilter, CompactionFilterFactory +from .concurrent_task_limiter cimport ConcurrentTaskLimiter cdef extern from "rocksdb/options.h" namespace "rocksdb": ctypedef enum CpuPriority: @@ -48,8 +50,8 @@ cdef extern from "rocksdb/options.h" namespace "rocksdb": ColumnFamilyOptions* OptimizeUniversalStyleCompaction(uint64_t) const Comparator* comparator shared_ptr[MergeOperator] merge_operator - # TODO: compaction_filter - # TODO: compaction_filter_factory + CompactionFilter* compaction_filter + shared_ptr[CompactionFilterFactory] compaction_filter_factory size_t write_buffer_size advanced_options.CompressionType compression advanced_options.CompressionType bottommost_compression @@ -65,7 +67,7 @@ cdef extern from "rocksdb/options.h" namespace "rocksdb": shared_ptr[TableFactory] table_factory vector[DbPath] cf_paths - # TODO shared_ptr[ConcurrentTaskLimiter] compaction_thread_limiter + shared_ptr[ConcurrentTaskLimiter] compaction_thread_limiter ColumnFamilyOptions() ColumnFamilyOptions(const Options& options) void Dump(Logger*)