Add parsing of missing DB options

Summary: There are a few options in struct DBOptions that aren't handled by options_helper.cc. Add those missing options so they can be used by GetDBOptionsFromString() and friends.

Test Plan: Updated options_test.cc, reran all tests.

Reviewers: sdong, yhchiang

Reviewed By: yhchiang

Subscribers: dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D54603
main
Omar Sandoval 9 years ago
parent f8e90e8753
commit deb08b8226
  1. 24
      util/options_helper.cc
  2. 52
      util/options_helper.h
  3. 9
      util/options_parser.cc
  4. 20
      util/options_test.cc

@ -361,6 +361,18 @@ bool ParseOptionHelper(char* opt_address, const OptionType& opt_type,
return ParseEnum<EncodingType>( return ParseEnum<EncodingType>(
encoding_type_string_map, value, encoding_type_string_map, value,
reinterpret_cast<EncodingType*>(opt_address)); reinterpret_cast<EncodingType*>(opt_address));
case OptionType::kWALRecoveryMode:
return ParseEnum<WALRecoveryMode>(
wal_recovery_mode_string_map, value,
reinterpret_cast<WALRecoveryMode*>(opt_address));
case OptionType::kAccessHint:
return ParseEnum<DBOptions::AccessHint>(
access_hint_string_map, value,
reinterpret_cast<DBOptions::AccessHint*>(opt_address));
case OptionType::kInfoLogLevel:
return ParseEnum<InfoLogLevel>(
info_log_level_string_map, value,
reinterpret_cast<InfoLogLevel*>(opt_address));
default: default:
return false; return false;
} }
@ -498,6 +510,18 @@ bool SerializeSingleOptionHelper(const char* opt_address,
return SerializeEnum<EncodingType>( return SerializeEnum<EncodingType>(
encoding_type_string_map, encoding_type_string_map,
*reinterpret_cast<const EncodingType*>(opt_address), value); *reinterpret_cast<const EncodingType*>(opt_address), value);
case OptionType::kWALRecoveryMode:
return SerializeEnum<WALRecoveryMode>(
wal_recovery_mode_string_map,
*reinterpret_cast<const WALRecoveryMode*>(opt_address), value);
case OptionType::kAccessHint:
return SerializeEnum<DBOptions::AccessHint>(
access_hint_string_map,
*reinterpret_cast<const DBOptions::AccessHint*>(opt_address), value);
case OptionType::kInfoLogLevel:
return SerializeEnum<InfoLogLevel>(
info_log_level_string_map,
*reinterpret_cast<const InfoLogLevel*>(opt_address), value);
default: default:
return false; return false;
} }

@ -93,6 +93,9 @@ enum class OptionType {
kFlushBlockPolicyFactory, kFlushBlockPolicyFactory,
kChecksumType, kChecksumType,
kEncodingType, kEncodingType,
kWALRecoveryMode,
kAccessHint,
kInfoLogLevel,
kUnknown kUnknown
}; };
@ -143,10 +146,7 @@ Status GetColumnFamilyOptionsFromMapInternal(
static std::unordered_map<std::string, OptionTypeInfo> db_options_type_info = { static std::unordered_map<std::string, OptionTypeInfo> db_options_type_info = {
/* /*
// not yet supported // not yet supported
AccessHint access_hint_on_compaction_start;
Env* env; Env* env;
InfoLogLevel info_log_level;
WALRecoveryMode wal_recovery_mode;
std::shared_ptr<Cache> row_cache; std::shared_ptr<Cache> row_cache;
std::shared_ptr<DeleteScheduler> delete_scheduler; std::shared_ptr<DeleteScheduler> delete_scheduler;
std::shared_ptr<Logger> info_log; std::shared_ptr<Logger> info_log;
@ -289,6 +289,30 @@ static std::unordered_map<std::string, OptionTypeInfo> db_options_type_info = {
OptionVerificationType::kNormal}}, OptionVerificationType::kNormal}},
{"stats_dump_period_sec", {"stats_dump_period_sec",
{offsetof(struct DBOptions, stats_dump_period_sec), OptionType::kUInt, {offsetof(struct DBOptions, stats_dump_period_sec), OptionType::kUInt,
OptionVerificationType::kNormal}},
{"fail_if_options_file_error",
{offsetof(struct DBOptions, fail_if_options_file_error),
OptionType::kBoolean, OptionVerificationType::kNormal}},
{"allow_concurrent_memtable_write",
{offsetof(struct DBOptions, allow_concurrent_memtable_write),
OptionType::kBoolean, OptionVerificationType::kNormal}},
{"wal_recovery_mode",
{offsetof(struct DBOptions, wal_recovery_mode),
OptionType::kWALRecoveryMode, OptionVerificationType::kNormal}},
{"enable_write_thread_adaptive_yield",
{offsetof(struct DBOptions, enable_write_thread_adaptive_yield),
OptionType::kBoolean, OptionVerificationType::kNormal}},
{"write_thread_slow_yield_usec",
{offsetof(struct DBOptions, write_thread_slow_yield_usec),
OptionType::kUInt64T, OptionVerificationType::kNormal}},
{"write_thread_max_yield_usec",
{offsetof(struct DBOptions, write_thread_max_yield_usec),
OptionType::kUInt64T, OptionVerificationType::kNormal}},
{"access_hint_on_compaction_start",
{offsetof(struct DBOptions, access_hint_on_compaction_start),
OptionType::kAccessHint, OptionVerificationType::kNormal}},
{"info_log_level",
{offsetof(struct DBOptions, info_log_level), OptionType::kInfoLogLevel,
OptionVerificationType::kNormal}}}; OptionVerificationType::kNormal}}};
static std::unordered_map<std::string, OptionTypeInfo> cf_options_type_info = { static std::unordered_map<std::string, OptionTypeInfo> cf_options_type_info = {
@ -558,6 +582,28 @@ static std::unordered_map<std::string, CompactionStyle>
{"kCompactionStyleFIFO", kCompactionStyleFIFO}, {"kCompactionStyleFIFO", kCompactionStyleFIFO},
{"kCompactionStyleNone", kCompactionStyleNone}}; {"kCompactionStyleNone", kCompactionStyleNone}};
static std::unordered_map<std::string,
WALRecoveryMode> wal_recovery_mode_string_map = {
{"kTolerateCorruptedTailRecords",
WALRecoveryMode::kTolerateCorruptedTailRecords},
{"kAbsoluteConsistency", WALRecoveryMode::kAbsoluteConsistency},
{"kPointInTimeRecovery", WALRecoveryMode::kPointInTimeRecovery},
{"kSkipAnyCorruptedRecords", WALRecoveryMode::kSkipAnyCorruptedRecords}};
static std::unordered_map<std::string, DBOptions::AccessHint>
access_hint_string_map = {{"NONE", DBOptions::AccessHint::NONE},
{"NORMAL", DBOptions::AccessHint::NORMAL},
{"SEQUENTIAL", DBOptions::AccessHint::SEQUENTIAL},
{"WILLNEED", DBOptions::AccessHint::WILLNEED}};
static std::unordered_map<std::string, InfoLogLevel> info_log_level_string_map =
{{"DEBUG_LEVEL", InfoLogLevel::DEBUG_LEVEL},
{"INFO_LEVEL", InfoLogLevel::INFO_LEVEL},
{"WARN_LEVEL", InfoLogLevel::WARN_LEVEL},
{"ERROR_LEVEL", InfoLogLevel::ERROR_LEVEL},
{"FATAL_LEVEL", InfoLogLevel::FATAL_LEVEL},
{"HEADER_LEVEL", InfoLogLevel::HEADER_LEVEL}};
} // namespace rocksdb } // namespace rocksdb
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE

@ -557,6 +557,15 @@ bool AreEqualOptions(
*reinterpret_cast<const BlockBasedTableOptions::IndexType*>( *reinterpret_cast<const BlockBasedTableOptions::IndexType*>(
offset1) == offset1) ==
*reinterpret_cast<const BlockBasedTableOptions::IndexType*>(offset2)); *reinterpret_cast<const BlockBasedTableOptions::IndexType*>(offset2));
case OptionType::kWALRecoveryMode:
return (*reinterpret_cast<const WALRecoveryMode*>(offset1) ==
*reinterpret_cast<const WALRecoveryMode*>(offset2));
case OptionType::kAccessHint:
return (*reinterpret_cast<const DBOptions::AccessHint*>(offset1) ==
*reinterpret_cast<const DBOptions::AccessHint*>(offset2));
case OptionType::kInfoLogLevel:
return (*reinterpret_cast<const InfoLogLevel*>(offset1) ==
*reinterpret_cast<const InfoLogLevel*>(offset2));
default: default:
if (type_info.verification == OptionVerificationType::kByName || if (type_info.verification == OptionVerificationType::kByName ||
type_info.verification == OptionVerificationType::kByNameAllowNull) { type_info.verification == OptionVerificationType::kByNameAllowNull) {

@ -1653,16 +1653,6 @@ TEST_F(OptionsParserTest, DBOptionsAllFieldsSettable) {
options = new (options_ptr) DBOptions(); options = new (options_ptr) DBOptions();
FillWithSpecialChar(options_ptr, sizeof(DBOptions), kDBOptionsBlacklist); FillWithSpecialChar(options_ptr, sizeof(DBOptions), kDBOptionsBlacklist);
// Following options are not settable through GetDBOptionsFromString():
options->fail_if_options_file_error = false;
options->allow_concurrent_memtable_write = false;
options->wal_recovery_mode = WALRecoveryMode::kPointInTimeRecovery;
options->enable_write_thread_adaptive_yield = true;
options->write_thread_slow_yield_usec = true;
options->write_thread_max_yield_usec = 1000u;
options->access_hint_on_compaction_start = DBOptions::AccessHint::NONE;
options->info_log_level = InfoLogLevel::DEBUG_LEVEL;
char* new_options_ptr = new char[sizeof(DBOptions)]; char* new_options_ptr = new char[sizeof(DBOptions)];
DBOptions* new_options = new (new_options_ptr) DBOptions(); DBOptions* new_options = new (new_options_ptr) DBOptions();
FillWithSpecialChar(new_options_ptr, sizeof(DBOptions), kDBOptionsBlacklist); FillWithSpecialChar(new_options_ptr, sizeof(DBOptions), kDBOptionsBlacklist);
@ -1714,7 +1704,15 @@ TEST_F(OptionsParserTest, DBOptionsAllFieldsSettable) {
"allow_mmap_reads=false;" "allow_mmap_reads=false;"
"max_log_file_size=4607;" "max_log_file_size=4607;"
"random_access_max_buffer_size=1048576;" "random_access_max_buffer_size=1048576;"
"advise_random_on_open=true;", "advise_random_on_open=true;"
"fail_if_options_file_error=false;"
"allow_concurrent_memtable_write=true;"
"wal_recovery_mode=kPointInTimeRecovery;"
"enable_write_thread_adaptive_yield=true;"
"write_thread_slow_yield_usec=5;"
"write_thread_max_yield_usec=1000;"
"access_hint_on_compaction_start=NONE;"
"info_log_level=DEBUG_LEVEL;",
new_options)); new_options));
ASSERT_EQ(unset_bytes_base, NumUnsetBytes(new_options_ptr, sizeof(DBOptions), ASSERT_EQ(unset_bytes_base, NumUnsetBytes(new_options_ptr, sizeof(DBOptions),

Loading…
Cancel
Save