Commit 0ecaed87 authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel

refs #5758 add --tsv to ftdump to produce fragmentation data all on one line


git-svn-id: file:///svn/toku/tokudb@50850 c7de825b-a66e-492c-adef-691d508d4ae1
parent 95047c46
...@@ -231,16 +231,21 @@ dump_block_translation(FT h, uint64_t offset) { ...@@ -231,16 +231,21 @@ dump_block_translation(FT h, uint64_t offset) {
} }
static void static void
dump_fragmentation(int UU(f), FT h) { dump_fragmentation(int UU(f), FT h, int tsv) {
int64_t used_space; int64_t used_space;
int64_t total_space; int64_t total_space;
toku_blocktable_internal_fragmentation(h->blocktable, &total_space, &used_space); toku_blocktable_internal_fragmentation(h->blocktable, &total_space, &used_space);
int64_t fragsizes = total_space - used_space; int64_t fragsizes = total_space - used_space;
printf("used_size\t%" PRId64 "\n", used_space); if (tsv) {
printf("total_size\t%" PRId64 "\n", total_space); printf("%" PRId64 "\t%" PRId64 "\t%" PRId64 "\t%.1f\n", used_space, total_space, fragsizes,
printf("fragsizes\t%" PRId64 "\n", fragsizes); 100. * ((double)fragsizes / (double)(total_space)));
printf("fragmentation\t%.1f\n", 100. * ((double)fragsizes / (double)(total_space))); } else {
printf("used_size\t%" PRId64 "\n", used_space);
printf("total_size\t%" PRId64 "\n", total_space);
printf("fragsizes\t%" PRId64 "\n", fragsizes);
printf("fragmentation\t%.1f\n", 100. * ((double)fragsizes / (double)(total_space)));
}
} }
typedef struct { typedef struct {
...@@ -415,7 +420,7 @@ split_fields (char *line, char *fields[], int maxfields) { ...@@ -415,7 +420,7 @@ split_fields (char *line, char *fields[], int maxfields) {
static int static int
usage(const char *arg0) { usage(const char *arg0) {
printf("Usage: %s [--nodata] [--i[nteractive]|--fragmentation|--translation-table|--rootnode] ftfilename\n", arg0); printf("Usage: %s [--nodata] [--i[nteractive]|--fragmentation [--tsv]|--translation-table|--rootnode] ftfilename\n", arg0);
return 1; return 1;
} }
...@@ -461,6 +466,7 @@ main (int argc, const char *const argv[]) { ...@@ -461,6 +466,7 @@ main (int argc, const char *const argv[]) {
int fragmentation = 0; int fragmentation = 0;
int translation_table = 0; int translation_table = 0;
int rootnode = 0; int rootnode = 0;
int tsv = 0;
const char *arg0 = argv[0]; const char *arg0 = argv[0];
argc--; argv++; argc--; argv++;
...@@ -471,6 +477,8 @@ main (int argc, const char *const argv[]) { ...@@ -471,6 +477,8 @@ main (int argc, const char *const argv[]) {
interactive = 1; interactive = 1;
} else if (strcmp(argv[0], "--fragmentation") == 0) { } else if (strcmp(argv[0], "--fragmentation") == 0) {
fragmentation = 1; fragmentation = 1;
} else if (strcmp(argv[0], "--tsv") == 0) {
tsv = 1;
} else if (strcmp(argv[0], "--translation-table") == 0) { } else if (strcmp(argv[0], "--translation-table") == 0) {
translation_table = 1; translation_table = 1;
} else if (strcmp(argv[0], "--rootnode") == 0) { } else if (strcmp(argv[0], "--rootnode") == 0) {
...@@ -533,7 +541,7 @@ main (int argc, const char *const argv[]) { ...@@ -533,7 +541,7 @@ main (int argc, const char *const argv[]) {
offset = getuint64(fields[1]); offset = getuint64(fields[1]);
dump_block_translation(ft, offset); dump_block_translation(ft, offset);
} else if (strcmp(fields[0], "fragmentation") == 0) { } else if (strcmp(fields[0], "fragmentation") == 0) {
dump_fragmentation(f, ft); dump_fragmentation(f, ft, tsv);
} else if (strcmp(fields[0], "nodesizes") == 0) { } else if (strcmp(fields[0], "nodesizes") == 0) {
dump_nodesizes(f, ft); dump_nodesizes(f, ft);
} else if (strcmp(fields[0], "garbage") == 0) { } else if (strcmp(fields[0], "garbage") == 0) {
...@@ -556,7 +564,7 @@ main (int argc, const char *const argv[]) { ...@@ -556,7 +564,7 @@ main (int argc, const char *const argv[]) {
} else if (rootnode) { } else if (rootnode) {
dump_node(f, ft->h->root_blocknum, ft); dump_node(f, ft->h->root_blocknum, ft);
} else if (fragmentation) { } else if (fragmentation) {
dump_fragmentation(f, ft); dump_fragmentation(f, ft, tsv);
} else if (translation_table) { } else if (translation_table) {
toku_dump_translation_table_pretty(stdout, ft->blocktable); toku_dump_translation_table_pretty(stdout, ft->blocktable);
} else { } else {
......
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