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

New logformat code can now dump our base test. Addresses #11.

git-svn-id: file:///svn/tokudb@725 c7de825b-a66e-492c-adef-691d508d4ae1
parent adba557e
...@@ -40,6 +40,10 @@ struct tokutxn { ...@@ -40,6 +40,10 @@ struct tokutxn {
int tokulogger_finish (TOKULOGGER logger, struct wbuf *wbuf); 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__))) { static inline int toku_logsizeof_u_int32_t (u_int32_t v __attribute__((__unused__))) {
return 4; return 4;
} }
......
...@@ -512,6 +512,19 @@ int toku_logprint_TXNID (FILE *outf, FILE *inf, const char *fieldname, u_int32_t ...@@ -512,6 +512,19 @@ int toku_logprint_TXNID (FILE *outf, FILE *inf, const char *fieldname, u_int32_t
fprintf(outf, " %s=%lld", fieldname, v); fprintf(outf, " %s=%lld", fieldname, v);
return 0; 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) { 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; u_int32_t v;
int r = toku_fread_u_int32_t(inf, &v, crc, len); int r = toku_fread_u_int32_t(inf, &v, crc, len);
......
...@@ -28,6 +28,8 @@ int tokulogger_log_newbrtnode (TOKUTXN txn, FILENUM filenum, DISKOFF offset, u_i ...@@ -28,6 +28,8 @@ int tokulogger_log_newbrtnode (TOKUTXN txn, FILENUM filenum, DISKOFF offset, u_i
int tokulogger_fsync (TOKULOGGER logger); 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_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_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); 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, ...@@ -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_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_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_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_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); int toku_logprint_LOGGEDBRTHEADER (FILE *outf, FILE *inf, const char *fieldname, u_int32_t *crc, u_int32_t *len);
......
...@@ -141,33 +141,23 @@ void read_and_print_magic (void) { ...@@ -141,33 +141,23 @@ void read_and_print_magic (void) {
} }
} }
#if 1 static void newmain (int count) {
int main (int argc, char *argv[]) {
int count=-1;
int i; int i;
if (argc>1) {
count = atoi(argv[1]);
}
read_and_print_magic(); read_and_print_magic();
for (i=0; i!=count; i++) { for (i=0; i!=count; i++) {
int r = toku_logprint_one_record(stdout, stdin); int r = toku_logprint_one_record(stdout, stdin);
if (r==EOF) break;
if (r!=0) { if (r!=0) {
fflush(stdout); fflush(stdout);
fprintf(stderr, "Problem in log err=%d\n", r); fprintf(stderr, "Problem in log err=%d\n", r);
exit(1); exit(1);
} }
} }
return 0;
} }
#else static void oldmain (int count) {
int main (int argc, char *argv[]) {
int cmd; int cmd;
int count=-1;
int i; int i;
if (argc>1) {
count = atoi(argv[1]);
}
read_and_print_magic(); read_and_print_magic();
for (i=0; for (i=0;
i!=count && (crc=0,actual_len=0,cmd=get_char())!=EOF; i!=count && (crc=0,actual_len=0,cmd=get_char())!=EOF;
...@@ -268,6 +258,21 @@ int main (int argc, char *argv[]) { ...@@ -268,6 +258,21 @@ int main (int argc, char *argv[]) {
assert(0); assert(0);
next: ; /*nothing*/ 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; return 0;
} }
#endif
...@@ -42,10 +42,18 @@ const struct logtype logtypes[] = { ...@@ -42,10 +42,18 @@ const struct logtype logtypes[] = {
{"BYTESTRING", "fname"}, {"BYTESTRING", "fname"},
{"u_int32_t", "mode"}, {"u_int32_t", "mode"},
NULLFIELD}}, NULLFIELD}},
{"fheader", 'H', FA{{"TXNID", "txnid"}, {"fheader", 'H', FA{{"TXNID", "txnid"},
{"FILENUM", "filenum"}, {"FILENUM", "filenum"},
{"LOGGEDBRTHEADER", "header"}, {"LOGGEDBRTHEADER", "header"},
NULLFIELD}}, 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"}, {"fopen", 'O', FA{{"TXNID", "txnid"},
{"BYTESTRING", "fname"}, {"BYTESTRING", "fname"},
{"FILENUM", "filenum"}, {"FILENUM", "filenum"},
......
...@@ -93,6 +93,10 @@ static inline void wbuf_BYTESTRING (struct wbuf *w, BYTESTRING v) { ...@@ -93,6 +93,10 @@ static inline void wbuf_BYTESTRING (struct wbuf *w, BYTESTRING v) {
wbuf_bytes(w, v.data, v.len); 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) { static inline void wbuf_u_int32_t (struct wbuf *w, u_int32_t v) {
wbuf_int(w, v); wbuf_int(w, v);
} }
......
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