diff --git a/newbrt/log-internal.h b/newbrt/log-internal.h index 5dfae09b1a7..8552f8c253d 100644 --- a/newbrt/log-internal.h +++ b/newbrt/log-internal.h @@ -40,6 +40,10 @@ struct tokutxn { int tokulogger_finish (TOKULOGGER logger, struct wbuf *wbuf); +static inline int toku_logsizeof_u_int8_t (u_int32_t v __attribute__((__unused__))) { + return 1; +} + static inline int toku_logsizeof_u_int32_t (u_int32_t v __attribute__((__unused__))) { return 4; } diff --git a/newbrt/log.c b/newbrt/log.c index 512595f6914..b060c6b5f9a 100644 --- a/newbrt/log.c +++ b/newbrt/log.c @@ -512,6 +512,19 @@ int toku_logprint_TXNID (FILE *outf, FILE *inf, const char *fieldname, u_int32_t fprintf(outf, " %s=%lld", fieldname, v); return 0; } + +int toku_logprint_u_int8_t (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len) { + u_int8_t v; + int r = toku_fread_u_int8_t(inf, &v, crc, len); + if (r!=0) return r; + fprintf(outf, " %s=%d", fieldname, v); + if (v=='\'') fprintf(outf, "('\'')"); + else if (isprint(v)) fprintf(outf, "('%c')", v); + else {}/*nothing*/ + return 0; + +} + int toku_logprint_u_int32_t (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len) { u_int32_t v; int r = toku_fread_u_int32_t(inf, &v, crc, len); diff --git a/newbrt/log.h b/newbrt/log.h index dd231c035c0..42871051eb9 100644 --- a/newbrt/log.h +++ b/newbrt/log.h @@ -28,6 +28,8 @@ int tokulogger_log_newbrtnode (TOKUTXN txn, FILENUM filenum, DISKOFF offset, u_i int tokulogger_fsync (TOKULOGGER logger); +int toku_fread_u_int8_t (FILE *f, u_int8_t *v, u_int32_t *crc, u_int32_t *len); + int toku_fread_u_int32_t_nocrclen (FILE *f, u_int32_t *v); int toku_fread_u_int32_t (FILE *f, u_int32_t *v, u_int32_t *crc, u_int32_t *len); int toku_fread_LSN (FILE *f, LSN *lsn, u_int32_t *crc, u_int32_t *len); @@ -43,6 +45,7 @@ int toku_logprint_TXNID (FILE *outf, FILE *inf, const char *fieldname, int toku_logprint_BYTESTRING (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len); int toku_logprint_FILENUM (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len); int toku_logprint_DISKOFF (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len); +int toku_logprint_u_int8_t (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len); int toku_logprint_u_int32_t (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len); int toku_logprint_LOGGEDBRTHEADER (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len); diff --git a/newbrt/logdump.c b/newbrt/logdump.c index 9ef200b8fa0..276d3b267c7 100644 --- a/newbrt/logdump.c +++ b/newbrt/logdump.c @@ -141,33 +141,23 @@ void read_and_print_magic (void) { } } -#if 1 -int main (int argc, char *argv[]) { - int count=-1; +static void newmain (int count) { int i; - if (argc>1) { - count = atoi(argv[1]); - } read_and_print_magic(); for (i=0; i!=count; i++) { int r = toku_logprint_one_record(stdout, stdin); + if (r==EOF) break; if (r!=0) { fflush(stdout); fprintf(stderr, "Problem in log err=%d\n", r); exit(1); } } - return 0; } -#else -int main (int argc, char *argv[]) { +static void oldmain (int count) { int cmd; - int count=-1; int i; - if (argc>1) { - count = atoi(argv[1]); - } read_and_print_magic(); for (i=0; i!=count && (crc=0,actual_len=0,cmd=get_char())!=EOF; @@ -268,6 +258,21 @@ int main (int argc, char *argv[]) { assert(0); next: ; /*nothing*/ } +} + +int main (int argc, char *argv[]) { + int count=-1; + int oldcode=0; + while (argc>1) { + if (strcmp(argv[1], "--oldcode")==0) { + oldcode=1; + } else { + count = atoi(argv[1]); + } + argc--; argv++; + } + if (oldcode) oldmain(count); + else newmain(count); return 0; } -#endif + diff --git a/newbrt/logformat.c b/newbrt/logformat.c index 5b051eaed42..ac1b5230610 100644 --- a/newbrt/logformat.c +++ b/newbrt/logformat.c @@ -42,10 +42,18 @@ const struct logtype logtypes[] = { {"BYTESTRING", "fname"}, {"u_int32_t", "mode"}, NULLFIELD}}, - {"fheader", 'H', FA{{"TXNID", "txnid"}, - {"FILENUM", "filenum"}, - {"LOGGEDBRTHEADER", "header"}, - NULLFIELD}}, + {"fheader", 'H', FA{{"TXNID", "txnid"}, + {"FILENUM", "filenum"}, + {"LOGGEDBRTHEADER", "header"}, + NULLFIELD}}, + {"newbrtnode", 'N', FA{{"TXNID", "txnid"}, + {"FILENUM", "filenum"}, + {"DISKOFF", "diskoff"}, + {"u_int32_t", "height"}, + {"u_int32_t", "nodesize"}, + {"u_int8_t", "is_dup_sort"}, + {"u_int32_t", "rand4fingerprint"}, + NULLFIELD}}, {"fopen", 'O', FA{{"TXNID", "txnid"}, {"BYTESTRING", "fname"}, {"FILENUM", "filenum"}, diff --git a/newbrt/wbuf.h b/newbrt/wbuf.h index c59abbaf193..b2427eeb5ba 100644 --- a/newbrt/wbuf.h +++ b/newbrt/wbuf.h @@ -93,6 +93,10 @@ static inline void wbuf_BYTESTRING (struct wbuf *w, BYTESTRING v) { wbuf_bytes(w, v.data, v.len); } +static inline void wbuf_u_int8_t (struct wbuf *w, u_int8_t v) { + wbuf_char(w, v); +} + static inline void wbuf_u_int32_t (struct wbuf *w, u_int32_t v) { wbuf_int(w, v); }