|
|
@ -10,16 +10,13 @@ |
|
|
|
#include "rocksdb/cache.h" |
|
|
|
#include "rocksdb/cache.h" |
|
|
|
#include "rocksdb/filter_policy.h" |
|
|
|
#include "rocksdb/filter_policy.h" |
|
|
|
#include "rocksdb/options.h" |
|
|
|
#include "rocksdb/options.h" |
|
|
|
#include "rocksdb/memtablerep.h" |
|
|
|
|
|
|
|
#include "rocksdb/rate_limiter.h" |
|
|
|
#include "rocksdb/rate_limiter.h" |
|
|
|
#include "rocksdb/slice_transform.h" |
|
|
|
#include "rocksdb/slice_transform.h" |
|
|
|
#include "rocksdb/table.h" |
|
|
|
#include "rocksdb/table.h" |
|
|
|
#include "rocksdb/utilities/convenience.h" |
|
|
|
#include "rocksdb/utilities/convenience.h" |
|
|
|
#include "table/block_based_table_factory.h" |
|
|
|
#include "table/block_based_table_factory.h" |
|
|
|
#include "table/plain_table_factory.h" |
|
|
|
|
|
|
|
#include "util/logging.h" |
|
|
|
#include "util/logging.h" |
|
|
|
#include "util/options_helper.h" |
|
|
|
#include "util/options_helper.h" |
|
|
|
#include "util/string_util.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace rocksdb { |
|
|
|
namespace rocksdb { |
|
|
|
|
|
|
|
|
|
|
@ -269,7 +266,7 @@ Status GetMutableOptionsFromStrings( |
|
|
|
return Status::InvalidArgument( |
|
|
|
return Status::InvalidArgument( |
|
|
|
"unsupported dynamic option: " + o.first); |
|
|
|
"unsupported dynamic option: " + o.first); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (const std::exception& e) { |
|
|
|
} catch (std::exception& e) { |
|
|
|
return Status::InvalidArgument("error parsing " + o.first + ":" + |
|
|
|
return Status::InvalidArgument("error parsing " + o.first + ":" + |
|
|
|
std::string(e.what())); |
|
|
|
std::string(e.what())); |
|
|
|
} |
|
|
|
} |
|
|
@ -394,27 +391,6 @@ bool ParseColumnFamilyOption(const std::string& name, const std::string& value, |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
new_options->table_factory.reset(NewBlockBasedTableFactory(table_opt)); |
|
|
|
new_options->table_factory.reset(NewBlockBasedTableFactory(table_opt)); |
|
|
|
} else if (name == "plain_table_factory") { |
|
|
|
|
|
|
|
PlainTableOptions table_opt, base_table_options; |
|
|
|
|
|
|
|
auto plain_table_factory = dynamic_cast<PlainTableFactory*>( |
|
|
|
|
|
|
|
new_options->table_factory.get()); |
|
|
|
|
|
|
|
if (plain_table_factory != nullptr) { |
|
|
|
|
|
|
|
base_table_options = plain_table_factory->GetTableOptions(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Status table_opt_s = GetPlainTableOptionsFromString( |
|
|
|
|
|
|
|
base_table_options, value, &table_opt); |
|
|
|
|
|
|
|
if (!table_opt_s.ok()) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
new_options->table_factory.reset(NewPlainTableFactory(table_opt)); |
|
|
|
|
|
|
|
} else if (name == "memtablerep") { |
|
|
|
|
|
|
|
MemTableRepFactory* new_mem_factory; |
|
|
|
|
|
|
|
Status mem_factory_s =
|
|
|
|
|
|
|
|
GetMemTableRepFactoryFromString(value, &new_mem_factory); |
|
|
|
|
|
|
|
if (!mem_factory_s.ok()) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
new_options->memtable_factory.reset(new_mem_factory); |
|
|
|
|
|
|
|
} else if (name == "min_write_buffer_number_to_merge") { |
|
|
|
} else if (name == "min_write_buffer_number_to_merge") { |
|
|
|
new_options->min_write_buffer_number_to_merge = ParseInt(value); |
|
|
|
new_options->min_write_buffer_number_to_merge = ParseInt(value); |
|
|
|
} else if (name == "max_write_buffer_number_to_maintain") { |
|
|
|
} else if (name == "max_write_buffer_number_to_maintain") { |
|
|
@ -505,7 +481,7 @@ bool ParseColumnFamilyOption(const std::string& name, const std::string& value, |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
catch (const std::exception& e) { |
|
|
|
catch (std::exception& e) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -653,7 +629,7 @@ Status GetBlockBasedTableOptionsFromMap( |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return Status::InvalidArgument("Unrecognized option: " + o.first); |
|
|
|
return Status::InvalidArgument("Unrecognized option: " + o.first); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (const std::exception& e) { |
|
|
|
} catch (std::exception& e) { |
|
|
|
return Status::InvalidArgument("error parsing " + o.first + ":" + |
|
|
|
return Status::InvalidArgument("error parsing " + o.first + ":" + |
|
|
|
std::string(e.what())); |
|
|
|
std::string(e.what())); |
|
|
|
} |
|
|
|
} |
|
|
@ -708,7 +684,7 @@ Status GetPlainTableOptionsFromMap( |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return Status::InvalidArgument("Unrecognized option: " + o.first); |
|
|
|
return Status::InvalidArgument("Unrecognized option: " + o.first); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (const std::exception& e) { |
|
|
|
} catch (std::exception& e) { |
|
|
|
return Status::InvalidArgument("error parsing " + o.first + ":" + |
|
|
|
return Status::InvalidArgument("error parsing " + o.first + ":" + |
|
|
|
std::string(e.what())); |
|
|
|
std::string(e.what())); |
|
|
|
} |
|
|
|
} |
|
|
@ -716,75 +692,6 @@ Status GetPlainTableOptionsFromMap( |
|
|
|
return Status::OK(); |
|
|
|
return Status::OK(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Status GetPlainTableOptionsFromString( |
|
|
|
|
|
|
|
const PlainTableOptions& table_options, |
|
|
|
|
|
|
|
const std::string& opts_str, |
|
|
|
|
|
|
|
PlainTableOptions* new_table_options) { |
|
|
|
|
|
|
|
std::unordered_map<std::string, std::string> opts_map; |
|
|
|
|
|
|
|
Status s = StringToMap(opts_str, &opts_map); |
|
|
|
|
|
|
|
if (!s.ok()) { |
|
|
|
|
|
|
|
return s; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return GetPlainTableOptionsFromMap(table_options, opts_map, |
|
|
|
|
|
|
|
new_table_options); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Status GetMemTableRepFactoryFromString( |
|
|
|
|
|
|
|
const std::string& opts_str, |
|
|
|
|
|
|
|
MemTableRepFactory** new_mem_factory) { |
|
|
|
|
|
|
|
std::vector<std::string> opts_list = StringSplit(opts_str, ':'); |
|
|
|
|
|
|
|
size_t len = opts_list.size(); |
|
|
|
|
|
|
|
if (opts_list[0] == "skip_list") { |
|
|
|
|
|
|
|
// Expecting format
|
|
|
|
|
|
|
|
// skip_list:lookahead
|
|
|
|
|
|
|
|
if (2 == len) { |
|
|
|
|
|
|
|
size_t lookahead = ParseSizeT(opts_list[1]); |
|
|
|
|
|
|
|
*new_mem_factory = new SkipListFactory(lookahead); |
|
|
|
|
|
|
|
} else if (1 == len) { |
|
|
|
|
|
|
|
*new_mem_factory = new SkipListFactory(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return Status::InvalidArgument("Can't parse option ", opts_str); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (opts_list[0] == "prefix_hash") { |
|
|
|
|
|
|
|
// Expecting format
|
|
|
|
|
|
|
|
// prfix_hash:hash_bucket_count
|
|
|
|
|
|
|
|
if (2 == len) { |
|
|
|
|
|
|
|
size_t hash_bucket_count = ParseSizeT(opts_list[1]); |
|
|
|
|
|
|
|
*new_mem_factory = NewHashSkipListRepFactory(hash_bucket_count); |
|
|
|
|
|
|
|
} else if (1 == len) { |
|
|
|
|
|
|
|
*new_mem_factory = NewHashSkipListRepFactory(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return Status::InvalidArgument("Can't parse option ", opts_str); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (opts_list[0] == "hash_linkedlist") { |
|
|
|
|
|
|
|
// Expecting format
|
|
|
|
|
|
|
|
// hash_linkedlist:hash_bucket_count
|
|
|
|
|
|
|
|
if (2 == len) { |
|
|
|
|
|
|
|
size_t hash_bucket_count = ParseSizeT(opts_list[1]); |
|
|
|
|
|
|
|
*new_mem_factory = NewHashLinkListRepFactory(hash_bucket_count); |
|
|
|
|
|
|
|
} else if (1 == len) { |
|
|
|
|
|
|
|
*new_mem_factory = NewHashLinkListRepFactory(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return Status::InvalidArgument("Can't parse option ", opts_str); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (opts_list[0] == "vector") { |
|
|
|
|
|
|
|
if (1 == len) { |
|
|
|
|
|
|
|
*new_mem_factory = new VectorRepFactory; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return Status::InvalidArgument("Can't parse option ", opts_str); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (opts_list[0] == "cuckoo") { |
|
|
|
|
|
|
|
return Status::InvalidArgument("cuckoo is not supported for now"); |
|
|
|
|
|
|
|
// TODO(bahuang): cuckoo is not supported for now
|
|
|
|
|
|
|
|
// *new_mem_factory = NewHashCuckooRepFactory(
|
|
|
|
|
|
|
|
// options.write_buffer_size, FLAGS_key_size + FLAGS_value_size));
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return Status::InvalidArgument("Can't parse option " + opts_str); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return Status::OK(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Status GetColumnFamilyOptionsFromMap( |
|
|
|
Status GetColumnFamilyOptionsFromMap( |
|
|
|
const ColumnFamilyOptions& base_options, |
|
|
|
const ColumnFamilyOptions& base_options, |
|
|
|
const std::unordered_map<std::string, std::string>& opts_map, |
|
|
|
const std::unordered_map<std::string, std::string>& opts_map, |
|
|
|