Skip to content

Commit

Permalink
sst_dump: Set dummy prefix extractor for binary search index in block…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
siying committed Jun 5, 2014
1 parent 5d87071 commit b92a19a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 0 additions & 1 deletion db/compaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,4 @@ uint64_t Compaction::OutputFilePreallocationSize() {
return preallocation_size * 1.1;
}


} // namespace rocksdb
10 changes: 10 additions & 0 deletions tools/sst_dump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ Status SstFileReader::SetTableOptionsByMagicNumber(uint64_t table_magic_number,
if (table_magic_number == kBlockBasedTableMagicNumber) {
options_.table_factory = std::make_shared<BlockBasedTableFactory>();
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<BlockBasedTableOptions::IndexType>(
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<PlainTableFactory>(
Expand Down

0 comments on commit b92a19a

Please sign in to comment.