Commit 92070341 authored by Barry Perlman's avatar Barry Perlman Committed by Yoni Fogel

Addresses #2197 refs[t:2197] brtdump: Provide cachefile for brt header.


git-svn-id: file:///svn/toku/tokudb@15989 c7de825b-a66e-492c-adef-691d508d4ae1
parent 5ee41e8c
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
static int dump_data = 1; static int dump_data = 1;
static CACHETABLE ct;
static void static void
print_item (bytevec val, ITEMLEN len) { print_item (bytevec val, ITEMLEN len) {
printf("\""); printf("\"");
...@@ -24,10 +27,11 @@ print_item (bytevec val, ITEMLEN len) { ...@@ -24,10 +27,11 @@ print_item (bytevec val, ITEMLEN len) {
} }
static void static void
dump_header (int f, struct brt_header **header) { dump_header (int f, struct brt_header **header, CACHEFILE cf) {
struct brt_header *h; struct brt_header *h;
int r; int r;
r = toku_deserialize_brtheader_from (f, &h); assert(r==0); r = toku_deserialize_brtheader_from (f, &h); assert(r==0);
h->cf = cf;
printf("brtheader:\n"); printf("brtheader:\n");
printf(" layout_version=%d\n", h->layout_version); printf(" layout_version=%d\n", h->layout_version);
printf(" layout_version_original=%d\n", h->layout_version_original); printf(" layout_version_original=%d\n", h->layout_version_original);
...@@ -296,7 +300,14 @@ main (int argc, const char *argv[]) { ...@@ -296,7 +300,14 @@ main (int argc, const char *argv[]) {
const char *n = argv[0]; const char *n = argv[0];
int f = open(n, O_RDONLY + O_BINARY); assert(f>=0); int f = open(n, O_RDONLY + O_BINARY); assert(f>=0);
struct brt_header *h; struct brt_header *h;
dump_header(f, &h); // create a cachefile for the header
int r = toku_create_cachetable(&ct, 1<<25, (LSN){0}, 0);
assert(r == 0);
CACHEFILE cf;
FILENUM fn;
r = toku_cachetable_openfd_with_filenum (&cf, ct, f, n, FALSE, fn, FALSE);
assert(r==0);
dump_header(f, &h, cf);
if (interactive) { if (interactive) {
while (1) { while (1) {
printf("brtdump>"); fflush(stdout); printf("brtdump>"); fflush(stdout);
...@@ -314,7 +325,7 @@ main (int argc, const char *argv[]) { ...@@ -314,7 +325,7 @@ main (int argc, const char *argv[]) {
interactive_help(); interactive_help();
} else if (strcmp(fields[0], "header") == 0) { } else if (strcmp(fields[0], "header") == 0) {
toku_brtheader_free(h); toku_brtheader_free(h);
dump_header(f, &h); dump_header(f, &h, cf);
} else if (strcmp(fields[0], "node") == 0 && nfields == 2) { } else if (strcmp(fields[0], "node") == 0 && nfields == 2) {
BLOCKNUM off = make_blocknum(getuint64(fields[1])); BLOCKNUM off = make_blocknum(getuint64(fields[1]));
dump_node(f, off, h); dump_node(f, off, h);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment