Skip to content

Commit fbf474f

Browse files
Jonah CohenGunnar Kudrjavets
authored andcommitted
Add rocksdb_db_options and rocksdb_default_cf_options sysvars.
(And remove rocksdb_compaction_style since it's redundant.)
1 parent 597c129 commit fbf474f

File tree

1 file changed

+30
-12
lines changed

1 file changed

+30
-12
lines changed

storage/rocksdb/ha_rocksdb.cc

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "rdb_cf_manager.h"
3636

3737
#include "rocksdb/table.h"
38+
#include "utilities/convenience.h"
3839

3940
/* This is here to get PRIu64, PRId64 */
4041
#ifndef __STDC_FORMAT_MACROS
@@ -60,6 +61,8 @@ Numeric_cf_option write_buffer_size_map;
6061
static char * rocksdb_target_file_size_base_str;
6162
Numeric_cf_option target_file_size_base_map;
6263

64+
static char * rocksdb_db_options;
65+
static char * rocksdb_default_cf_options;
6366

6467
///////////////////////////////////////////////////////////
6568
// Globals
@@ -186,7 +189,6 @@ static bool rocksdb_parse_target_file_size_base_arg()
186189
// Options definitions
187190
//////////////////////////////////////////////////////////////////////////////
188191
static long long rocksdb_block_cache_size;
189-
static unsigned long rocksdb_compaction_style;
190192

191193
//static long long rocksdb_write_buffer_size;
192194
//static int rocksdb_target_file_size_base;
@@ -207,15 +209,6 @@ static MYSQL_THDVAR_ULONG(bulk_load_size, PLUGIN_VAR_RQCMDARG,
207209
"Max #records in a batch for bulk-load mode",
208210
NULL, NULL, /*default*/ 1000, /*min*/ 1, /*max*/ 1024*1024*1024, 0);
209211

210-
static MYSQL_SYSVAR_ULONG(compaction_style, rocksdb_compaction_style,
211-
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
212-
"options.compaction_style for RocksDB",
213-
NULL, NULL,
214-
/*default*/ rocksdb::CompactionStyle::kCompactionStyleLevel,
215-
/*min*/ rocksdb::CompactionStyle::kCompactionStyleLevel,
216-
/*max*/ rocksdb::CompactionStyle::kCompactionStyleFIFO,
217-
0);
218-
219212
static MYSQL_SYSVAR_LONGLONG(block_cache_size, rocksdb_block_cache_size,
220213
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
221214
"block_cache size for RocksDB",
@@ -229,6 +222,16 @@ static MYSQL_SYSVAR_STR(write_buffer_size, rocksdb_write_buffer_size_str,
229222
rocksdb_write_buffer_size_update, "4194304" /* default is 4 MB for default CF */);
230223
const longlong ROCKSDB_WRITE_BUFFER_SIZE_DEFAULT=4194304;
231224

225+
static MYSQL_SYSVAR_STR(db_options, rocksdb_db_options,
226+
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
227+
"db options for RocksDB",
228+
NULL, NULL, "");
229+
230+
static MYSQL_SYSVAR_STR(default_cf_options, rocksdb_default_cf_options,
231+
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
232+
"default cf options for RocksDB",
233+
NULL, NULL, "");
234+
232235
static MYSQL_SYSVAR_STR(target_file_size_base,
233236
rocksdb_target_file_size_base_str,
234237
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
@@ -255,8 +258,9 @@ static struct st_mysql_sys_var* rocksdb_system_variables[]= {
255258

256259
MYSQL_SYSVAR(block_cache_size),
257260
MYSQL_SYSVAR(write_buffer_size),
261+
MYSQL_SYSVAR(db_options),
262+
MYSQL_SYSVAR(default_cf_options),
258263
MYSQL_SYSVAR(target_file_size_base),
259-
MYSQL_SYSVAR(compaction_style),
260264

261265
NULL
262266
};
@@ -707,6 +711,7 @@ static int rocksdb_init_func(void *p)
707711
std::vector<std::string> cf_names;
708712

709713
rocksdb::DBOptions db_opts;
714+
710715
db_opts.create_if_missing = true;
711716
db_opts.statistics= rocksdb_stats;
712717

@@ -743,12 +748,25 @@ static int rocksdb_init_func(void *p)
743748

744749
default_cf_opts.write_buffer_size= write_buffer_size_map.get_default_val();
745750
default_cf_opts.target_file_size_base= target_file_size_base_map.get_default_val();
746-
default_cf_opts.compaction_style = (rocksdb::CompactionStyle)rocksdb_compaction_style;
747751

748752
rocksdb::BlockBasedTableOptions table_options;
749753
table_options.block_cache = rocksdb::NewLRUCache(rocksdb_block_cache_size);
750754
default_cf_opts.table_factory.reset(rocksdb::NewBlockBasedTableFactory(table_options));
751755

756+
if (!rocksdb::GetDBOptionsFromString(
757+
db_opts,
758+
std::string(rocksdb_db_options),
759+
&db_opts)) {
760+
DBUG_RETURN(1);
761+
}
762+
763+
if (!rocksdb::GetColumnFamilyOptionsFromString(
764+
default_cf_opts,
765+
std::string(rocksdb_default_cf_options),
766+
&default_cf_opts)) {
767+
DBUG_RETURN(1);
768+
}
769+
752770
/*
753771
If there are no column families, we're creating the new database.
754772
Create one column family named "default".

0 commit comments

Comments
 (0)