From fd3fb4b0bfda063647017e74aa0cc85a5d4eccec Mon Sep 17 00:00:00 2001 From: Reed Allman Date: Mon, 7 Jul 2014 21:12:25 -0700 Subject: [PATCH] C API: update options w/ convenience funcs & fifo compaction --- db/c.cc | 44 ++++++++++++++++++++++++++++++++++++++++++++ include/rocksdb/c.h | 20 +++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/db/c.cc b/db/c.cc index 89cff6eee..0b716b108 100644 --- a/db/c.cc +++ b/db/c.cc @@ -36,6 +36,7 @@ using rocksdb::ColumnFamilyHandle; using rocksdb::ColumnFamilyOptions; using rocksdb::CompactionFilter; using rocksdb::CompactionFilterFactory; +using rocksdb::CompactionOptionsFIFO; using rocksdb::Comparator; using rocksdb::CompressionType; using rocksdb::DB; @@ -73,6 +74,7 @@ struct rocksdb_iterator_t { Iterator* rep; }; struct rocksdb_writebatch_t { WriteBatch rep; }; struct rocksdb_snapshot_t { const Snapshot* rep; }; struct rocksdb_flushoptions_t { FlushOptions rep; }; +struct rocksdb_fifo_compaction_options_t { CompactionOptionsFIFO rep; }; struct rocksdb_readoptions_t { ReadOptions rep; }; struct rocksdb_writeoptions_t { WriteOptions rep; }; struct rocksdb_options_t { Options rep; }; @@ -957,6 +959,26 @@ void rocksdb_options_destroy(rocksdb_options_t* options) { delete options; } +void rocksdb_options_increase_parallelism( + rocksdb_options_t* opt, int total_threads) { + opt->rep.IncreaseParallelism(total_threads); +} + +void rocksdb_options_optimize_for_point_lookup( + rocksdb_options_t* opt) { + opt->rep.OptimizeForPointLookup(); +} + +void rocksdb_options_optimize_level_style_compaction( + rocksdb_options_t* opt, uint64_t memtable_memory_budget) { + opt->rep.OptimizeLevelStyleCompaction(memtable_memory_budget); +} + +void rocksdb_options_optimize_universal_style_compaction( + rocksdb_options_t* opt, uint64_t memtable_memory_budget) { + opt->rep.OptimizeUniversalStyleCompaction(memtable_memory_budget); +} + void rocksdb_options_set_compaction_filter( rocksdb_options_t* opt, rocksdb_compactionfilter_t* filter) { @@ -1445,6 +1467,12 @@ void rocksdb_options_set_universal_compaction_options(rocksdb_options_t *opt, ro opt->rep.compaction_options_universal = *(uco->rep); } +void rocksdb_options_set_fifo_compaction_options( + rocksdb_options_t* opt, + rocksdb_fifo_compaction_options_t* fifo) { + opt->rep.compaction_options_fifo = fifo->rep; +} + /* TODO: DB::OpenForReadOnly @@ -1803,6 +1831,22 @@ void rocksdb_universal_compaction_options_destroy( delete uco; } +rocksdb_fifo_compaction_options_t* rocksdb_fifo_compaction_options_create() { + rocksdb_fifo_compaction_options_t* result = new rocksdb_fifo_compaction_options_t; + result->rep = CompactionOptionsFIFO(); + return result; +} + +void rocksdb_fifo_compaction_options_set_max_table_files_size( + rocksdb_fifo_compaction_options_t* fifo_opts, uint64_t size) { + fifo_opts->rep.max_table_files_size = size; +} + +void rocksdb_fifo_compaction_options_destroy( + rocksdb_fifo_compaction_options_t* fifo_opts) { + delete fifo_opts; +} + void rocksdb_options_set_min_level_to_compress(rocksdb_options_t* opt, int level) { if (level >= 0) { assert(level <= opt->rep.num_levels); diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index 4aac3466a..115909cd3 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -63,6 +63,7 @@ typedef struct rocksdb_compactionfilterfactory_t rocksdb_compactionfilterfactory_t; typedef struct rocksdb_comparator_t rocksdb_comparator_t; typedef struct rocksdb_env_t rocksdb_env_t; +typedef struct rocksdb_fifo_compaction_options_t rocksdb_fifo_compaction_options_t; typedef struct rocksdb_filelock_t rocksdb_filelock_t; typedef struct rocksdb_filterpolicy_t rocksdb_filterpolicy_t; typedef struct rocksdb_flushoptions_t rocksdb_flushoptions_t; @@ -345,6 +346,14 @@ extern const char* rocksdb_writebatch_data(rocksdb_writebatch_t*, size_t *size); extern rocksdb_options_t* rocksdb_options_create(); extern void rocksdb_options_destroy(rocksdb_options_t*); +extern void rocksdb_options_increase_parallelism( + rocksdb_options_t* opt, int total_threads); +extern void rocksdb_options_optimize_for_point_lookup( + rocksdb_options_t* opt); +extern void rocksdb_options_optimize_level_style_compaction( + rocksdb_options_t* opt, uint64_t memtable_memory_budget); +extern void rocksdb_options_optimize_universal_style_compaction( + rocksdb_options_t* opt, uint64_t memtable_memory_budget); extern void rocksdb_options_set_compaction_filter( rocksdb_options_t*, rocksdb_compactionfilter_t*); @@ -518,10 +527,13 @@ extern void rocksdb_options_set_compression(rocksdb_options_t*, int); enum { rocksdb_level_compaction = 0, - rocksdb_universal_compaction = 1 + rocksdb_universal_compaction = 1, + rocksdb_fifo_compaction = 2 }; extern void rocksdb_options_set_compaction_style(rocksdb_options_t*, int); extern void rocksdb_options_set_universal_compaction_options(rocksdb_options_t*, rocksdb_universal_compaction_options_t*); +extern void rocksdb_options_set_fifo_compaction_options(rocksdb_options_t* opt, + rocksdb_fifo_compaction_options_t* fifo); /* Compaction Filter */ @@ -702,6 +714,12 @@ extern void rocksdb_universal_compaction_options_set_stop_style( extern void rocksdb_universal_compaction_options_destroy( rocksdb_universal_compaction_options_t*); +extern rocksdb_fifo_compaction_options_t* rocksdb_fifo_compaction_options_create(); +extern void rocksdb_fifo_compaction_options_set_max_table_files_size( + rocksdb_fifo_compaction_options_t* fifo_opts, uint64_t size); +extern void rocksdb_fifo_compaction_options_destroy( + rocksdb_fifo_compaction_options_t* fifo_opts); + extern int rocksdb_livefiles_count( const rocksdb_livefiles_t*); extern const char* rocksdb_livefiles_name(