Skip to content

Commit

Permalink
Issue #11: Column Family support: address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
spetrunia authored and Herman Lee committed Sep 11, 2015
1 parent 7586bcc commit f002aea
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
12 changes: 5 additions & 7 deletions storage/rocksdb/ha_rocksdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -741,16 +741,14 @@ static int rocksdb_init_func(void *p)
sql_print_information("RocksDB: Column Families at start:");
for (size_t i = 0; i < cf_names.size(); ++i)
{
int tfsb= target_file_size_base_map.get_val(cf_names[i].c_str());
size_t wbs= write_buffer_size_map.get_val(cf_names[i].c_str());
rocksdb::ColumnFamilyOptions opts;
get_cf_options(cf_names[i], &opts);

sql_print_information(" cf=%s", cf_names[i].c_str());
sql_print_information(" write_buffer_size=%ld", wbs);
sql_print_information(" target_file_size_base=%d", tfsb);
sql_print_information(" write_buffer_size=%ld", opts.write_buffer_size);
sql_print_information(" target_file_size_base=%d",
opts.target_file_size_base);

rocksdb::ColumnFamilyOptions opts(default_cf_opts);
opts.write_buffer_size= wbs;
opts.target_file_size_base= tfsb;
cf_descr.push_back(rocksdb::ColumnFamilyDescriptor(cf_names[i], opts));
}

Expand Down
29 changes: 21 additions & 8 deletions storage/rocksdb/rdb_cf_option.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


/*
Read a number from a string. The number may have a suffix Kk/Mm/Gg.
Read a number from a string. The number may have a suffix Kk/Mm/Gg/Tt.
The code is copied from eval_num_suffix().
@param str INOUT string pointer
Expand All @@ -52,6 +52,8 @@ bool read_number_and_suffix(const char **str, longlong *number)
num*= 1024L * 1024L;
else if (*endchar == 'g' || *endchar == 'G')
num*= 1024L * 1024L * 1024L;
else if (*endchar == 't' || *endchar == 'T')
num*= 1024LL * 1024LL * 1024LL * 1024LL;
else
suffix_chars= 0;

Expand All @@ -63,10 +65,10 @@ bool read_number_and_suffix(const char **str, longlong *number)


/*
Read column family name, followed by semicolon ':'
Read column family name, followed by colon ':'
@param str INOUT string pointer. On return points to right after
the semicolon.
the colon.
@return 0 - OK
1 - Error
*/
Expand All @@ -79,17 +81,27 @@ bool read_cf_name(const char **str_arg)
if (str[0] == ':')
{
*str_arg= str + 1;
return 0; /* OK */
return false; /* OK */
}
return 1; /* Error */
return true; /* Error */
}


/*
@brief
Parse a per-Column Family numeric argument. It can be a single number of
specify value for each CF.
@detail
Parse a string value that maybe either
- a single number-with-suffix
- a line in form
cfname:value,cfname2:value2,...
cfname:value,cfname2:value2,...
where cfname='default' also sets the default value (which is used for
the column family named 'default' and also column families for which
the value wasn't specified explicitly.)
@param str String with option value
@param out OUT Parsed option value
Expand Down Expand Up @@ -123,8 +135,9 @@ bool parse_per_cf_numeric(const char *str, Numeric_cf_option *out)
out->name_map[cf_name_str]= num;

/*
However, if there is column family named "DEFAULT" it is take in as
default.
If column family is named "default", its pameter value is also the
default value for column familes which dont have an explicitly specified
value.
*/
if (!strcmp(cf_name_str.c_str(), DEFAULT_CF_NAME))
out->default_val= num;
Expand Down

0 comments on commit f002aea

Please sign in to comment.