summaryrefslogtreecommitdiff
path: root/storage/rocksdb/rdb_cf_options.cc
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2017-02-06 17:39:08 +0000
committerSergei Petrunia <psergey@askmonty.org>2017-02-06 17:39:08 +0000
commit7468ccfadf27a0c5f87c8909ee8514bdd52dc4a7 (patch)
treeb77bc71584e1fe8d727b04a1577dd612da7b9fdd /storage/rocksdb/rdb_cf_options.cc
parentcfb59f3196aac1b41cdda79952031dcc64042914 (diff)
downloadmariadb-git-7468ccfadf27a0c5f87c8909ee8514bdd52dc4a7.tar.gz
Copy of
commit d1bb19b8f751875472211312c8e810143a7ba4b6 Author: Manuel Ung <mung@fb.com> Date: Fri Feb 3 11:50:34 2017 -0800 Add cardinality stats to information schema Summary: This adds cardinality stats to the INFORMATION_SCHEMA.ROCKSDB_INDEX_FILE_MAP table. This is the only missing user collected properties from SST files that we don't expose, which is useful for debugging cardinality bugs. Reviewed By: hermanlee Differential Revision: D4509156 fbshipit-source-id: 2d3918a
Diffstat (limited to 'storage/rocksdb/rdb_cf_options.cc')
-rw-r--r--storage/rocksdb/rdb_cf_options.cc166
1 files changed, 68 insertions, 98 deletions
diff --git a/storage/rocksdb/rdb_cf_options.cc b/storage/rocksdb/rdb_cf_options.cc
index bd4d78d0796..97dc16fe4e6 100644
--- a/storage/rocksdb/rdb_cf_options.cc
+++ b/storage/rocksdb/rdb_cf_options.cc
@@ -15,7 +15,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifdef USE_PRAGMA_IMPLEMENTATION
-#pragma implementation // gcc: Class implementation
+#pragma implementation // gcc: Class implementation
#endif
/* This C++ files header file */
@@ -41,24 +41,23 @@ Rdb_pk_comparator Rdb_cf_options::s_pk_comparator;
Rdb_rev_comparator Rdb_cf_options::s_rev_pk_comparator;
bool Rdb_cf_options::init(
- const rocksdb::BlockBasedTableOptions& table_options,
- std::shared_ptr<rocksdb::TablePropertiesCollectorFactory> prop_coll_factory,
- const char* const default_cf_options,
- const char* const override_cf_options)
-{
+ const rocksdb::BlockBasedTableOptions &table_options,
+ std::shared_ptr<rocksdb::TablePropertiesCollectorFactory> prop_coll_factory,
+ const char *const default_cf_options,
+ const char *const override_cf_options) {
DBUG_ASSERT(default_cf_options != nullptr);
DBUG_ASSERT(override_cf_options != nullptr);
m_default_cf_opts.comparator = &s_pk_comparator;
m_default_cf_opts.compaction_filter_factory.reset(
- new Rdb_compact_filter_factory);
+ new Rdb_compact_filter_factory);
m_default_cf_opts.table_factory.reset(
- rocksdb::NewBlockBasedTableFactory(table_options));
+ rocksdb::NewBlockBasedTableFactory(table_options));
if (prop_coll_factory) {
m_default_cf_opts.table_properties_collector_factories.push_back(
- prop_coll_factory);
+ prop_coll_factory);
}
if (!set_default(std::string(default_cf_options)) ||
@@ -70,34 +69,27 @@ bool Rdb_cf_options::init(
}
void Rdb_cf_options::get(const std::string &cf_name,
- rocksdb::ColumnFamilyOptions* const opts)
-{
+ rocksdb::ColumnFamilyOptions *const opts) {
DBUG_ASSERT(opts != nullptr);
// set defaults
- rocksdb::GetColumnFamilyOptionsFromString(*opts,
- m_default_config,
- opts);
+ rocksdb::GetColumnFamilyOptionsFromString(*opts, m_default_config, opts);
// set per-cf config if we have one
Name_to_config_t::iterator it = m_name_map.find(cf_name);
if (it != m_name_map.end()) {
- rocksdb::GetColumnFamilyOptionsFromString(*opts,
- it->second,
- opts);
+ rocksdb::GetColumnFamilyOptionsFromString(*opts, it->second, opts);
}
}
-bool Rdb_cf_options::set_default(const std::string &default_config)
-{
+bool Rdb_cf_options::set_default(const std::string &default_config) {
rocksdb::ColumnFamilyOptions options;
if (!default_config.empty() &&
- !rocksdb::GetColumnFamilyOptionsFromString(options,
- default_config,
- &options).ok()) {
- fprintf(stderr,
- "Invalid default column family config: %s\n",
+ !rocksdb::GetColumnFamilyOptionsFromString(options, default_config,
+ &options)
+ .ok()) {
+ fprintf(stderr, "Invalid default column family config: %s\n",
default_config.c_str());
return false;
}
@@ -107,8 +99,7 @@ bool Rdb_cf_options::set_default(const std::string &default_config)
}
// Skip over any spaces in the input string.
-void Rdb_cf_options::skip_spaces(const std::string& input, size_t* const pos)
-{
+void Rdb_cf_options::skip_spaces(const std::string &input, size_t *const pos) {
DBUG_ASSERT(pos != nullptr);
while (*pos < input.size() && isspace(input[*pos]))
@@ -118,10 +109,9 @@ void Rdb_cf_options::skip_spaces(const std::string& input, size_t* const pos)
// Find a valid column family name. Note that all characters except a
// semicolon are valid (should this change?) and all spaces are trimmed from
// the beginning and end but are not removed between other characters.
-bool Rdb_cf_options::find_column_family(const std::string& input,
- size_t* const pos,
- std::string* const key)
-{
+bool Rdb_cf_options::find_column_family(const std::string &input,
+ size_t *const pos,
+ std::string *const key) {
DBUG_ASSERT(pos != nullptr);
DBUG_ASSERT(key != nullptr);
@@ -129,15 +119,13 @@ bool Rdb_cf_options::find_column_family(const std::string& input,
size_t end_pos = *pos - 1;
// Loop through the characters in the string until we see a '='.
- for ( ; *pos < input.size() && input[*pos] != '='; ++(*pos))
- {
+ for (; *pos < input.size() && input[*pos] != '='; ++(*pos)) {
// If this is not a space, move the end position to the current position.
if (input[*pos] != ' ')
end_pos = *pos;
}
- if (end_pos == beg_pos - 1)
- {
+ if (end_pos == beg_pos - 1) {
// NO_LINT_DEBUG
sql_print_warning("No column family found (options: %s)", input.c_str());
return false;
@@ -150,18 +138,16 @@ bool Rdb_cf_options::find_column_family(const std::string& input,
// Find a valid options portion. Everything is deemed valid within the options
// portion until we hit as many close curly braces as we have seen open curly
// braces.
-bool Rdb_cf_options::find_options(const std::string& input, size_t* const pos,
- std::string* const options)
-{
+bool Rdb_cf_options::find_options(const std::string &input, size_t *const pos,
+ std::string *const options) {
DBUG_ASSERT(pos != nullptr);
DBUG_ASSERT(options != nullptr);
// Make sure we have an open curly brace at the current position.
- if (*pos < input.size() && input[*pos] != '{')
- {
+ if (*pos < input.size() && input[*pos] != '{') {
// NO_LINT_DEBUG
sql_print_warning("Invalid cf options, '{' expected (options: %s)",
- input.c_str());
+ input.c_str());
return false;
}
@@ -175,29 +161,26 @@ bool Rdb_cf_options::find_options(const std::string& input, size_t* const pos,
// Loop through the characters in the string until we find the appropriate
// number of closing curly braces.
- while (*pos < input.size())
- {
- switch (input[*pos])
- {
- case '}':
- // If this is a closing curly brace and we bring the count down to zero
- // we can exit the loop with a valid options string.
- if (--brace_count == 0)
- {
- *options = input.substr(beg_pos, *pos - beg_pos);
- ++(*pos); // Move past the last closing curly brace
- return true;
- }
-
- break;
-
- case '{':
- // If this is an open curly brace increment the count.
- ++brace_count;
- break;
-
- default:
- break;
+ while (*pos < input.size()) {
+ switch (input[*pos]) {
+ case '}':
+ // If this is a closing curly brace and we bring the count down to zero
+ // we can exit the loop with a valid options string.
+ if (--brace_count == 0) {
+ *options = input.substr(beg_pos, *pos - beg_pos);
+ ++(*pos); // Move past the last closing curly brace
+ return true;
+ }
+
+ break;
+
+ case '{':
+ // If this is an open curly brace increment the count.
+ ++brace_count;
+ break;
+
+ default:
+ break;
}
// Move to the next character.
@@ -208,15 +191,14 @@ bool Rdb_cf_options::find_options(const std::string& input, size_t* const pos,
// Generate an error.
// NO_LINT_DEBUG
sql_print_warning("Mismatched cf options, '}' expected (options: %s)",
- input.c_str());
+ input.c_str());
return false;
}
-bool Rdb_cf_options::find_cf_options_pair(const std::string& input,
- size_t* const pos,
- std::string* const cf,
- std::string* const opt_str)
-{
+bool Rdb_cf_options::find_cf_options_pair(const std::string &input,
+ size_t *const pos,
+ std::string *const cf,
+ std::string *const opt_str) {
DBUG_ASSERT(pos != nullptr);
DBUG_ASSERT(cf != nullptr);
DBUG_ASSERT(opt_str != nullptr);
@@ -229,11 +211,10 @@ bool Rdb_cf_options::find_cf_options_pair(const std::string& input,
return false;
// If we are at the end of the input then we generate an error.
- if (*pos == input.size())
- {
+ if (*pos == input.size()) {
// NO_LINT_DEBUG
sql_print_warning("Invalid cf options, '=' expected (options: %s)",
- input.c_str());
+ input.c_str());
return false;
}
@@ -250,13 +231,11 @@ bool Rdb_cf_options::find_cf_options_pair(const std::string& input,
skip_spaces(input, pos);
// We should either be at the end of the input string or at a semicolon.
- if (*pos < input.size())
- {
- if (input[*pos] != ';')
- {
+ if (*pos < input.size()) {
+ if (input[*pos] != ';') {
// NO_LINT_DEBUG
sql_print_warning("Invalid cf options, ';' expected (options: %s)",
- input.c_str());
+ input.c_str());
return false;
}
@@ -266,8 +245,7 @@ bool Rdb_cf_options::find_cf_options_pair(const std::string& input,
return true;
}
-bool Rdb_cf_options::set_override(const std::string &override_config)
-{
+bool Rdb_cf_options::set_override(const std::string &override_config) {
// TODO(???): support updates?
std::string cf;
@@ -277,15 +255,13 @@ bool Rdb_cf_options::set_override(const std::string &override_config)
// Loop through the characters of the string until we reach the end.
size_t pos = 0;
- while (pos < override_config.size())
- {
+ while (pos < override_config.size()) {
// Attempt to find <cf>={<opt_str>}.
if (!find_cf_options_pair(override_config, &pos, &cf, &opt_str))
return false;
// Generate an error if we have already seen this column family.
- if (configs.find(cf) != configs.end())
- {
+ if (configs.find(cf) != configs.end()) {
// NO_LINT_DEBUG
sql_print_warning(
"Duplicate entry for %s in override options (options: %s)",
@@ -294,9 +270,8 @@ bool Rdb_cf_options::set_override(const std::string &override_config)
}
// Generate an error if the <opt_str> is not valid according to RocksDB.
- if (!rocksdb::GetColumnFamilyOptionsFromString(
- options, opt_str, &options).ok())
- {
+ if (!rocksdb::GetColumnFamilyOptionsFromString(options, opt_str, &options)
+ .ok()) {
// NO_LINT_DEBUG
sql_print_warning(
"Invalid cf config for %s in override options (options: %s)",
@@ -314,29 +289,24 @@ bool Rdb_cf_options::set_override(const std::string &override_config)
return true;
}
-const rocksdb::Comparator* Rdb_cf_options::get_cf_comparator(
- const std::string& cf_name)
-{
- if (Rdb_cf_manager::is_cf_name_reverse(cf_name.c_str()))
- {
+const rocksdb::Comparator *
+Rdb_cf_options::get_cf_comparator(const std::string &cf_name) {
+ if (Rdb_cf_manager::is_cf_name_reverse(cf_name.c_str())) {
return &s_rev_pk_comparator;
- }
- else
- {
+ } else {
return &s_pk_comparator;
}
}
void Rdb_cf_options::get_cf_options(const std::string &cf_name,
- rocksdb::ColumnFamilyOptions* const opts)
-{
+ rocksdb::ColumnFamilyOptions *const opts) {
DBUG_ASSERT(opts != nullptr);
*opts = m_default_cf_opts;
get(cf_name, opts);
// Set the comparator according to 'rev:'
- opts->comparator= get_cf_comparator(cf_name);
+ opts->comparator = get_cf_comparator(cf_name);
}
-} // namespace myrocks
+} // namespace myrocks