mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-27 11:43:49 +00:00
127ee2e677
Summary: ldb uses --output_hex so make manifest_dump do the same thing. Test Plan: [zshao@dev485 ~/git/rocksdb] ./manifest_dump --output_hex --file=/data/users/zshao/test_leveldb/MANIFEST-000034 manifest_file_number 42 next_file_number 43 last_sequence 2311567 log_number 36 prev_log_number 0 --- level 0 --- version# 0 --- --- level 1 --- version# 0 --- --- level 2 --- version# 0 --- --- level 3 --- version# 0 --- 5:27788699['0000027F4FBE0000' @ 1 : 1 .. '11CE749602C90000' @ 160642 : 1] 7:27785313['11CE773DA7E00000' @ 160643 : 1 .. '23A4C63EC55D0000' @ 321094 : 1] 9:27784288['23A4D581FCD30000' @ 321095 : 1 .. '3576291D12D00000' @ 481428 : 1] 38:64378271['35762BF0E0CE0000' @ 481429 : 1 .. '5E987E0604700000' @ 852910 : 1] 39:64379046['5E987EB0BDD50000' @ 852911 : 1 .. '87C954330E840000' @ 1224603 : 1] 40:10169201['87C95507E49C0000' @ 1224604 : 1 .. '8E48DC0933B70000' @ 1283317 : 1] 21:27798825['8E48DFB0D7CE0000' @ 1283318 : 1 .. 'A00675F8AD7E0000' @ 1443826 : 1] 23:27793751['A006777536E30000' @ 1443827 : 1 .. 'B1D1787FE8670000' @ 1604553 : 1] 25:27801659['B1D179289BB30000' @ 1604554 : 1 .. 'C396D3A69DCE0000' @ 1765012 : 1] 27:27792661['C396DA1E03B10000' @ 1765013 : 1 .. 'D55C9974FCC10000' @ 1925513 : 1] 29:27789095['D55C9B47CBC00000' @ 1925514 : 1 .. 'E71F67D11CCC0000' @ 2085789 : 1] 31:27793145['E71F7A667E740000' @ 2085790 : 1 .. 'F8D4712EF3D90000' @ 2246454 : 1] 41:11246031['F8D4715916A70000' @ 2246455 : 1 .. 'FFFFFCAE97DF0000' @ 2311567 : 1] --- level 4 --- version# 0 --- --- level 5 --- version# 0 --- --- level 6 --- version# 0 --- Reviewers: dhruba, sheki, emayanke Reviewed By: dhruba CC: leveldb Differential Revision: https://reviews.facebook.net/D7575
80 lines
2.2 KiB
C++
80 lines
2.2 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 output_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 (param == "--output_hex") {
|
|
output_hex = n;
|
|
} else {
|
|
fprintf(stderr, "Unknown or badly-formatted option: %s\n",
|
|
argv[i]);
|
|
abort();
|
|
}
|
|
}
|
|
if (!foundfile) {
|
|
fprintf(stderr,
|
|
"%s [--verbose=0|1] [--output_hex] [--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, output_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());
|
|
}
|
|
}
|