Changeset: 9bbe639dfaf7 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/9bbe639dfaf7 Modified Files: gdk/gdk_logger.c gdk/gdk_logger_internals.h gdk/gdk_logger_old.c Branch: Sep2022 Log Message:
merged with jan2022 diffs (283 lines): diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c --- a/gdk/gdk_logger.c +++ b/gdk/gdk_logger.c @@ -310,12 +310,12 @@ string_reader(logger *lg, BAT *b, lng nr if (mnstr_readLng(lg->input_log, &SZ) != 1) return LOG_EOF; sz = (size_t)SZ; - char *buf = lg->buf; - if (lg->bufsize < sz) { - if (!(buf = GDKrealloc(lg->buf, sz))) + char *buf = lg->rbuf; + if (lg->rbufsize < sz) { + if (!(buf = GDKrealloc(lg->rbuf, sz))) return LOG_ERR; - lg->buf = buf; - lg->bufsize = sz; + lg->rbuf = buf; + lg->rbufsize = sz; } if (mnstr_read(lg->input_log, buf, sz, 1) != 1) @@ -419,8 +419,8 @@ log_read_updates(logger *lg, trans *tr, } // We have to read the value to update the read cursor - size_t tlen = lg->bufsize; - void *t = rt(lg->buf, &tlen, lg->input_log, 1); + size_t tlen = lg->rbufsize; + void *t = rt(lg->rbuf, &tlen, lg->input_log, 1); if (t == NULL) { res = LOG_ERR; } @@ -438,13 +438,13 @@ log_read_updates(logger *lg, trans *tr, } if (l->flag == LOG_UPDATE_CONST) { - size_t tlen = lg->bufsize; - void *t = rt(lg->buf, &tlen, lg->input_log, 1); + size_t tlen = lg->rbufsize; + void *t = rt(lg->rbuf, &tlen, lg->input_log, 1); if (t == NULL) { res = LOG_ERR; } else { - lg->buf = t; - lg->bufsize = tlen; + lg->rbuf = t; + lg->rbufsize = tlen; for(BUN p = 0; p<(BUN) nr; p++) { if (r && BUNappend(r, t, true) != GDK_SUCCEED) res = LOG_ERR; @@ -463,32 +463,32 @@ log_read_updates(logger *lg, trans *tr, else res = LOG_ERR; } else { - size_t tlen = lg->bufsize/sizeof(int); + size_t tlen = lg->rbufsize/sizeof(int); size_t cnt = 0, snr = (size_t)nr; snr = (snr+31)/32; assert(tlen); for (; res == LOG_OK && snr > 0; snr-=cnt) { cnt = snr>tlen?tlen:snr; - if (!mnstr_readIntArray(lg->input_log, lg->buf, cnt)) + if (!mnstr_readIntArray(lg->input_log, lg->rbuf, cnt)) res = LOG_ERR; } } } else { if (!ATOMvarsized(tpe)) { size_t cnt = 0, snr = (size_t)nr; - size_t tlen = lg->bufsize/ATOMsize(tpe), ntlen = lg->bufsize; + size_t tlen = lg->rbufsize/ATOMsize(tpe), ntlen = lg->rbufsize; assert(tlen); /* read in chunks of max * BUFSIZE/width rows */ for (; res == LOG_OK && snr > 0; snr-=cnt) { cnt = snr>tlen?tlen:snr; - void *t = rt(lg->buf, &ntlen, lg->input_log, cnt); + void *t = rt(lg->rbuf, &ntlen, lg->input_log, cnt); if (t == NULL) { res = LOG_EOF; break; } - assert(t == lg->buf); + assert(t == lg->rbuf); if (r && BUNappendmulti(r, t, cnt, true) != GDK_SUCCEED) res = LOG_ERR; } @@ -497,8 +497,8 @@ log_read_updates(logger *lg, trans *tr, res = string_reader(lg, r, nr); } else { for (; res == LOG_OK && nr > 0; nr--) { - size_t tlen = lg->bufsize; - void *t = rt(lg->buf, &tlen, lg->input_log, 1); + size_t tlen = lg->rbufsize; + void *t = rt(lg->rbuf, &tlen, lg->input_log, 1); if (t == NULL) { /* see if failure was due to @@ -510,8 +510,8 @@ log_read_updates(logger *lg, trans *tr, else res = LOG_ERR; } else { - lg->buf = t; - lg->bufsize = tlen; + lg->rbuf = t; + lg->rbufsize = tlen; if (r && BUNappend(r, t, true) != GDK_SUCCEED) res = LOG_ERR; } @@ -561,8 +561,8 @@ log_read_updates(logger *lg, trans *tr, res = string_reader(lg, r, nr); } else { for (; res == LOG_OK && nr > 0; nr--) { - size_t tlen = lg->bufsize; - void *t = rt(lg->buf, &tlen, lg->input_log, 1); + size_t tlen = lg->rbufsize; + void *t = rt(lg->rbuf, &tlen, lg->input_log, 1); if (t == NULL) { if (strstr(GDKerrbuf, "malloc") == NULL) @@ -570,8 +570,8 @@ log_read_updates(logger *lg, trans *tr, else res = LOG_ERR; } else { - lg->buf = t; - lg->bufsize = tlen; + lg->rbuf = t; + lg->rbufsize = tlen; if ((r && BUNappend(r, t, true) != GDK_SUCCEED)) res = LOG_ERR; } @@ -2121,7 +2121,8 @@ log_load(int debug, const char *fn, cons MT_lock_destroy(&lg->flush_queue_lock); GDKfree(lg->fn); GDKfree(lg->dir); - GDKfree(lg->buf); + GDKfree(lg->rbuf); + GDKfree(lg->wbuf); GDKfree(lg); GDKdebug = dbg; return GDK_FAIL; @@ -2169,13 +2170,17 @@ log_new(int debug, const char *fn, const } lg->fn = GDKstrdup(fn); lg->dir = GDKstrdup(filename); - lg->bufsize = 64*1024; - lg->buf = GDKmalloc(lg->bufsize); - if (lg->fn == NULL || lg->dir == NULL || lg->buf == NULL) { + lg->rbufsize = 64*1024; + lg->rbuf = GDKmalloc(lg->rbufsize); + lg->wbufsize = 64*1024; + lg->wbuf = GDKmalloc(lg->wbufsize); + if (lg->fn == NULL || lg->dir == NULL || + lg->rbuf == NULL || lg->wbuf == NULL) { TRC_CRITICAL(GDK, "strdup failed\n"); GDKfree(lg->fn); GDKfree(lg->dir); - GDKfree(lg->buf); + GDKfree(lg->rbuf); + GDKfree(lg->wbuf); GDKfree(lg); return NULL; } @@ -2245,7 +2250,8 @@ log_destroy(logger *lg) MT_lock_destroy(&lg->flush_queue_lock); GDKfree(lg->fn); GDKfree(lg->dir); - GDKfree(lg->buf); + GDKfree(lg->rbuf); + GDKfree(lg->wbuf); log_close_input(lg); log_close_output(lg); GDKfree(lg); @@ -2484,9 +2490,9 @@ log_constant(logger *lg, int type, ptr v static gdk_return string_writer(logger *lg, BAT *b, lng offset, lng nr) { - size_t bufsz = lg->bufsize, resize = 0; + size_t bufsz = lg->wbufsize, resize = 0; BUN end = (BUN)(offset + nr); - char *buf = lg->buf; + char *buf = lg->wbuf; gdk_return res = GDK_SUCCEED; if (!buf) @@ -2496,12 +2502,12 @@ string_writer(logger *lg, BAT *b, lng of for ( ; p < end; ) { size_t sz = 0; if (resize) { - if (!(buf = GDKrealloc(lg->buf, resize))) { + if (!(buf = GDKrealloc(lg->wbuf, resize))) { res = GDK_FAIL; break; } - lg->buf = buf; - lg->bufsize = bufsz = resize; + lg->wbuf = buf; + lg->wbufsize = bufsz = resize; resize = 0; } char *dst = buf; diff --git a/gdk/gdk_logger_internals.h b/gdk/gdk_logger_internals.h --- a/gdk/gdk_logger_internals.h +++ b/gdk/gdk_logger_internals.h @@ -66,8 +66,10 @@ struct logger { uint8_t type_nr[256]; /* mapping from logger type id to GDK type nr */ int8_t type_id[128]; /* mapping from GDK type nr to logger type id */ - void *buf; - size_t bufsize; + void *rbuf; + size_t rbufsize; + void *wbuf; + size_t wbufsize; /* flush variables */ unsigned int flush_queue[FLUSH_QUEUE_SIZE]; /* circular array with the current transactions' ids waiting to be flushed */ diff --git a/gdk/gdk_logger_old.c b/gdk/gdk_logger_old.c --- a/gdk/gdk_logger_old.c +++ b/gdk/gdk_logger_old.c @@ -495,8 +495,8 @@ log_read_updates(old_logger *lg, trans * if (ht == TYPE_void && l->flag == LOG_INSERT) { lng nr = l->nr; for (; res == LOG_OK && nr > 0; nr--) { - size_t tlen = lg->lg->bufsize; - void *t = rt(lg->lg->buf, &tlen, lg->log, 1); + size_t tlen = lg->lg->rbufsize; + void *t = rt(lg->lg->rbuf, &tlen, lg->log, 1); if (t == NULL) { /* see if failure was due to @@ -509,8 +509,8 @@ log_read_updates(old_logger *lg, trans * res = LOG_ERR; break; } else { - lg->lg->buf = t; - lg->lg->bufsize = tlen; + lg->lg->rbuf = t; + lg->lg->rbufsize = tlen; } if (BUNappend(r, t, true) != GDK_SUCCEED) res = LOG_ERR; @@ -526,13 +526,13 @@ log_read_updates(old_logger *lg, trans * if (!pax) { lng nr = l->nr; for (; res == LOG_OK && nr > 0; nr--) { - size_t tlen = lg->lg->bufsize; + size_t tlen = lg->lg->rbufsize; void *h = rh(hv, &hlen, lg->log, 1); - void *t = rt(lg->lg->buf, &tlen, lg->log, 1); + void *t = rt(lg->lg->rbuf, &tlen, lg->log, 1); if (t != NULL) { - lg->lg->buf = t; - lg->lg->bufsize = tlen; + lg->lg->rbuf = t; + lg->lg->rbufsize = tlen; } if (h == NULL) res = LOG_EOF; @@ -574,8 +574,8 @@ log_read_updates(old_logger *lg, trans * } nr = l->nr; for (; res == LOG_OK && nr > 0; nr--) { - size_t tlen = lg->lg->bufsize; - void *t = rt(lg->lg->buf, &tlen, lg->log, 1); + size_t tlen = lg->lg->rbufsize; + void *t = rt(lg->lg->rbuf, &tlen, lg->log, 1); if (t == NULL) { if (strstr(GDKerrbuf, "malloc") == NULL) @@ -583,8 +583,8 @@ log_read_updates(old_logger *lg, trans * else res = LOG_ERR; } else { - lg->lg->buf = t; - lg->lg->bufsize = tlen; + lg->lg->rbuf = t; + lg->lg->rbufsize = tlen; if (BUNappend(r, t, true) != GDK_SUCCEED) res = LOG_ERR; } _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org