Refactor GetMutableOptionsFromStrings

Summary: Add mutable options info into `OptionsTypeInfo` and use it to parse mutable options map. Also support `max_bytes_for_level_multiplier_additional` in option file.

Test Plan: unit test

Reviewers: yhchiang, IslamAbdelRahman, sdong

Reviewed By: sdong

Subscribers: andrewkr, dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D63843
This commit is contained in:
Yi Wu 2016-09-13 21:12:43 -07:00
parent 81747f1be6
commit 8e061f9740
6 changed files with 150 additions and 201 deletions

View File

@ -98,6 +98,7 @@
target_file_size_multiplier=1
source_compaction_factor=1
max_bytes_for_level_multiplier=8
max_bytes_for_level_multiplier_additional=2:3:5
compaction_filter_factory=nullptr
max_write_buffer_number=8
level0_stop_writes_trigger=20

View File

@ -142,6 +142,17 @@ std::string trim(const std::string& str) {
return std::string();
}
bool SerializeIntVector(const std::vector<int>& vec, std::string* value) {
*value = "";
for (size_t i = 0; i < vec.size(); ++i) {
if (i > 0) {
*value += ":";
}
*value += ToString(vec[i]);
}
return true;
}
template <typename T>
bool ParseEnum(const std::unordered_map<std::string, T>& type_map,
const std::string& type, T* value) {
@ -230,6 +241,22 @@ int ParseInt(const std::string& value) {
return num;
}
std::vector<int> ParseVectorInt(const std::string& value) {
std::vector<int> result;
size_t start = 0;
while (start < value.size()) {
size_t end = value.find(':', start);
if (end == std::string::npos) {
result.push_back(ParseInt(value.substr(start)));
break;
} else {
result.push_back(ParseInt(value.substr(start, end - start)));
start = end + 1;
}
}
return result;
}
double ParseDouble(const std::string& value) {
#ifndef CYGWIN
return std::stod(value);
@ -327,6 +354,9 @@ bool ParseOptionHelper(char* opt_address, const OptionType& opt_type,
case OptionType::kInt:
*reinterpret_cast<int*>(opt_address) = ParseInt(value);
break;
case OptionType::kVectorInt:
*reinterpret_cast<std::vector<int>*>(opt_address) = ParseVectorInt(value);
break;
case OptionType::kUInt:
*reinterpret_cast<unsigned int*>(opt_address) = ParseUint32(value);
break;
@ -404,6 +434,9 @@ bool SerializeSingleOptionHelper(const char* opt_address,
case OptionType::kInt:
*value = ToString(*(reinterpret_cast<const int*>(opt_address)));
break;
case OptionType::kVectorInt:
return SerializeIntVector(
*reinterpret_cast<const std::vector<int>*>(opt_address), value);
case OptionType::kUInt:
*value = ToString(*(reinterpret_cast<const unsigned int*>(opt_address)));
break;
@ -539,121 +572,6 @@ bool SerializeSingleOptionHelper(const char* opt_address,
return true;
}
template<typename OptionsType>
bool ParseMemtableOptions(const std::string& name, const std::string& value,
OptionsType* new_options) {
if (name == "write_buffer_size") {
new_options->write_buffer_size = ParseSizeT(value);
} else if (name == "arena_block_size") {
new_options->arena_block_size = ParseSizeT(value);
} else if (name == "memtable_prefix_bloom_bits") {
// deprecated
} else if (name == "memtable_prefix_bloom_size_ratio") {
new_options->memtable_prefix_bloom_size_ratio = ParseDouble(value);
} else if (name == "memtable_prefix_bloom_probes") {
// Deprecated
} else if (name == "memtable_prefix_bloom_huge_page_tlb_size") {
// Deprecated
} else if (name == "memtable_huge_page_size") {
new_options->memtable_huge_page_size = ParseSizeT(value);
} else if (name == "max_successive_merges") {
new_options->max_successive_merges = ParseSizeT(value);
} else if (name == "filter_deletes") {
// Deprecated
} else if (name == "max_write_buffer_number") {
new_options->max_write_buffer_number = ParseInt(value);
} else if (name == "inplace_update_num_locks") {
new_options->inplace_update_num_locks = ParseSizeT(value);
} else {
return false;
}
return true;
}
template<typename OptionsType>
bool ParseCompactionOptions(const std::string& name, const std::string& value,
OptionsType* new_options) {
if (name == "disable_auto_compactions") {
new_options->disable_auto_compactions = ParseBoolean(name, value);
} else if (name == "soft_rate_limit") {
// Deprecated options but still leave it here to avoid older options
// strings can be consumed.
} else if (name == "soft_pending_compaction_bytes_limit") {
new_options->soft_pending_compaction_bytes_limit = ParseUint64(value);
} else if (name == "hard_pending_compaction_bytes_limit") {
new_options->hard_pending_compaction_bytes_limit = ParseUint64(value);
} else if (name == "hard_rate_limit") {
// Deprecated options but still leave it here to avoid older options
// strings can be consumed.
} else if (name == "level0_file_num_compaction_trigger") {
new_options->level0_file_num_compaction_trigger = ParseInt(value);
} else if (name == "level0_slowdown_writes_trigger") {
new_options->level0_slowdown_writes_trigger = ParseInt(value);
} else if (name == "level0_stop_writes_trigger") {
new_options->level0_stop_writes_trigger = ParseInt(value);
} else if (name == "max_grandparent_overlap_factor") {
// Deprecated
} else if (name == "max_compaction_bytes") {
new_options->max_compaction_bytes = ParseUint64(value);
} else if (name == "expanded_compaction_factor") {
// Deprecated
} else if (name == "source_compaction_factor") {
// Deprecated
} else if (name == "target_file_size_base") {
new_options->target_file_size_base = ParseInt(value);
} else if (name == "target_file_size_multiplier") {
new_options->target_file_size_multiplier = ParseInt(value);
} else if (name == "max_bytes_for_level_base") {
new_options->max_bytes_for_level_base = ParseUint64(value);
} else if (name == "max_bytes_for_level_multiplier") {
new_options->max_bytes_for_level_multiplier = ParseInt(value);
} else if (name == "max_bytes_for_level_multiplier_additional") {
new_options->max_bytes_for_level_multiplier_additional.clear();
size_t start = 0;
while (true) {
size_t end = value.find(':', start);
if (end == std::string::npos) {
new_options->max_bytes_for_level_multiplier_additional.push_back(
ParseInt(value.substr(start)));
break;
} else {
new_options->max_bytes_for_level_multiplier_additional.push_back(
ParseInt(value.substr(start, end - start)));
start = end + 1;
}
}
} else if (name == "verify_checksums_in_compaction") {
new_options->verify_checksums_in_compaction = ParseBoolean(name, value);
} else {
return false;
}
return true;
}
template<typename OptionsType>
bool ParseMiscOptions(const std::string& name, const std::string& value,
OptionsType* new_options) {
if (name == "max_sequential_skip_in_iterations") {
new_options->max_sequential_skip_in_iterations = ParseUint64(value);
} else if (name == "paranoid_file_checks") {
new_options->paranoid_file_checks = ParseBoolean(name, value);
} else if (name == "report_bg_io_stats") {
new_options->report_bg_io_stats = ParseBoolean(name, value);
} else if (name == "compression") {
bool is_ok = ParseEnum<CompressionType>(compression_type_string_map, value,
&new_options->compression);
if (!is_ok) {
return false;
}
} else if (name == "min_partial_merge_operands") {
new_options->min_partial_merge_operands = ParseUint32(value);
} else {
return false;
}
return true;
}
Status GetMutableOptionsFromStrings(
const MutableCFOptions& base_options,
const std::unordered_map<std::string, std::string>& options_map,
@ -662,15 +580,22 @@ Status GetMutableOptionsFromStrings(
*new_options = base_options;
for (const auto& o : options_map) {
try {
if (ParseMemtableOptions(o.first, o.second, new_options)) {
} else if (ParseCompactionOptions(o.first, o.second, new_options)) {
} else if (ParseMiscOptions(o.first, o.second, new_options)) {
} else {
return Status::InvalidArgument(
"unsupported dynamic option: " + o.first);
auto iter = cf_options_type_info.find(o.first);
if (iter == cf_options_type_info.end()) {
return Status::InvalidArgument("Unrecognized option: " + o.first);
}
const auto& opt_info = iter->second;
if (!opt_info.is_mutable) {
return Status::InvalidArgument("Option not changeable: " + o.first);
}
bool is_ok = ParseOptionHelper(
reinterpret_cast<char*>(new_options) + opt_info.mutable_offset,
opt_info.type, o.second);
if (!is_ok) {
return Status::InvalidArgument("Error parsing " + o.first);
}
} catch (std::exception& e) {
return Status::InvalidArgument("error parsing " + o.first + ":" +
return Status::InvalidArgument("Error parsing " + o.first + ":" +
std::string(e.what()));
}
}
@ -760,22 +685,7 @@ Status ParseColumnFamilyOption(const std::string& name,
const std::string& value =
input_strings_escaped ? UnescapeOptionString(org_value) : org_value;
try {
if (name == "max_bytes_for_level_multiplier_additional") {
new_options->max_bytes_for_level_multiplier_additional.clear();
size_t start = 0;
while (true) {
size_t end = value.find(':', start);
if (end == std::string::npos) {
new_options->max_bytes_for_level_multiplier_additional.push_back(
ParseInt(value.substr(start)));
break;
} else {
new_options->max_bytes_for_level_multiplier_additional.push_back(
ParseInt(value.substr(start, end - start)));
start = end + 1;
}
}
} else if (name == "block_based_table_factory") {
if (name == "block_based_table_factory") {
// Nested options
BlockBasedTableOptions table_opt, base_table_options;
auto block_based_table_factory = dynamic_cast<BlockBasedTableFactory*>(

View File

@ -74,6 +74,7 @@ ColumnFamilyOptions BuildColumnFamilyOptions(
enum class OptionType {
kBoolean,
kInt,
kVectorInt,
kUInt,
kUInt32T,
kUInt64T,
@ -120,6 +121,8 @@ struct OptionTypeInfo {
int offset;
OptionType type;
OptionVerificationType verification;
bool is_mutable;
int mutable_offset;
};
// A helper function that converts "opt_address" to a std::string
@ -338,164 +341,191 @@ static std::unordered_map<std::string, OptionTypeInfo> cf_options_type_info = {
uint34_t* existing_value_size,
Slice delta_value,
std::string* merged_value);
std::vector<int> max_bytes_for_level_multiplier_additional;
*/
{"report_bg_io_stats",
{offsetof(struct ColumnFamilyOptions, report_bg_io_stats),
OptionType::kBoolean, OptionVerificationType::kNormal}},
OptionType::kBoolean, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, report_bg_io_stats)}},
{"compaction_measure_io_stats",
{offsetof(struct ColumnFamilyOptions, report_bg_io_stats),
OptionType::kBoolean, OptionVerificationType::kDeprecated}},
{0, OptionType::kBoolean, OptionVerificationType::kDeprecated, false}},
{"disable_auto_compactions",
{offsetof(struct ColumnFamilyOptions, disable_auto_compactions),
OptionType::kBoolean, OptionVerificationType::kNormal}},
OptionType::kBoolean, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, disable_auto_compactions)}},
{"filter_deletes",
{0, OptionType::kBoolean, OptionVerificationType::kDeprecated}},
{0, OptionType::kBoolean, OptionVerificationType::kDeprecated, true}},
{"inplace_update_support",
{offsetof(struct ColumnFamilyOptions, inplace_update_support),
OptionType::kBoolean, OptionVerificationType::kNormal}},
OptionType::kBoolean, OptionVerificationType::kNormal, false}},
{"level_compaction_dynamic_level_bytes",
{offsetof(struct ColumnFamilyOptions,
level_compaction_dynamic_level_bytes),
OptionType::kBoolean, OptionVerificationType::kNormal}},
OptionType::kBoolean, OptionVerificationType::kNormal, false}},
{"optimize_filters_for_hits",
{offsetof(struct ColumnFamilyOptions, optimize_filters_for_hits),
OptionType::kBoolean, OptionVerificationType::kNormal}},
OptionType::kBoolean, OptionVerificationType::kNormal, false}},
{"paranoid_file_checks",
{offsetof(struct ColumnFamilyOptions, paranoid_file_checks),
OptionType::kBoolean, OptionVerificationType::kNormal}},
OptionType::kBoolean, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, paranoid_file_checks)}},
{"purge_redundant_kvs_while_flush",
{offsetof(struct ColumnFamilyOptions, purge_redundant_kvs_while_flush),
OptionType::kBoolean, OptionVerificationType::kNormal}},
OptionType::kBoolean, OptionVerificationType::kNormal, false}},
{"verify_checksums_in_compaction",
{offsetof(struct ColumnFamilyOptions, verify_checksums_in_compaction),
OptionType::kBoolean, OptionVerificationType::kNormal}},
OptionType::kBoolean, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, verify_checksums_in_compaction)}},
{"soft_pending_compaction_bytes_limit",
{offsetof(struct ColumnFamilyOptions, soft_pending_compaction_bytes_limit),
OptionType::kUInt64T, OptionVerificationType::kNormal}},
OptionType::kUInt64T, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, soft_pending_compaction_bytes_limit)}},
{"hard_pending_compaction_bytes_limit",
{offsetof(struct ColumnFamilyOptions, hard_pending_compaction_bytes_limit),
OptionType::kUInt64T, OptionVerificationType::kNormal}},
OptionType::kUInt64T, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, hard_pending_compaction_bytes_limit)}},
{"hard_rate_limit",
{offsetof(struct ColumnFamilyOptions, hard_rate_limit),
OptionType::kDouble, OptionVerificationType::kDeprecated}},
{0, OptionType::kDouble, OptionVerificationType::kDeprecated, true}},
{"soft_rate_limit",
{offsetof(struct ColumnFamilyOptions, soft_rate_limit),
OptionType::kDouble, OptionVerificationType::kNormal}},
{0, OptionType::kDouble, OptionVerificationType::kDeprecated, true}},
{"max_compaction_bytes",
{offsetof(struct ColumnFamilyOptions, max_compaction_bytes),
OptionType::kUInt64T, OptionVerificationType::kNormal}},
OptionType::kUInt64T, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, max_compaction_bytes)}},
{"expanded_compaction_factor",
{0, OptionType::kInt, OptionVerificationType::kDeprecated}},
{0, OptionType::kInt, OptionVerificationType::kDeprecated, true}},
{"level0_file_num_compaction_trigger",
{offsetof(struct ColumnFamilyOptions, level0_file_num_compaction_trigger),
OptionType::kInt, OptionVerificationType::kNormal}},
OptionType::kInt, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, level0_file_num_compaction_trigger)}},
{"level0_slowdown_writes_trigger",
{offsetof(struct ColumnFamilyOptions, level0_slowdown_writes_trigger),
OptionType::kInt, OptionVerificationType::kNormal}},
OptionType::kInt, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, level0_slowdown_writes_trigger)}},
{"level0_stop_writes_trigger",
{offsetof(struct ColumnFamilyOptions, level0_stop_writes_trigger),
OptionType::kInt, OptionVerificationType::kNormal}},
{"max_bytes_for_level_multiplier",
{offsetof(struct ColumnFamilyOptions, max_bytes_for_level_multiplier),
OptionType::kInt, OptionVerificationType::kNormal}},
OptionType::kInt, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, level0_stop_writes_trigger)}},
{"max_grandparent_overlap_factor",
{0, OptionType::kInt, OptionVerificationType::kDeprecated}},
{0, OptionType::kInt, OptionVerificationType::kDeprecated, true}},
{"max_mem_compaction_level",
{offsetof(struct ColumnFamilyOptions, max_mem_compaction_level),
OptionType::kInt, OptionVerificationType::kDeprecated}},
{0, OptionType::kInt, OptionVerificationType::kDeprecated, false}},
{"max_write_buffer_number",
{offsetof(struct ColumnFamilyOptions, max_write_buffer_number),
OptionType::kInt, OptionVerificationType::kNormal}},
OptionType::kInt, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, max_write_buffer_number)}},
{"max_write_buffer_number_to_maintain",
{offsetof(struct ColumnFamilyOptions, max_write_buffer_number_to_maintain),
OptionType::kInt, OptionVerificationType::kNormal}},
OptionType::kInt, OptionVerificationType::kNormal, false}},
{"min_write_buffer_number_to_merge",
{offsetof(struct ColumnFamilyOptions, min_write_buffer_number_to_merge),
OptionType::kInt, OptionVerificationType::kNormal}},
OptionType::kInt, OptionVerificationType::kNormal, false}},
{"num_levels",
{offsetof(struct ColumnFamilyOptions, num_levels), OptionType::kInt,
OptionVerificationType::kNormal}},
OptionVerificationType::kNormal, false}},
{"source_compaction_factor",
{0, OptionType::kInt, OptionVerificationType::kDeprecated}},
{0, OptionType::kInt, OptionVerificationType::kDeprecated, true}},
{"target_file_size_multiplier",
{offsetof(struct ColumnFamilyOptions, target_file_size_multiplier),
OptionType::kInt, OptionVerificationType::kNormal}},
OptionType::kInt, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, target_file_size_multiplier)}},
{"arena_block_size",
{offsetof(struct ColumnFamilyOptions, arena_block_size),
OptionType::kSizeT, OptionVerificationType::kNormal}},
OptionType::kSizeT, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, arena_block_size)}},
{"inplace_update_num_locks",
{offsetof(struct ColumnFamilyOptions, inplace_update_num_locks),
OptionType::kSizeT, OptionVerificationType::kNormal}},
OptionType::kSizeT, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, inplace_update_num_locks)}},
{"max_successive_merges",
{offsetof(struct ColumnFamilyOptions, max_successive_merges),
OptionType::kSizeT, OptionVerificationType::kNormal}},
OptionType::kSizeT, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, max_successive_merges)}},
{"memtable_huge_page_size",
{offsetof(struct ColumnFamilyOptions, memtable_huge_page_size),
OptionType::kSizeT, OptionVerificationType::kNormal}},
OptionType::kSizeT, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, memtable_huge_page_size)}},
{"memtable_prefix_bloom_huge_page_tlb_size",
{0, OptionType::kSizeT, OptionVerificationType::kDeprecated}},
{0, OptionType::kSizeT, OptionVerificationType::kDeprecated, true}},
{"write_buffer_size",
{offsetof(struct ColumnFamilyOptions, write_buffer_size),
OptionType::kSizeT, OptionVerificationType::kNormal}},
OptionType::kSizeT, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, write_buffer_size)}},
{"bloom_locality",
{offsetof(struct ColumnFamilyOptions, bloom_locality),
OptionType::kUInt32T, OptionVerificationType::kNormal}},
OptionType::kUInt32T, OptionVerificationType::kNormal, false}},
{"memtable_prefix_bloom_bits",
{0, OptionType::kUInt32T, OptionVerificationType::kDeprecated}},
{0, OptionType::kUInt32T, OptionVerificationType::kDeprecated, true}},
{"memtable_prefix_bloom_size_ratio",
{offsetof(struct ColumnFamilyOptions, memtable_prefix_bloom_size_ratio),
OptionType::kDouble, OptionVerificationType::kNormal}},
OptionType::kDouble, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, memtable_prefix_bloom_size_ratio)}},
{"memtable_prefix_bloom_probes",
{0, OptionType::kUInt32T, OptionVerificationType::kDeprecated}},
{0, OptionType::kUInt32T, OptionVerificationType::kDeprecated, true}},
{"min_partial_merge_operands",
{offsetof(struct ColumnFamilyOptions, min_partial_merge_operands),
OptionType::kUInt32T, OptionVerificationType::kNormal}},
OptionType::kUInt32T, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, min_partial_merge_operands)}},
{"max_bytes_for_level_base",
{offsetof(struct ColumnFamilyOptions, max_bytes_for_level_base),
OptionType::kUInt64T, OptionVerificationType::kNormal}},
OptionType::kUInt64T, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, max_bytes_for_level_base)}},
{"max_bytes_for_level_multiplier",
{offsetof(struct ColumnFamilyOptions, max_bytes_for_level_multiplier),
OptionType::kInt, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, max_bytes_for_level_multiplier)}},
{"max_bytes_for_level_multiplier_additional",
{offsetof(struct ColumnFamilyOptions,
max_bytes_for_level_multiplier_additional),
OptionType::kVectorInt, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions,
max_bytes_for_level_multiplier_additional)}},
{"max_sequential_skip_in_iterations",
{offsetof(struct ColumnFamilyOptions, max_sequential_skip_in_iterations),
OptionType::kUInt64T, OptionVerificationType::kNormal}},
OptionType::kUInt64T, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, max_sequential_skip_in_iterations)}},
{"target_file_size_base",
{offsetof(struct ColumnFamilyOptions, target_file_size_base),
OptionType::kUInt64T, OptionVerificationType::kNormal}},
OptionType::kUInt64T, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, target_file_size_base)}},
{"rate_limit_delay_max_milliseconds",
{offsetof(struct ColumnFamilyOptions, rate_limit_delay_max_milliseconds),
OptionType::kUInt, OptionVerificationType::kDeprecated}},
{0, OptionType::kUInt, OptionVerificationType::kDeprecated, false}},
{"compression",
{offsetof(struct ColumnFamilyOptions, compression),
OptionType::kCompressionType, OptionVerificationType::kNormal}},
OptionType::kCompressionType, OptionVerificationType::kNormal, true,
offsetof(struct MutableCFOptions, compression)}},
{"compression_per_level",
{offsetof(struct ColumnFamilyOptions, compression_per_level),
OptionType::kVectorCompressionType, OptionVerificationType::kNormal}},
OptionType::kVectorCompressionType, OptionVerificationType::kNormal,
false}},
{"bottommost_compression",
{offsetof(struct ColumnFamilyOptions, bottommost_compression),
OptionType::kCompressionType, OptionVerificationType::kNormal}},
OptionType::kCompressionType, OptionVerificationType::kNormal, false}},
{"comparator",
{offsetof(struct ColumnFamilyOptions, comparator), OptionType::kComparator,
OptionVerificationType::kByName}},
OptionVerificationType::kByName, false}},
{"prefix_extractor",
{offsetof(struct ColumnFamilyOptions, prefix_extractor),
OptionType::kSliceTransform, OptionVerificationType::kByNameAllowNull}},
OptionType::kSliceTransform, OptionVerificationType::kByNameAllowNull,
false}},
{"memtable_factory",
{offsetof(struct ColumnFamilyOptions, memtable_factory),
OptionType::kMemTableRepFactory, OptionVerificationType::kByName}},
OptionType::kMemTableRepFactory, OptionVerificationType::kByName, false}},
{"table_factory",
{offsetof(struct ColumnFamilyOptions, table_factory),
OptionType::kTableFactory, OptionVerificationType::kByName}},
OptionType::kTableFactory, OptionVerificationType::kByName, false}},
{"compaction_filter",
{offsetof(struct ColumnFamilyOptions, compaction_filter),
OptionType::kCompactionFilter, OptionVerificationType::kByName}},
OptionType::kCompactionFilter, OptionVerificationType::kByName, false}},
{"compaction_filter_factory",
{offsetof(struct ColumnFamilyOptions, compaction_filter_factory),
OptionType::kCompactionFilterFactory, OptionVerificationType::kByName}},
OptionType::kCompactionFilterFactory, OptionVerificationType::kByName,
false}},
{"merge_operator",
{offsetof(struct ColumnFamilyOptions, merge_operator),
OptionType::kMergeOperator, OptionVerificationType::kByName}},
OptionType::kMergeOperator, OptionVerificationType::kByName, false}},
{"compaction_style",
{offsetof(struct ColumnFamilyOptions, compaction_style),
OptionType::kCompactionStyle, OptionVerificationType::kNormal}}};
OptionType::kCompactionStyle, OptionVerificationType::kNormal, false}}};
static std::unordered_map<std::string, OptionTypeInfo>
block_based_table_type_info = {

View File

@ -518,6 +518,9 @@ bool AreEqualOptions(
case OptionType::kInt:
return (*reinterpret_cast<const int*>(offset1) ==
*reinterpret_cast<const int*>(offset2));
case OptionType::kVectorInt:
return (*reinterpret_cast<const std::vector<int>*>(offset1) ==
*reinterpret_cast<const std::vector<int>*>(offset2));
case OptionType::kUInt:
return (*reinterpret_cast<const unsigned int*>(offset1) ==
*reinterpret_cast<const unsigned int*>(offset2));

View File

@ -170,7 +170,6 @@ TEST_F(OptionsTest, GetOptionsFromMapTest) {
ASSERT_EQ(new_cf_opt.max_bytes_for_level_multiplier_additional[1], 17);
ASSERT_EQ(new_cf_opt.max_bytes_for_level_multiplier_additional[2], 18);
ASSERT_EQ(new_cf_opt.max_compaction_bytes, 21);
ASSERT_EQ(new_cf_opt.soft_rate_limit, 1.1);
ASSERT_EQ(new_cf_opt.hard_pending_compaction_bytes_limit, 211);
ASSERT_EQ(new_cf_opt.arena_block_size, 22U);
ASSERT_EQ(new_cf_opt.disable_auto_compactions, true);

View File

@ -321,6 +321,12 @@ void RandomInitCFOptions(ColumnFamilyOptions* cf_opt, Random* rnd) {
cf_opt->num_levels = rnd->Uniform(100);
cf_opt->target_file_size_multiplier = rnd->Uniform(100);
// vector int options
cf_opt->max_bytes_for_level_multiplier_additional.resize(cf_opt->num_levels);
for (int i = 0; i < cf_opt->num_levels; i++) {
cf_opt->max_bytes_for_level_multiplier_additional[i] = rnd->Uniform(100);
}
// size_t options
cf_opt->arena_block_size = rnd->Uniform(10000);
cf_opt->inplace_update_num_locks = rnd->Uniform(10000);