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
main
sdong 9 years ago
parent 3a6643c2fd
commit 6170fec251
  1. 8
      table/block_based_table_factory.cc
  2. 6
      table/plain_table_factory.h
  3. 37
      util/options_helper.cc
  4. 35
      util/options_helper.h
  5. 2
      utilities/memory/memory_test.cc

@ -24,8 +24,8 @@
namespace rocksdb { namespace rocksdb {
BlockBasedTableFactory::BlockBasedTableFactory( BlockBasedTableFactory::BlockBasedTableFactory(
const BlockBasedTableOptions& table_options) const BlockBasedTableOptions& _table_options)
: table_options_(table_options) { : table_options_(_table_options) {
if (table_options_.flush_block_policy_factory == nullptr) { if (table_options_.flush_block_policy_factory == nullptr) {
table_options_.flush_block_policy_factory.reset( table_options_.flush_block_policy_factory.reset(
new FlushBlockBySizePolicyFactory()); new FlushBlockBySizePolicyFactory());
@ -167,8 +167,8 @@ const BlockBasedTableOptions& BlockBasedTableFactory::table_options() const {
} }
TableFactory* NewBlockBasedTableFactory( TableFactory* NewBlockBasedTableFactory(
const BlockBasedTableOptions& table_options) { const BlockBasedTableOptions& _table_options) {
return new BlockBasedTableFactory(table_options); return new BlockBasedTableFactory(_table_options);
} }
const std::string BlockBasedTablePropertyNames::kIndexType = const std::string BlockBasedTablePropertyNames::kIndexType =

@ -142,9 +142,9 @@ class PlainTableFactory : public TableFactory {
// huge_page_tlb_size determines whether to allocate hash indexes from huge // huge_page_tlb_size determines whether to allocate hash indexes from huge
// page TLB and the page size if allocating from there. See comments of // page TLB and the page size if allocating from there. See comments of
// Arena::AllocateAligned() for details. // Arena::AllocateAligned() for details.
explicit PlainTableFactory(const PlainTableOptions& table_options = explicit PlainTableFactory(
PlainTableOptions()) const PlainTableOptions& _table_options = PlainTableOptions())
: table_options_(table_options) {}; : table_options_(_table_options) {}
const char* Name() const override { return "PlainTable"; } const char* Name() const override { return "PlainTable"; }
Status NewTableReader(const TableReaderOptions& table_reader_options, Status NewTableReader(const TableReaderOptions& table_reader_options,

@ -109,7 +109,6 @@ std::string trim(const std::string& str) {
template <typename T> template <typename T>
bool ParseEnum(const std::unordered_map<std::string, T>& type_map, bool ParseEnum(const std::unordered_map<std::string, T>& type_map,
const std::string& type, T* value) { const std::string& type, T* value) {
auto iter = type_map.find(type); auto iter = type_map.find(type);
if (iter != type_map.end()) { if (iter != type_map.end()) {
*value = iter->second; *value = iter->second;
@ -246,8 +245,8 @@ bool ParseVectorCompressionType(
compression_per_level->emplace_back(type); compression_per_level->emplace_back(type);
break; break;
} else { } else {
is_ok = ParseEnum<CompressionType>(compression_type_string_map, is_ok = ParseEnum<CompressionType>(
value.substr(start, end - start), &type); compression_type_string_map, value.substr(start, end - start), &type);
if (!is_ok) { if (!is_ok) {
return false; return false;
} }
@ -336,11 +335,13 @@ bool ParseOptionHelper(char* opt_address, const OptionType& opt_type,
*reinterpret_cast<double*>(opt_address) = ParseDouble(value); *reinterpret_cast<double*>(opt_address) = ParseDouble(value);
break; break;
case OptionType::kCompactionStyle: case OptionType::kCompactionStyle:
return ParseEnum<CompactionStyle>(compaction_style_string_map, return ParseEnum<CompactionStyle>(
value, reinterpret_cast<CompactionStyle*>(opt_address)); compaction_style_string_map, value,
reinterpret_cast<CompactionStyle*>(opt_address));
case OptionType::kCompressionType: case OptionType::kCompressionType:
return ParseEnum<CompressionType>(compression_type_string_map, return ParseEnum<CompressionType>(
value, reinterpret_cast<CompressionType*>(opt_address)); compression_type_string_map, value,
reinterpret_cast<CompressionType*>(opt_address));
case OptionType::kVectorCompressionType: case OptionType::kVectorCompressionType:
return ParseVectorCompressionType( return ParseVectorCompressionType(
value, reinterpret_cast<std::vector<CompressionType>*>(opt_address)); value, reinterpret_cast<std::vector<CompressionType>*>(opt_address));
@ -349,14 +350,16 @@ bool ParseOptionHelper(char* opt_address, const OptionType& opt_type,
value, reinterpret_cast<std::shared_ptr<const SliceTransform>*>( value, reinterpret_cast<std::shared_ptr<const SliceTransform>*>(
opt_address)); opt_address));
case OptionType::kChecksumType: case OptionType::kChecksumType:
return ParseEnum<ChecksumType>(checksum_type_string_map, value, return ParseEnum<ChecksumType>(
checksum_type_string_map, value,
reinterpret_cast<ChecksumType*>(opt_address)); reinterpret_cast<ChecksumType*>(opt_address));
case OptionType::kBlockBasedTableIndexType: case OptionType::kBlockBasedTableIndexType:
return ParseEnum<BlockBasedTableOptions::IndexType>( return ParseEnum<BlockBasedTableOptions::IndexType>(
block_base_table_index_type_string_map, value, block_base_table_index_type_string_map, value,
reinterpret_cast<BlockBasedTableOptions::IndexType*>(opt_address)); reinterpret_cast<BlockBasedTableOptions::IndexType*>(opt_address));
case OptionType::kEncodingType: case OptionType::kEncodingType:
return ParseEnum<EncodingType>(encoding_type_string_map, value, return ParseEnum<EncodingType>(
encoding_type_string_map, value,
reinterpret_cast<EncodingType*>(opt_address)); reinterpret_cast<EncodingType*>(opt_address));
default: default:
return false; return false;
@ -398,10 +401,12 @@ bool SerializeSingleOptionHelper(const char* opt_address,
*(reinterpret_cast<const std::string*>(opt_address))); *(reinterpret_cast<const std::string*>(opt_address)));
break; break;
case OptionType::kCompactionStyle: case OptionType::kCompactionStyle:
return SerializeEnum<CompactionStyle>(compaction_style_string_map, return SerializeEnum<CompactionStyle>(
compaction_style_string_map,
*(reinterpret_cast<const CompactionStyle*>(opt_address)), value); *(reinterpret_cast<const CompactionStyle*>(opt_address)), value);
case OptionType::kCompressionType: case OptionType::kCompressionType:
return SerializeEnum<CompressionType>(compression_type_string_map, return SerializeEnum<CompressionType>(
compression_type_string_map,
*(reinterpret_cast<const CompressionType*>(opt_address)), value); *(reinterpret_cast<const CompressionType*>(opt_address)), value);
case OptionType::kVectorCompressionType: case OptionType::kVectorCompressionType:
return SerializeVectorCompressionType( return SerializeVectorCompressionType(
@ -473,7 +478,8 @@ bool SerializeSingleOptionHelper(const char* opt_address,
break; break;
} }
case OptionType::kChecksumType: case OptionType::kChecksumType:
return SerializeEnum<ChecksumType>(checksum_type_string_map, return SerializeEnum<ChecksumType>(
checksum_type_string_map,
*reinterpret_cast<const ChecksumType*>(opt_address), value); *reinterpret_cast<const ChecksumType*>(opt_address), value);
case OptionType::kBlockBasedTableIndexType: case OptionType::kBlockBasedTableIndexType:
return SerializeEnum<BlockBasedTableOptions::IndexType>( return SerializeEnum<BlockBasedTableOptions::IndexType>(
@ -489,7 +495,8 @@ bool SerializeSingleOptionHelper(const char* opt_address,
break; break;
} }
case OptionType::kEncodingType: case OptionType::kEncodingType:
return SerializeEnum<EncodingType>(encoding_type_string_map, return SerializeEnum<EncodingType>(
encoding_type_string_map,
*reinterpret_cast<const EncodingType*>(opt_address), value); *reinterpret_cast<const EncodingType*>(opt_address), value);
default: default:
return false; return false;
@ -936,8 +943,8 @@ Status GetStringFromTableFactory(std::string* opts_str, const TableFactory* tf,
const auto* bbtf = dynamic_cast<const BlockBasedTableFactory*>(tf); const auto* bbtf = dynamic_cast<const BlockBasedTableFactory*>(tf);
opts_str->clear(); opts_str->clear();
if (bbtf != nullptr) { if (bbtf != nullptr) {
return GetStringFromBlockBasedTableOptions( return GetStringFromBlockBasedTableOptions(opts_str, bbtf->table_options(),
opts_str, bbtf->table_options(), delimiter); delimiter);
} }
return Status::OK(); return Status::OK();

@ -493,20 +493,19 @@ static std::unordered_map<std::string,
{offsetof(struct BlockBasedTableOptions, format_version), {offsetof(struct BlockBasedTableOptions, format_version),
OptionType::kUInt32T, OptionVerificationType::kNormal}}}; OptionType::kUInt32T, OptionVerificationType::kNormal}}};
static std::unordered_map<std::string, static std::unordered_map<std::string, OptionTypeInfo> plain_table_type_info = {
OptionTypeInfo> plain_table_type_info = {
{"user_key_len", {"user_key_len",
{offsetof(struct PlainTableOptions, user_key_len), {offsetof(struct PlainTableOptions, user_key_len), OptionType::kUInt32T,
OptionType::kUInt32T, OptionVerificationType::kNormal}}, OptionVerificationType::kNormal}},
{"bloom_bits_per_key", {"bloom_bits_per_key",
{offsetof(struct PlainTableOptions, bloom_bits_per_key), {offsetof(struct PlainTableOptions, bloom_bits_per_key), OptionType::kInt,
OptionType::kInt, OptionVerificationType::kNormal}}, OptionVerificationType::kNormal}},
{"hash_table_ratio", {"hash_table_ratio",
{offsetof(struct PlainTableOptions, hash_table_ratio), {offsetof(struct PlainTableOptions, hash_table_ratio), OptionType::kDouble,
OptionType::kDouble, OptionVerificationType::kNormal}}, OptionVerificationType::kNormal}},
{"index_sparseness", {"index_sparseness",
{offsetof(struct PlainTableOptions, index_sparseness), {offsetof(struct PlainTableOptions, index_sparseness), OptionType::kSizeT,
OptionType::kSizeT, OptionVerificationType::kNormal}}, OptionVerificationType::kNormal}},
{"huge_page_tlb_size", {"huge_page_tlb_size",
{offsetof(struct PlainTableOptions, huge_page_tlb_size), {offsetof(struct PlainTableOptions, huge_page_tlb_size),
OptionType::kSizeT, OptionVerificationType::kNormal}}, OptionType::kSizeT, OptionVerificationType::kNormal}},
@ -514,8 +513,8 @@ static std::unordered_map<std::string,
{offsetof(struct PlainTableOptions, encoding_type), {offsetof(struct PlainTableOptions, encoding_type),
OptionType::kEncodingType, OptionVerificationType::kByName}}, OptionType::kEncodingType, OptionVerificationType::kByName}},
{"full_scan_mode", {"full_scan_mode",
{offsetof(struct PlainTableOptions, full_scan_mode), {offsetof(struct PlainTableOptions, full_scan_mode), OptionType::kBoolean,
OptionType::kBoolean, OptionVerificationType::kNormal}}, OptionVerificationType::kNormal}},
{"store_index_in_file", {"store_index_in_file",
{offsetof(struct PlainTableOptions, store_index_in_file), {offsetof(struct PlainTableOptions, store_index_in_file),
OptionType::kBoolean, OptionVerificationType::kNormal}}}; OptionType::kBoolean, OptionVerificationType::kNormal}}};
@ -528,20 +527,18 @@ static std::unordered_map<std::string, CompressionType>
{"kBZip2Compression", kBZip2Compression}, {"kBZip2Compression", kBZip2Compression},
{"kLZ4Compression", kLZ4Compression}, {"kLZ4Compression", kLZ4Compression},
{"kLZ4HCCompression", kLZ4HCCompression}, {"kLZ4HCCompression", kLZ4HCCompression},
{"kZSTDNotFinalCompression", kZSTDNotFinalCompression} {"kZSTDNotFinalCompression", kZSTDNotFinalCompression}};
};
static std::unordered_map<std::string, BlockBasedTableOptions::IndexType> 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}, {"kBinarySearch", BlockBasedTableOptions::IndexType::kBinarySearch},
{"kHashSearch", BlockBasedTableOptions::IndexType::kHashSearch}}; {"kHashSearch", BlockBasedTableOptions::IndexType::kHashSearch}};
static std::unordered_map<std::string, EncodingType> static std::unordered_map<std::string, EncodingType> encoding_type_string_map =
encoding_type_string_map = {{"kPlain", kPlain}, {"kPrefix", kPrefix}}; {{"kPlain", kPlain}, {"kPrefix", kPrefix}};
static std::unordered_map<std::string, ChecksumType> static std::unordered_map<std::string, ChecksumType> checksum_type_string_map =
checksum_type_string_map = { {{"kNoChecksum", kNoChecksum}, {"kCRC32c", kCRC32c}, {"kxxHash", kxxHash}};
{"kNoChecksum", kNoChecksum}, {"kCRC32c", kCRC32c}, {"kxxHash", kxxHash}};
static std::unordered_map<std::string, CompactionStyle> static std::unordered_map<std::string, CompactionStyle>
compaction_style_string_map = { compaction_style_string_map = {

@ -46,7 +46,7 @@ class MemoryTest : public testing::Test {
const BlockBasedTableFactory* bbtf = const BlockBasedTableFactory* bbtf =
dynamic_cast<const BlockBasedTableFactory*>(factory); dynamic_cast<const BlockBasedTableFactory*>(factory);
if (bbtf != nullptr) { if (bbtf != nullptr) {
const auto bbt_opts = bbtf->GetTableOptions(); const auto bbt_opts = bbtf->table_options();
cache_set->insert(bbt_opts.block_cache.get()); cache_set->insert(bbt_opts.block_cache.get());
cache_set->insert(bbt_opts.block_cache_compressed.get()); cache_set->insert(bbt_opts.block_cache_compressed.get());
} }

Loading…
Cancel
Save