summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorsdong <siying.d@fb.com>2015-11-17 16:41:54 -0800
committersdong <siying.d@fb.com>2015-11-17 16:52:54 -0800
commit6170fec2515948fdce4b8ca3b0aaaec1378f79a9 (patch)
tree3e601eb93e98fb5163101d3bf272d582d639e7d2 /util
parent3a6643c2fd16b0078066f50c723a4cc9deed0ad7 (diff)
Fix build broken by previous commit of "option helper refactor"
Summary: The commit of option helper refactor broken the build: (1) a git merge problem (2) some uncaught compiler warning Fix it. Test Plan: Make sure "make all" passes Reviewers: anthony, IslamAbdelRahman, rven, kradhakrishnan, yhchiang Reviewed By: yhchiang Subscribers: leveldb, dhruba Differential Revision: https://reviews.facebook.net/D50943
Diffstat (limited to 'util')
-rw-r--r--util/options_helper.cc59
-rw-r--r--util/options_helper.h79
2 files changed, 71 insertions, 67 deletions
diff --git a/util/options_helper.cc b/util/options_helper.cc
index 48d137f75..26b4c08ef 100644
--- a/util/options_helper.cc
+++ b/util/options_helper.cc
@@ -106,10 +106,9 @@ std::string trim(const std::string& str) {
return std::string();
}
-template<typename T>
-bool ParseEnum(const std::unordered_map<std::string,T>& type_map,
+template <typename T>
+bool ParseEnum(const std::unordered_map<std::string, T>& type_map,
const std::string& type, T* value) {
-
auto iter = type_map.find(type);
if (iter != type_map.end()) {
*value = iter->second;
@@ -118,8 +117,8 @@ bool ParseEnum(const std::unordered_map<std::string,T>& type_map,
return false;
}
-template<typename T>
-bool SerializeEnum(const std::unordered_map<std::string,T>& type_map,
+template <typename T>
+bool SerializeEnum(const std::unordered_map<std::string, T>& type_map,
const T& type, std::string* value) {
for (const auto& pair : type_map) {
if (pair.second == type) {
@@ -140,7 +139,7 @@ bool SerializeVectorCompressionType(const std::vector<CompressionType>& types,
}
std::string string_type;
result = SerializeEnum<CompressionType>(compression_type_string_map,
- types[i], &string_type);
+ types[i], &string_type);
if (result == false) {
return result;
}
@@ -238,16 +237,16 @@ bool ParseVectorCompressionType(
bool is_ok;
CompressionType type;
if (end == std::string::npos) {
- is_ok = ParseEnum<CompressionType>(compression_type_string_map,
- value.substr(start), &type);
+ is_ok = ParseEnum<CompressionType>(compression_type_string_map,
+ value.substr(start), &type);
if (!is_ok) {
return false;
}
compression_per_level->emplace_back(type);
break;
} else {
- is_ok = ParseEnum<CompressionType>(compression_type_string_map,
- value.substr(start, end - start), &type);
+ is_ok = ParseEnum<CompressionType>(
+ compression_type_string_map, value.substr(start, end - start), &type);
if (!is_ok) {
return false;
}
@@ -336,11 +335,13 @@ bool ParseOptionHelper(char* opt_address, const OptionType& opt_type,
*reinterpret_cast<double*>(opt_address) = ParseDouble(value);
break;
case OptionType::kCompactionStyle:
- return ParseEnum<CompactionStyle>(compaction_style_string_map,
- value, reinterpret_cast<CompactionStyle*>(opt_address));
+ return ParseEnum<CompactionStyle>(
+ compaction_style_string_map, value,
+ reinterpret_cast<CompactionStyle*>(opt_address));
case OptionType::kCompressionType:
- return ParseEnum<CompressionType>(compression_type_string_map,
- value, reinterpret_cast<CompressionType*>(opt_address));
+ return ParseEnum<CompressionType>(
+ compression_type_string_map, value,
+ reinterpret_cast<CompressionType*>(opt_address));
case OptionType::kVectorCompressionType:
return ParseVectorCompressionType(
value, reinterpret_cast<std::vector<CompressionType>*>(opt_address));
@@ -349,15 +350,17 @@ bool ParseOptionHelper(char* opt_address, const OptionType& opt_type,
value, reinterpret_cast<std::shared_ptr<const SliceTransform>*>(
opt_address));
case OptionType::kChecksumType:
- return ParseEnum<ChecksumType>(checksum_type_string_map, value,
- reinterpret_cast<ChecksumType*>(opt_address));
+ return ParseEnum<ChecksumType>(
+ checksum_type_string_map, value,
+ reinterpret_cast<ChecksumType*>(opt_address));
case OptionType::kBlockBasedTableIndexType:
return ParseEnum<BlockBasedTableOptions::IndexType>(
- block_base_table_index_type_string_map, value,
- reinterpret_cast<BlockBasedTableOptions::IndexType*>(opt_address));
+ block_base_table_index_type_string_map, value,
+ reinterpret_cast<BlockBasedTableOptions::IndexType*>(opt_address));
case OptionType::kEncodingType:
- return ParseEnum<EncodingType>(encoding_type_string_map, value,
- reinterpret_cast<EncodingType*>(opt_address));
+ return ParseEnum<EncodingType>(
+ encoding_type_string_map, value,
+ reinterpret_cast<EncodingType*>(opt_address));
default:
return false;
}
@@ -398,10 +401,12 @@ bool SerializeSingleOptionHelper(const char* opt_address,
*(reinterpret_cast<const std::string*>(opt_address)));
break;
case OptionType::kCompactionStyle:
- return SerializeEnum<CompactionStyle>(compaction_style_string_map,
+ return SerializeEnum<CompactionStyle>(
+ compaction_style_string_map,
*(reinterpret_cast<const CompactionStyle*>(opt_address)), value);
case OptionType::kCompressionType:
- return SerializeEnum<CompressionType>(compression_type_string_map,
+ return SerializeEnum<CompressionType>(
+ compression_type_string_map,
*(reinterpret_cast<const CompressionType*>(opt_address)), value);
case OptionType::kVectorCompressionType:
return SerializeVectorCompressionType(
@@ -473,7 +478,8 @@ bool SerializeSingleOptionHelper(const char* opt_address,
break;
}
case OptionType::kChecksumType:
- return SerializeEnum<ChecksumType>(checksum_type_string_map,
+ return SerializeEnum<ChecksumType>(
+ checksum_type_string_map,
*reinterpret_cast<const ChecksumType*>(opt_address), value);
case OptionType::kBlockBasedTableIndexType:
return SerializeEnum<BlockBasedTableOptions::IndexType>(
@@ -489,7 +495,8 @@ bool SerializeSingleOptionHelper(const char* opt_address,
break;
}
case OptionType::kEncodingType:
- return SerializeEnum<EncodingType>(encoding_type_string_map,
+ return SerializeEnum<EncodingType>(
+ encoding_type_string_map,
*reinterpret_cast<const EncodingType*>(opt_address), value);
default:
return false;
@@ -936,8 +943,8 @@ Status GetStringFromTableFactory(std::string* opts_str, const TableFactory* tf,
const auto* bbtf = dynamic_cast<const BlockBasedTableFactory*>(tf);
opts_str->clear();
if (bbtf != nullptr) {
- return GetStringFromBlockBasedTableOptions(
- opts_str, bbtf->table_options(), delimiter);
+ return GetStringFromBlockBasedTableOptions(opts_str, bbtf->table_options(),
+ delimiter);
}
return Status::OK();
diff --git a/util/options_helper.h b/util/options_helper.h
index c9b154680..373ffc6be 100644
--- a/util/options_helper.h
+++ b/util/options_helper.h
@@ -493,55 +493,52 @@ static std::unordered_map<std::string,
{offsetof(struct BlockBasedTableOptions, format_version),
OptionType::kUInt32T, OptionVerificationType::kNormal}}};
-static std::unordered_map<std::string,
- OptionTypeInfo> plain_table_type_info = {
- {"user_key_len",
- {offsetof(struct PlainTableOptions, user_key_len),
- OptionType::kUInt32T, OptionVerificationType::kNormal}},
- {"bloom_bits_per_key",
- {offsetof(struct PlainTableOptions, bloom_bits_per_key),
- OptionType::kInt, OptionVerificationType::kNormal}},
- {"hash_table_ratio",
- {offsetof(struct PlainTableOptions, hash_table_ratio),
- OptionType::kDouble, OptionVerificationType::kNormal}},
- {"index_sparseness",
- {offsetof(struct PlainTableOptions, index_sparseness),
- OptionType::kSizeT, OptionVerificationType::kNormal}},
- {"huge_page_tlb_size",
- {offsetof(struct PlainTableOptions, huge_page_tlb_size),
- OptionType::kSizeT, OptionVerificationType::kNormal}},
- {"encoding_type",
- {offsetof(struct PlainTableOptions, encoding_type),
- OptionType::kEncodingType, OptionVerificationType::kByName}},
- {"full_scan_mode",
- {offsetof(struct PlainTableOptions, full_scan_mode),
- OptionType::kBoolean, OptionVerificationType::kNormal}},
- {"store_index_in_file",
- {offsetof(struct PlainTableOptions, store_index_in_file),
- OptionType::kBoolean, OptionVerificationType::kNormal}}};
+static std::unordered_map<std::string, OptionTypeInfo> plain_table_type_info = {
+ {"user_key_len",
+ {offsetof(struct PlainTableOptions, user_key_len), OptionType::kUInt32T,
+ OptionVerificationType::kNormal}},
+ {"bloom_bits_per_key",
+ {offsetof(struct PlainTableOptions, bloom_bits_per_key), OptionType::kInt,
+ OptionVerificationType::kNormal}},
+ {"hash_table_ratio",
+ {offsetof(struct PlainTableOptions, hash_table_ratio), OptionType::kDouble,
+ OptionVerificationType::kNormal}},
+ {"index_sparseness",
+ {offsetof(struct PlainTableOptions, index_sparseness), OptionType::kSizeT,
+ OptionVerificationType::kNormal}},
+ {"huge_page_tlb_size",
+ {offsetof(struct PlainTableOptions, huge_page_tlb_size),
+ OptionType::kSizeT, OptionVerificationType::kNormal}},
+ {"encoding_type",
+ {offsetof(struct PlainTableOptions, encoding_type),
+ OptionType::kEncodingType, OptionVerificationType::kByName}},
+ {"full_scan_mode",
+ {offsetof(struct PlainTableOptions, full_scan_mode), OptionType::kBoolean,
+ OptionVerificationType::kNormal}},
+ {"store_index_in_file",
+ {offsetof(struct PlainTableOptions, store_index_in_file),
+ OptionType::kBoolean, OptionVerificationType::kNormal}}};
-static std::unordered_map<std::string, CompressionType>
+static std::unordered_map<std::string, CompressionType>
compression_type_string_map = {
- {"kNoCompression", kNoCompression},
- {"kSnappyCompression", kSnappyCompression},
- {"kZlibCompression", kZlibCompression},
- {"kBZip2Compression", kBZip2Compression},
- {"kLZ4Compression", kLZ4Compression},
- {"kLZ4HCCompression", kLZ4HCCompression},
- {"kZSTDNotFinalCompression", kZSTDNotFinalCompression}
-};
+ {"kNoCompression", kNoCompression},
+ {"kSnappyCompression", kSnappyCompression},
+ {"kZlibCompression", kZlibCompression},
+ {"kBZip2Compression", kBZip2Compression},
+ {"kLZ4Compression", kLZ4Compression},
+ {"kLZ4HCCompression", kLZ4HCCompression},
+ {"kZSTDNotFinalCompression", kZSTDNotFinalCompression}};
static std::unordered_map<std::string, BlockBasedTableOptions::IndexType>
- block_base_table_index_type_string_map = {
+ block_base_table_index_type_string_map = {
{"kBinarySearch", BlockBasedTableOptions::IndexType::kBinarySearch},
{"kHashSearch", BlockBasedTableOptions::IndexType::kHashSearch}};
-static std::unordered_map<std::string, EncodingType>
- encoding_type_string_map = {{"kPlain", kPlain}, {"kPrefix", kPrefix}};
+static std::unordered_map<std::string, EncodingType> encoding_type_string_map =
+ {{"kPlain", kPlain}, {"kPrefix", kPrefix}};
-static std::unordered_map<std::string, ChecksumType>
- checksum_type_string_map = {
- {"kNoChecksum", kNoChecksum}, {"kCRC32c", kCRC32c}, {"kxxHash", kxxHash}};
+static std::unordered_map<std::string, ChecksumType> checksum_type_string_map =
+ {{"kNoChecksum", kNoChecksum}, {"kCRC32c", kCRC32c}, {"kxxHash", kxxHash}};
static std::unordered_map<std::string, CompactionStyle>
compaction_style_string_map = {