c28097538a
Summary: Without this option, manifest_dump does not print binary keys for files in a human-readable way. Test Plan: ./manifest_dump --hex=1 --verbose=0 --file=/data/users/zshao/fdb_comparison/leveldb/fbobj.apprequest-0_0_original/MANIFEST-000002 manifest_file_number 589 next_file_number 590 last_sequence 2311567 log_number 543 prev_log_number 0 --- level 0 --- version# 0 --- 532:1300357['0000455BABE20000' @ 2183973 : 1 .. 'FFFCA5D7ADE20000' @ 2184254 : 1] 536:1308170['000198C75CE30000' @ 2203313 : 1 .. 'FFFCF94A79E30000' @ 2206463 : 1] 542:1321644['0002931AA5E50000' @ 2267055 : 1 .. 'FFF77B31C5E50000' @ 2270754 : 1] 544:1286390['000410A309E60000' @ 2278592 : 1 .. 'FFFE470A73E60000' @ 2289221 : 1] 538:1298778['0006BCF4D8E30000' @ 2217050 : 1 .. 'FFFD77DAF7E30000' @ 2220489 : 1] 540:1282353['00090D5356E40000' @ 2231156 : 1 .. 'FFFFF4625CE40000' @ 2231969 : 1] --- level 1 --- version# 0 --- 510:2112325['000007F9C2D40000' @ 1782099 : 1 .. '146F5B67B8D80000' @ 1905458 : 1] 511:2121742['146F8A3023D60000' @ 1824388 : 1 .. '28BC8FBB9CD40000' @ 1777993 : 1] 512:801631['28BCD396F1DE0000' @ 2080191 : 1 .. '3082DBE9ADDB0000' @ 1989927 : 1] Reviewers: dhruba, sheki, emayanke Reviewed By: dhruba CC: leveldb Differential Revision: https://reviews.facebook.net/D7425
76 lines
2.1 KiB
C++
76 lines
2.1 KiB
C++
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
|
|
#include "db/version_set.h"
|
|
|
|
#include <algorithm>
|
|
#include <stdio.h>
|
|
#include "db/filename.h"
|
|
#include "db/log_reader.h"
|
|
#include "db/log_writer.h"
|
|
#include "db/memtable.h"
|
|
#include "db/table_cache.h"
|
|
#include "leveldb/env.h"
|
|
#include "leveldb/table_builder.h"
|
|
#include "table/merger.h"
|
|
#include "table/two_level_iterator.h"
|
|
#include "util/coding.h"
|
|
#include "util/logging.h"
|
|
|
|
static int verbose = 0;
|
|
static int hex = 0;
|
|
|
|
using namespace leveldb;
|
|
|
|
//
|
|
// Takes a manifest file and dumps out all metedata
|
|
//
|
|
int main(int argc, char** argv) {
|
|
|
|
// parse command line options
|
|
size_t n;
|
|
char junk;
|
|
int foundfile = 0;
|
|
std::string manifestfile;
|
|
for (int i = 1; i < argc; i++) {
|
|
std::string param(argv[i]);
|
|
if ((n = param.find("--file=")) != std::string::npos) {
|
|
manifestfile = param.substr(strlen("--file="));
|
|
foundfile = 1;
|
|
} else if (sscanf(argv[i], "--verbose=%ld%c", &n, &junk) == 1 &&
|
|
(n == 0 || n == 1)) {
|
|
verbose = n;
|
|
} else if (sscanf(argv[i], "--hex=%ld%c", &n, &junk) == 1 &&
|
|
(n == 0 || n == 1)) {
|
|
hex = n;
|
|
}
|
|
}
|
|
if (!foundfile) {
|
|
fprintf(stderr, "%s [--verbose=0|1] [--file=pathname of manifest file\n",
|
|
argv[0]);
|
|
abort();
|
|
}
|
|
|
|
if (verbose) {
|
|
printf("Processing Manifest file %s\n", manifestfile.c_str());
|
|
}
|
|
|
|
Options options;
|
|
std::string file(manifestfile);
|
|
std::string dbname("dummy");
|
|
TableCache* tc = new TableCache(dbname, &options, 10);
|
|
const InternalKeyComparator* cmp = new InternalKeyComparator(options.comparator);
|
|
|
|
VersionSet* versions = new VersionSet(dbname, &options,
|
|
tc, cmp);
|
|
Status s = versions->DumpManifest(options, file, verbose, hex);
|
|
if (!s.ok()) {
|
|
printf("Error in processing file %s %s\n", manifestfile.c_str(),
|
|
s.ToString().c_str());
|
|
}
|
|
if (verbose) {
|
|
printf("Processing Manifest file %s done\n", manifestfile.c_str());
|
|
}
|
|
}
|