Commit e4b54630 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Make the dumper print more (maybe all stuff)

git-svn-id: file:///svn/tokudb@1803 c7de825b-a66e-492c-adef-691d508d4ae1
parent 3c39874f
......@@ -165,5 +165,10 @@ clean:
randdb4: LOADLIBES=-ldb
randbrt: brt.o fifo.o cachetable.o memory.o brt-serialize.o
# After doing (cd ../src/tests;make test_log5.recover), run these. The files should have no differences.
testdump: brtdump
./brtdump ../src/tests/dir.test_log5.c.tdb.recover/foo.db > dump.r && ./brtdump ../src/tests/dir.test_log5.c.tdb/foo.db > dump.o && diff dump.o dump.r
TAGS: ../*/*.c ../*/*.h
etags ../*/*.c ../*/*.h
/* Tell me the diff between two brt files. */
#include <assert.h>
#include <ctype.h>
#include <fcntl.h>
#include "key.h"
......@@ -26,13 +27,89 @@ void dump_header (int f, struct brt_header **header) {
*header = h;
}
void print_item (bytevec val, ITEMLEN len) {
printf("\"");
ITEMLEN i;
for (i=0; i<len; i++) {
char ch = ((char*)val)[i];
if (isprint(ch) && ch!='\\' && ch!='"') {
printf("%c", ch);
} else {
printf("\\%03o", ch);
}
}
printf("\"");
}
void dump_node (int f, DISKOFF off, struct brt_header *h) {
BRTNODE n;
int r = toku_deserialize_brtnode_from (f, off, &n, h->flags, h->nodesize,
toku_default_compare_fun, toku_default_compare_fun,
(DB*)0, (FILENUM){0});
assert(r==0);
printf("brtnode\n");
printf(" nodesize =%u\n", n->nodesize);
printf(" flags =%u\n", n->flags);
printf(" thisnodename=%lld\n", n->thisnodename);
printf(" disk_lsn =%lld\n", n->disk_lsn.lsn);
printf(" log_lsn =%lld\n", n->log_lsn.lsn);
printf(" height =%d\n", n->height);
printf(" rand4fp =%08x\n", n->rand4fingerprint);
printf(" localfp =%08x\n", n->local_fingerprint);
if (n->height>0) {
printf(" n_children=%d\n", n->u.n.n_children);
printf(" total_childkeylens=%u\n", n->u.n.totalchildkeylens);
printf(" n_bytes_in_buffers=%u\n", n->u.n.n_bytes_in_buffers);
int i;
printf(" subfingerprints={");
for (i=0; i<n->u.n.n_children; i++) {
if (i>0) printf(" ");
printf("%08x", BRTNODE_CHILD_SUBTREE_FINGERPRINTS(n, i));
}
printf("}\n");
printf(" pivots:\n");
for (i=0; i<n->u.n.n_children-1; i++) {
struct kv_pair *piv = n->u.n.childkeys[i];
printf(" pivot %d:", i);
print_item(kv_pair_key_const(piv), kv_pair_keylen(piv));
assert(n->flags==0); // if not zero, we must print the other part of the pivot.
printf("\n");
}
printf(" children:\n");
for (i=0; i<n->u.n.n_children; i++) {
printf(" child %d: %lld\n", i, BRTNODE_CHILD_DISKOFF(n, i));
printf(" buffer contains %d bytes (%d items)\n", n->u.n.n_bytes_in_buffer[i], toku_fifo_n_entries(n->u.n.buffers[i]));
FIFO_ITERATE(n->u.n.buffers[i], key, keylen, data, datalen, typ,
({
printf(" TYPE=");
switch ((enum brt_cmd_type)typ) {
case BRT_NONE: printf("NONE"); goto ok;
case BRT_INSERT: printf("INSERT"); goto ok;
case BRT_DELETE: printf("DELETE"); goto ok;
case BRT_DELETE_BOTH: printf("DELETE_BOTH"); goto ok;
}
printf("HUH?");
ok:
printf(" ");
print_item(key, keylen);
if (datalen>0) {
printf(" ");
print_item(data, datalen);
}
})
);
}
} else {
printf(" n_bytes_in_buffer=%d\n", n->u.l.n_bytes_in_buffer);
printf(" items_in_buffer =%d\n", toku_pma_n_entries(n->u.l.buffer));
PMA_ITERATE_IDX(n->u.l.buffer, idx, key, keylen, data, datalen,
({
print_item(key, keylen);
printf(" ");
print_item(data, datalen);
printf("\n");
}));
}
}
int main (int argc, const char *argv[]) {
......@@ -41,6 +118,9 @@ int main (int argc, const char *argv[]) {
int f = open(n, O_RDONLY); assert(f>=0);
struct brt_header *h;
dump_header(f, &h);
dump_node(f, 1<<20, h);
DISKOFF off;
for (off=h->nodesize; off<h->unused_memory; off+=h->nodesize) {
dump_node(f, off, h);
}
return 0;
}
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