31
31
#include " rdb_locks.h"
32
32
#include " rdb_rowmods.h"
33
33
34
- #include " rdb_cf_option .h"
34
+ #include " rdb_cf_options .h"
35
35
#include " rdb_cf_manager.h"
36
36
37
37
#include " rocksdb/table.h"
@@ -54,15 +54,11 @@ void key_copy(uchar *to_key, uchar *from_record, KEY *key_info,
54
54
// Parameters and settings
55
55
// /////////////////////////////////////////////////////////
56
56
extern const longlong ROCKSDB_WRITE_BUFFER_SIZE_DEFAULT;
57
- extern const int ROCKSDB_TARGET_FILE_SIZE_BASE_DEFAULT;
58
- static char * rocksdb_write_buffer_size_str;
59
- Numeric_cf_option write_buffer_size_map;
60
-
61
- static char * rocksdb_target_file_size_base_str;
62
- Numeric_cf_option target_file_size_base_map;
63
57
64
58
static char * rocksdb_db_options;
65
59
static char * rocksdb_default_cf_options;
60
+ static char * rocksdb_cf_options_file;
61
+ Cf_options rocksdb_cf_options_map;
66
62
67
63
// /////////////////////////////////////////////////////////
68
64
// Globals
@@ -95,64 +91,10 @@ mysql_mutex_t rocksdb_mutex;
95
91
// ////////////////////////////////////////////////////////////////////////////
96
92
97
93
static int
98
- rocksdb_write_buffer_size_validate (THD* thd,
99
- struct st_mysql_sys_var * var,
100
- void * save,
101
- struct st_mysql_value * value)
102
- {
103
- /* The option is read-only, it should never be updated */
104
- DBUG_ASSERT (0 );
105
- return 1 ;
106
- #if 0
107
- const char* param_str;
108
- char buff[STRING_BUFFER_USUAL_SIZE];
109
- int len= sizeof(buff);
110
-
111
- param_str= value->val_str(value, buff, &len);
112
- if (param_str != NULL)
113
- {
114
- if (parse_multi_number(param_str, &write_buffer_size_map))
115
- {
116
- save= (void*)1;
117
- return 1;
118
- }
119
- }
120
- save= NULL;
121
- return 0;
122
- #endif
123
- }
124
-
125
-
126
- static void
127
- rocksdb_write_buffer_size_update (THD* thd,
94
+ rocksdb_cf_options_file_validate (THD* thd,
128
95
struct st_mysql_sys_var * var,
129
- void * var_ptr,
130
- const void * save)
131
- {
132
- /* The option is read-only, it should never be updated */
133
- DBUG_ASSERT (0 );
134
- }
135
-
136
-
137
- static bool rocksdb_parse_write_buffer_size_arg ()
138
- {
139
- write_buffer_size_map.default_val = ROCKSDB_WRITE_BUFFER_SIZE_DEFAULT;
140
- if (parse_per_cf_numeric (rocksdb_write_buffer_size_str, &write_buffer_size_map))
141
- {
142
- sql_print_error (" RocksDB: Invalid value for rocksdb_write_buffer_size: %s" ,
143
- rocksdb_write_buffer_size_str);
144
- return true ;
145
- }
146
- else
147
- return false ;
148
- }
149
-
150
-
151
- static int
152
- rocksdb_target_file_size_base_validate (THD* thd,
153
- struct st_mysql_sys_var * var,
154
- void * save,
155
- struct st_mysql_value * value)
96
+ void * save,
97
+ struct st_mysql_value * value)
156
98
{
157
99
/* The option is read-only, it should never be updated */
158
100
DBUG_ASSERT (0 );
@@ -161,30 +103,15 @@ rocksdb_target_file_size_base_validate(THD* thd,
161
103
162
104
163
105
static void
164
- rocksdb_target_file_size_base_update (THD* thd,
165
- struct st_mysql_sys_var * var,
166
- void * var_ptr,
167
- const void * save)
106
+ rocksdb_cf_options_file_update (THD* thd,
107
+ struct st_mysql_sys_var * var,
108
+ void * var_ptr,
109
+ const void * save)
168
110
{
169
111
/* The option is read-only, it should never be updated */
170
112
DBUG_ASSERT (0 );
171
113
}
172
114
173
-
174
- static bool rocksdb_parse_target_file_size_base_arg ()
175
- {
176
- target_file_size_base_map.default_val = ROCKSDB_TARGET_FILE_SIZE_BASE_DEFAULT;
177
- if (parse_per_cf_numeric (rocksdb_target_file_size_base_str,
178
- &target_file_size_base_map))
179
- {
180
- sql_print_error (" RocksDB: Invalid value for rocksdb_target_file_size_base: %s" ,
181
- rocksdb_target_file_size_base_str);
182
- return true ;
183
- }
184
- else
185
- return false ;
186
- }
187
-
188
115
// ////////////////////////////////////////////////////////////////////////////
189
116
// Options definitions
190
117
// ////////////////////////////////////////////////////////////////////////////
@@ -215,13 +142,6 @@ static MYSQL_SYSVAR_LONGLONG(block_cache_size, rocksdb_block_cache_size,
215
142
NULL , NULL , /* RocksDB's default is 8 MB: */ 8 *1024 *1024L ,
216
143
/* min */ 1024L , /* max */ LONGLONG_MAX, /* Block size */ 1024L );
217
144
218
- static MYSQL_SYSVAR_STR (write_buffer_size, rocksdb_write_buffer_size_str,
219
- PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
220
- " options.write_buffer_size for RocksDB (Can also be set per-column family)" ,
221
- rocksdb_write_buffer_size_validate,
222
- rocksdb_write_buffer_size_update, " 4194304" /* default is 4 MB for default CF */ );
223
- const longlong ROCKSDB_WRITE_BUFFER_SIZE_DEFAULT=4194304 ;
224
-
225
145
static MYSQL_SYSVAR_STR (db_options, rocksdb_db_options,
226
146
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
227
147
" db options for RocksDB" ,
@@ -232,23 +152,13 @@ static MYSQL_SYSVAR_STR(default_cf_options, rocksdb_default_cf_options,
232
152
" default cf options for RocksDB" ,
233
153
NULL , NULL , " " );
234
154
235
- static MYSQL_SYSVAR_STR (target_file_size_base,
236
- rocksdb_target_file_size_base_str,
155
+ static MYSQL_SYSVAR_STR (cf_options_file, rocksdb_cf_options_file,
237
156
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
238
- " options.target_file_size_base for RocksDB (Can also be set per-column family)" ,
239
- rocksdb_target_file_size_base_validate,
240
- rocksdb_target_file_size_base_update,
241
- " 2097152" /* default is 2 MB for default CF */ );
242
- const int ROCKSDB_TARGET_FILE_SIZE_BASE_DEFAULT=2097152 ;
243
-
244
- #if 0
245
- static MYSQL_SYSVAR_INT(target_file_size_base,
246
- rocksdb_target_file_size_base,
247
- PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
248
- "options.target_file_size_base for RocksDB",
249
- NULL, NULL, /* RocksDB's default is 2 MB: */ 2*1024*1024L,
250
- /* min */ 1024L, /* max */ INT_MAX, /* Block size */1024L);
251
- #endif
157
+ " path to cnf file with cf options for RocksDB" ,
158
+ rocksdb_cf_options_file_validate,
159
+ rocksdb_cf_options_file_update, " " );
160
+
161
+ const longlong ROCKSDB_WRITE_BUFFER_SIZE_DEFAULT=4194304 ;
252
162
253
163
static struct st_mysql_sys_var * rocksdb_system_variables[]= {
254
164
MYSQL_SYSVAR (lock_wait_timeout),
@@ -257,10 +167,9 @@ static struct st_mysql_sys_var* rocksdb_system_variables[]= {
257
167
MYSQL_SYSVAR (bulk_load_size),
258
168
259
169
MYSQL_SYSVAR (block_cache_size),
260
- MYSQL_SYSVAR (write_buffer_size),
261
170
MYSQL_SYSVAR (db_options),
262
171
MYSQL_SYSVAR (default_cf_options),
263
- MYSQL_SYSVAR (target_file_size_base ),
172
+ MYSQL_SYSVAR (cf_options_file ),
264
173
265
174
NULL
266
175
};
@@ -651,12 +560,7 @@ static bool rocksdb_show_status(handlerton* hton,
651
560
652
561
void get_cf_options (const std::string &cf_name, rocksdb::ColumnFamilyOptions *opts)
653
562
{
654
- *opts= default_cf_opts;
655
- int tfsb= target_file_size_base_map.get_val (cf_name.c_str ());
656
- size_t wbs= write_buffer_size_map.get_val (cf_name.c_str ());
657
-
658
- opts->write_buffer_size = wbs;
659
- opts->target_file_size_base = tfsb;
563
+ rocksdb_cf_options_map.Get (cf_name, opts);
660
564
}
661
565
662
566
/*
@@ -671,13 +575,6 @@ static int rocksdb_init_func(void *p)
671
575
init_rocksdb_psi_keys ();
672
576
#endif
673
577
674
- /* Parse command-line option values */
675
- if (rocksdb_parse_write_buffer_size_arg () ||
676
- rocksdb_parse_target_file_size_base_arg ())
677
- {
678
- DBUG_RETURN (1 );
679
- }
680
-
681
578
rocksdb_hton= (handlerton *)p;
682
579
mysql_mutex_init (ex_key_mutex_example, &rocksdb_mutex, MY_MUTEX_INIT_FAST);
683
580
(void ) my_hash_init (&rocksdb_open_tables,system_charset_info,32 ,0 ,0 ,
@@ -746,8 +643,7 @@ static int rocksdb_init_func(void *p)
746
643
747
644
default_cf_opts.comparator = &rocksdb_pk_comparator;
748
645
749
- default_cf_opts.write_buffer_size = write_buffer_size_map.get_default_val ();
750
- default_cf_opts.target_file_size_base = target_file_size_base_map.get_default_val ();
646
+ default_cf_opts.write_buffer_size = ROCKSDB_WRITE_BUFFER_SIZE_DEFAULT;
751
647
752
648
rocksdb::BlockBasedTableOptions table_options;
753
649
table_options.block_cache = rocksdb::NewLRUCache (rocksdb_block_cache_size);
@@ -760,10 +656,10 @@ static int rocksdb_init_func(void *p)
760
656
DBUG_RETURN (1 );
761
657
}
762
658
763
- if (!rocksdb::GetColumnFamilyOptionsFromString (
764
- default_cf_opts,
765
- std::string (rocksdb_default_cf_options),
766
- &default_cf_opts )) {
659
+ if (!rocksdb_cf_options_map. SetDefault (
660
+ std::string (rocksdb_default_cf_options)) ||
661
+ !rocksdb_cf_options_map. ParseConfigFile (
662
+ std::string (rocksdb_cf_options_file) )) {
767
663
DBUG_RETURN (1 );
768
664
}
769
665
0 commit comments