Commit 461bd90d authored by Cholerae Hu's avatar Cholerae Hu Committed by zhangjinpeng1987

api: add set_delayed_write_rate method (#80)

parent 5060d530
......@@ -2096,6 +2096,10 @@ void crocksdb_options_set_compaction_priority(crocksdb_options_t *opt,
opt->rep.compaction_pri = static_cast<rocksdb::CompactionPri>(priority);
}
void crocksdb_options_set_delayed_write_rate(crocksdb_options_t *opt, uint64_t delayed_write_rate) {
opt->rep.delayed_write_rate = delayed_write_rate;
}
char *crocksdb_options_statistics_get_string(crocksdb_options_t *opt) {
rocksdb::Statistics *statistics = opt->rep.statistics.get();
if (statistics) {
......
......@@ -843,6 +843,9 @@ enum {
extern C_ROCKSDB_LIBRARY_API void
crocksdb_options_set_compaction_priority(crocksdb_options_t *, unsigned char);
extern C_ROCKSDB_LIBRARY_API void crocksdb_options_set_delayed_write_rate(
crocksdb_options_t*, uint64_t);
/* RateLimiter */
extern C_ROCKSDB_LIBRARY_API crocksdb_ratelimiter_t* crocksdb_ratelimiter_create(
int64_t rate_bytes_per_sec, int64_t refill_period_us, int32_t fairness);
......
......@@ -324,6 +324,7 @@ extern "C" {
prefix_extractor: *mut DBSliceTransform);
pub fn crocksdb_options_set_memtable_prefix_bloom_size_ratio(options: *mut DBOptions,
ratio: c_double);
pub fn crocksdb_options_set_delayed_write_rate(options: *mut DBOptions, rate: u64);
pub fn crocksdb_options_set_ratelimiter(options: *mut DBOptions, limiter: *mut DBRateLimiter);
pub fn crocksdb_options_set_info_log(options: *mut DBOptions, logger: *mut DBLogger);
pub fn crocksdb_options_get_block_cache_usage(options: *const DBOptions) -> usize;
......
......@@ -652,6 +652,12 @@ impl Options {
}
}
pub fn set_delayed_write_rate(&mut self, rate: u64) {
unsafe {
crocksdb_ffi::crocksdb_options_set_delayed_write_rate(self.inner, rate);
}
}
pub fn enable_statistics(&mut self) {
unsafe {
crocksdb_ffi::crocksdb_options_enable_statistics(self.inner);
......
......@@ -114,6 +114,16 @@ fn test_memtable_insert_hint_prefix_extractor() {
assert_eq!(db.get(b"k0-3").unwrap().unwrap(), b"c");
}
#[test]
fn test_set_delayed_write_rate() {
let path = TempDir::new("_rust_rocksdb_test_set_delayed_write_rate").expect("");
let mut opts = Options::new();
opts.create_if_missing(true);
opts.set_delayed_write_rate(2 * 1024 * 1024);
let db = DB::open(opts, path.path().to_str().unwrap()).unwrap();
drop(db);
}
#[test]
fn test_set_ratelimiter() {
let path = TempDir::new("_rust_rocksdb_test_set_rate_limiter").expect("");
......
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