From b92a19a431b53e150a5e1c3818cf807bccbcc2d1 Mon Sep 17 00:00:00 2001 From: sdong Date: Thu, 5 Jun 2014 15:12:32 -0700 Subject: [PATCH] sst_dump: Set dummy prefix extractor for binary search index in block based table Summary: Now sst_dump fails in block based tables if binary search index is used, as it requires a prefix extractor. Add it. Test Plan: Run it against such a file to make sure it fixes the problem. Reviewers: yhchiang, kailiu Reviewed By: kailiu Subscribers: ljin, igor, dhruba, haobo, leveldb Differential Revision: https://reviews.facebook.net/D18927 --- db/compaction.cc | 1 - tools/sst_dump.cc | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/db/compaction.cc b/db/compaction.cc index e88e822b2..0c758cc39 100644 --- a/db/compaction.cc +++ b/db/compaction.cc @@ -266,5 +266,4 @@ uint64_t Compaction::OutputFilePreallocationSize() { return preallocation_size * 1.1; } - } // namespace rocksdb diff --git a/tools/sst_dump.cc b/tools/sst_dump.cc index 9a144bb0b..8e1ae35a9 100644 --- a/tools/sst_dump.cc +++ b/tools/sst_dump.cc @@ -132,6 +132,16 @@ Status SstFileReader::SetTableOptionsByMagicNumber(uint64_t table_magic_number, if (table_magic_number == kBlockBasedTableMagicNumber) { options_.table_factory = std::make_shared(); fprintf(stdout, "Sst file format: block-based\n"); + auto& props = table_properties->user_collected_properties; + auto pos = props.find(BlockBasedTablePropertyNames::kIndexType); + if (pos != props.end()) { + auto index_type_on_file = static_cast( + DecodeFixed32(pos->second.c_str())); + if (index_type_on_file == + BlockBasedTableOptions::IndexType::kHashSearch) { + options_.prefix_extractor.reset(NewNoopTransform()); + } + } } else if (table_magic_number == kPlainTableMagicNumber) { options_.allow_mmap_reads = true; options_.table_factory = std::make_shared(