Skip to content

Commit

Permalink
sst_dump support cuckoo table (facebook#12098)
Browse files Browse the repository at this point in the history
Summary:
facebook#11446

Support Cuckoo Table format in sst_dump.

Pull Request resolved: facebook#12098

Reviewed By: jowlyzhang

Differential Revision: D51594094

Pulled By: ajkr

fbshipit-source-id: ba9092818bc3cc0f207b000391aa21d564570df2
  • Loading branch information
raffertyyu authored and facebook-github-bot committed Nov 30, 2023
1 parent d68f45e commit a777945
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion table/sst_file_dumper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ extern const uint64_t kBlockBasedTableMagicNumber;
extern const uint64_t kLegacyBlockBasedTableMagicNumber;
extern const uint64_t kPlainTableMagicNumber;
extern const uint64_t kLegacyPlainTableMagicNumber;
extern const uint64_t kCuckooTableMagicNumber;

const char* testFileName = "test_file_name";

Expand Down Expand Up @@ -123,9 +124,15 @@ Status SstFileDumper::GetTableReader(const std::string& file_path) {

if (s.ok()) {
if (magic_number == kPlainTableMagicNumber ||
magic_number == kLegacyPlainTableMagicNumber) {
magic_number == kLegacyPlainTableMagicNumber ||
magic_number == kCuckooTableMagicNumber) {
soptions_.use_mmap_reads = true;

if (magic_number == kCuckooTableMagicNumber) {
fopts = soptions_;
fopts.temperature = file_temp_;
}

fs->NewRandomAccessFile(file_path, fopts, &file, nullptr);
file_.reset(new RandomAccessFileReader(std::move(file), file_path));
}
Expand Down Expand Up @@ -426,6 +433,13 @@ Status SstFileDumper::SetTableOptionsByMagicNumber(
if (!silent_) {
fprintf(stdout, "Sst file format: plain table\n");
}
} else if (table_magic_number == kCuckooTableMagicNumber) {
ioptions_.allow_mmap_reads = true;

options_.table_factory.reset(NewCuckooTableFactory());
if (!silent_) {
fprintf(stdout, "Sst file format: cuckoo table\n");
}
} else {
char error_msg_buffer[80];
snprintf(error_msg_buffer, sizeof(error_msg_buffer) - 1,
Expand Down
2 changes: 1 addition & 1 deletion table/sst_file_dumper.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class SstFileDumper {
std::unique_ptr<TableReader> table_reader_;
std::unique_ptr<RandomAccessFileReader> file_;

const ImmutableOptions ioptions_;
ImmutableOptions ioptions_;
const MutableCFOptions moptions_;
ReadOptions read_options_;
InternalKeyComparator internal_comparator_;
Expand Down

0 comments on commit a777945

Please sign in to comment.