Commit 83165e83 authored by Connor's avatar Connor Committed by pingcap-github-bot

add API to set level merge and range merge (#379)

parent c130c13b
......@@ -5254,6 +5254,21 @@ void ctitandb_options_set_disable_background_gc(ctitandb_options_t* options,
options->rep.disable_background_gc = disable;
}
void ctitandb_options_set_level_merge(ctitandb_options_t* options,
unsigned char enable) {
options->rep.level_merge = enable;
}
void ctitandb_options_set_range_merge(ctitandb_options_t* options,
unsigned char enable) {
options->rep.range_merge = enable;
}
void ctitandb_options_set_max_sorted_runs(ctitandb_options_t* options,
int size) {
options->rep.max_sorted_runs = size;
}
void ctitandb_options_set_max_gc_batch_size(ctitandb_options_t* options,
uint64_t size) {
options->rep.max_gc_batch_size = size;
......
......@@ -2095,6 +2095,15 @@ extern C_ROCKSDB_LIBRARY_API void ctitandb_encode_blob_index(
extern C_ROCKSDB_LIBRARY_API void ctitandb_options_set_disable_background_gc(
ctitandb_options_t* options, unsigned char disable);
extern C_ROCKSDB_LIBRARY_API void ctitandb_options_set_level_merge(ctitandb_options_t* options,
unsigned char enable);
extern C_ROCKSDB_LIBRARY_API void ctitandb_options_set_range_merge(ctitandb_options_t* options,
unsigned char enable);
extern C_ROCKSDB_LIBRARY_API void ctitandb_options_set_max_sorted_runs(ctitandb_options_t* options,
int size);
extern C_ROCKSDB_LIBRARY_API void ctitandb_options_set_max_gc_batch_size(
ctitandb_options_t* options, uint64_t size);
......
Subproject commit 8376c989f018f0edb88183d85981e0a530898eeb
Subproject commit 96922d49054b921b84003a78b73040a4bbac55dc
This diff is collapsed.
......@@ -3196,7 +3196,7 @@ mod test {
let mut opts = DBOptions::new();
opts.create_if_missing(true);
let mut db = DB::open(opts, dbpath).unwrap();
let db = DB::open(opts, dbpath).unwrap();
let cf_handle = db.cf_handle("default").unwrap();
let mp = db.get_map_property_cf(cf_handle, "rocksdb.cfstats");
......
......@@ -12,7 +12,7 @@
// limitations under the License.
use crocksdb_ffi::{self, DBEntryType, DBTablePropertiesCollector, DBUserCollectedProperties};
use libc::{c_char, c_int, c_void, size_t, uint64_t, uint8_t};
use libc::{c_char, c_int, c_void, size_t};
use std::collections::HashMap;
use std::ffi::CString;
use std::mem;
......@@ -62,13 +62,13 @@ extern "C" fn destruct(handle: *mut c_void) {
pub extern "C" fn add(
handle: *mut c_void,
key: *const uint8_t,
key: *const u8,
key_len: size_t,
value: *const uint8_t,
value: *const u8,
value_len: size_t,
entry_type: c_int,
seq: uint64_t,
file_size: uint64_t,
seq: u64,
file_size: u64,
) {
unsafe {
let handle = &mut *(handle as *mut TablePropertiesCollectorHandle);
......
......@@ -12,7 +12,7 @@
// limitations under the License.
use crocksdb_ffi::{self, DBTablePropertiesCollector, DBTablePropertiesCollectorFactory};
use libc::{c_char, c_void, uint32_t};
use libc::{c_char, c_void};
use std::ffi::CString;
use table_properties_collector::{new_table_properties_collector, TablePropertiesCollector};
......@@ -55,7 +55,7 @@ extern "C" fn destruct(handle: *mut c_void) {
extern "C" fn create_table_properties_collector(
handle: *mut c_void,
cf: uint32_t,
cf: u32,
) -> *mut DBTablePropertiesCollector {
unsafe {
let handle = &mut *(handle as *mut TablePropertiesCollectorFactoryHandle);
......
......@@ -64,6 +64,24 @@ impl TitanDBOptions {
}
}
pub fn set_level_merge(&mut self, enable: bool) {
unsafe {
crocksdb_ffi::ctitandb_options_set_level_merge(self.inner, enable);
}
}
pub fn set_range_merge(&mut self, enable: bool) {
unsafe {
crocksdb_ffi::ctitandb_options_set_range_merge(self.inner, enable);
}
}
pub fn set_max_sorted_runs(&mut self, size: i32) {
unsafe {
crocksdb_ffi::ctitandb_options_set_max_sorted_runs(self.inner, size);
}
}
pub fn set_max_background_gc(&mut self, size: i32) {
unsafe {
crocksdb_ffi::ctitandb_options_set_max_background_gc(self.inner, size);
......
......@@ -150,7 +150,7 @@ fn test_provided_merge(
#[test]
pub fn test_column_family_option_use_doubly_skiplist() {
let mut cf_opts = ColumnFamilyOptions::new();
let cf_opts = ColumnFamilyOptions::new();
let memtable_name = cf_opts.get_memtable_factory_name();
assert!(memtable_name.is_some());
assert_eq!("SkipListFactory", memtable_name.unwrap());
......
......@@ -111,6 +111,9 @@ fn test_titandb() {
tdb_opts.set_blob_file_compression(DBCompressionType::No);
tdb_opts.set_disable_background_gc(true);
tdb_opts.set_purge_obsolete_files_period(10);
tdb_opts.set_level_merge(false);
tdb_opts.set_range_merge(false);
tdb_opts.set_max_sorted_runs(20);
let mut opts = DBOptions::new();
opts.create_if_missing(true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment