YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense alongwiththisprogram;ifnot,writetotheFreeSoftware
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
#include <my_global.h>
/* This C++ files header file */ #include"./rdb_cf_options.h"
// Skip over any spaces in the input string. 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])) ++(*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) {
DBUG_ASSERT(pos != nullptr);
DBUG_ASSERT(key != nullptr);
// Loop through the characters in the string until we see a '='. 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) { // NO_LINT_DEBUG
sql_print_warning("No column family found (options: %s)", input.c_str()); returnfalse;
}
// 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) {
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] != '{') { // NO_LINT_DEBUG
sql_print_warning("Invalid cf options, '{' expected (options: %s)",
input.c_str()); returnfalse;
}
// Skip the open curly brace and any spaces.
++(*pos);
skip_spaces(input, pos);
// Set up our brace_count, the begin position and current end position.
size_t brace_count = 1; const size_t beg_pos = *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 returntrue;
}
break;
case'{': // If this is an open curly brace increment the count.
++brace_count; break;
default: break;
}
// Move to the next character.
++(*pos);
}
// We never found the correct number of closing curly braces. // Generate an error. // NO_LINT_DEBUG
sql_print_warning("Mismatched cf options, '}' expected (options: %s)",
input.c_str()); returnfalse;
}
// We should now have a column family name. if (!find_column_family(input, pos, cf)) returnfalse;
// If we are at the end of the input then we generate an error. if (*pos == input.size()) { // NO_LINT_DEBUG
sql_print_warning("Invalid cf options, '=' expected (options: %s)",
input.c_str()); returnfalse;
}
// Skip equal sign and any spaces after it
++(*pos);
skip_spaces(input, pos);
// Find the options for this column family. This should be in the format // {<options>} where <options> may contain embedded pairs of curly braces. if (!find_options(input, pos, opt_str)) returnfalse;
// Skip any trailing spaces after the option string.
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] != ';') { // NO_LINT_DEBUG
sql_print_warning("Invalid cf options, ';' expected (options: %s)",
input.c_str()); returnfalse;
}
// Loop through the characters of the string until we reach the end.
size_t pos = 0;
while (pos < cf_options.size()) { // Attempt to find <cf>={<opt_str>}. if (!find_cf_options_pair(cf_options, &pos, &cf, &opt_str)) { returnfalse;
}
// Generate an error if we have already seen this column family. if (option_map->find(cf) != option_map->end()) { // NO_LINT_DEBUG
sql_print_warning( "Duplicate entry for %s in override options (options: %s)",
cf.c_str(), cf_options.c_str()); returnfalse;
}
// Generate an error if the <opt_str> is not valid according to RocksDB. if (!rocksdb::GetColumnFamilyOptionsFromString(options, opt_str, &options)
.ok()) { // NO_LINT_DEBUG
sql_print_warning( "Invalid cf config for %s in override options (options: %s)",
cf.c_str(), cf_options.c_str()); returnfalse;
}
// If everything is good, add this cf/opt_str pair to the map.
(*option_map)[cf] = opt_str;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.