Changeset: fa590305c5a3 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fa590305c5a3 Modified Files: clients/Tests/MAL-signatures.stable.out clients/Tests/MAL-signatures.stable.out.int128 clients/Tests/exports.stable.out gdk/gdk_logger.c monetdb5/modules/mal/bbp.c monetdb5/modules/mal/bbp.h monetdb5/modules/mal/bbp.mal sql/test/leaks/Tests/check3.stable.out sql/test/leaks/Tests/check3.stable.out.int128 sql/test/leaks/Tests/check4.stable.out sql/test/leaks/Tests/check4.stable.out.int128 sql/test/leaks/Tests/check5.stable.out sql/test/leaks/Tests/check5.stable.out.int128 Branch: Jul2015 Log Message:
clear sql_catalog bats by replacing them with new bats, should solve problems with forced BATclear diffs (truncated from 414 to 300 lines): diff --git a/clients/Tests/MAL-signatures.stable.out b/clients/Tests/MAL-signatures.stable.out --- a/clients/Tests/MAL-signatures.stable.out +++ b/clients/Tests/MAL-signatures.stable.out @@ -31533,6 +31533,10 @@ command bbp.getIndex(b:bat[:oid,:any_2]) address CMDbbpgetIndex; comment Retrieve the index in the BBP +command bbp.setName(b:bat[:oid,:any_1],n:str):str +address CMDsetName; +comment Rename a BAT + command blob.blob(s:str):blob address BLOBblob_fromstr; command blob.blob(s:blob):blob diff --git a/clients/Tests/MAL-signatures.stable.out.int128 b/clients/Tests/MAL-signatures.stable.out.int128 --- a/clients/Tests/MAL-signatures.stable.out.int128 +++ b/clients/Tests/MAL-signatures.stable.out.int128 @@ -40578,6 +40578,10 @@ command bbp.getIndex(b:bat[:oid,:any_2]) address CMDbbpgetIndex; comment Retrieve the index in the BBP +command bbp.setName(b:bat[:oid,:any_1],n:str):str +address CMDsetName; +comment Rename a BAT + command blob.blob(s:str):blob address BLOBblob_fromstr; command blob.blob(s:blob):blob diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -1178,6 +1178,7 @@ str CMDscience_bat_flt_sqrt(bat *ret, co str CMDscience_bat_flt_tan(bat *ret, const bat *bid); str CMDscience_bat_flt_tanh(bat *ret, const bat *bid); str CMDsetHeartbeat(void *res, int *ev); +str CMDsetName(str *rname, const bat *b, str *name); str CMDsetProfilerFile(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); str CMDsetProfilerStream(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); str CMDsetoid(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c --- a/gdk/gdk_logger.c +++ b/gdk/gdk_logger.c @@ -1118,12 +1118,40 @@ bm_tids(BAT *b, BAT *d) return tids; } +static void +logger_fatal(const char *format, const char *arg1, const char *arg2, const char *arg3) +{ + char *buf; + + GDKfatal(format, arg1, arg2, arg3); + GDKlog(format, arg1, arg2, arg3); + if ((buf = GDKerrbuf) != NULL) { + fprintf(stderr, "%s", buf); + fflush(stderr); + } + GDKexit(1); +} + +static void +logger_switch_bat( BAT *old, BAT *new, const char *fn, const char *name) +{ + char bak[BUFSIZ]; + + if (BATmode(old, TRANSIENT) != GDK_SUCCEED) + logger_fatal("Logger_new: cannot convert old %s to transient", name, 0, 0); + snprintf(bak, sizeof(bak), "tmp_%o", old->batCacheid); + if (BBPrename(old->batCacheid, bak) != 0) + logger_fatal("Logger_new: cannot rename old %s", name, 0, 0); + snprintf(bak, sizeof(bak), "%s_%s", fn, name); + if (BBPrename(new->batCacheid, bak) != 0) + logger_fatal("Logger_new: cannot rename new %s", name, 0, 0); +} static gdk_return -bm_subcommit(BAT *list_bid, BAT *list_nme, BAT *catalog_bid, BAT *catalog_nme, BAT *dcatalog, BAT *extra, int debug) +bm_subcommit(logger *lg, BAT *list_bid, BAT *list_nme, BAT *catalog_bid, BAT *catalog_nme, BAT *dcatalog, BAT *extra, int debug) { BUN p, q; - BUN nn = 4 + BATcount(list_bid) + (extra ? BATcount(extra) : 0); + BUN nn = 6 + BATcount(list_bid) + (extra ? BATcount(extra) : 0); bat *n = GDKmalloc(sizeof(bat) * nn); int i = 0; BATiter iter = (list_nme)?bat_iterator(list_nme):bat_iterator(list_bid); @@ -1161,20 +1189,30 @@ bm_subcommit(BAT *list_bid, BAT *list_nm n[i++] = abs(catalog_nme->batCacheid); n[i++] = abs(dcatalog->batCacheid); assert((BUN) i <= nn); - if (BATcount(dcatalog) && catalog_bid == list_bid && catalog_nme == list_nme) { - BAT *bids, *nmes, *tids = bm_tids(catalog_bid, dcatalog); + if (BATcount(dcatalog) > (BATcount(catalog_nme)/2) && catalog_bid == list_bid && catalog_nme == list_nme && lg->catalog_bid == catalog_bid) { + BAT *bids, *nmes, *tids = bm_tids(catalog_bid, dcatalog), *b; - bids = BATproject(tids, catalog_bid); - nmes = BATproject(tids, catalog_nme); + bids = logbat_new(TYPE_int, BATSIZE, PERSISTENT); + nmes = logbat_new(TYPE_str, BATSIZE, PERSISTENT); + b = BATproject(tids, catalog_bid); + BATappend(bids, b, TRUE); + logbat_destroy(b); + b = BATproject(tids, catalog_nme); + BATappend(nmes, b, TRUE); + logbat_destroy(b); logbat_destroy(tids); - BATclear(catalog_bid, TRUE); - BATclear(catalog_nme, TRUE); BATclear(dcatalog, TRUE); - BATappend(catalog_bid, bids, FALSE); - BATappend(catalog_nme, nmes, FALSE); - logbat_destroy(bids); - logbat_destroy(nmes); + logger_switch_bat(catalog_bid, bids, lg->fn, "catalog_bid"); + logger_switch_bat(catalog_nme, nmes, lg->fn, "catalog_nme"); + n[i++] = bids->batCacheid; + n[i++] = nmes->batCacheid; + + logbat_destroy(lg->catalog_bid); + logbat_destroy(lg->catalog_nme); + + lg->catalog_bid = catalog_bid = bids; + lg->catalog_nme = catalog_nme = nmes; } BATcommit(catalog_bid); BATcommit(catalog_nme); @@ -1186,20 +1224,6 @@ bm_subcommit(BAT *list_bid, BAT *list_nm return res; } -static void -logger_fatal(const char *format, const char *arg1, const char *arg2, const char *arg3) -{ - char *buf; - - GDKfatal(format, arg1, arg2, arg3); - GDKlog(format, arg1, arg2, arg3); - if ((buf = GDKerrbuf) != NULL) { - fprintf(stderr, "%s", buf); - fflush(stderr); - } - GDKexit(1); -} - static logger * logger_new(int debug, const char *fn, const char *logdir, int version, preversionfix_fptr prefuncp, postversionfix_fptr postfuncp) { @@ -1364,7 +1388,7 @@ logger_new(int debug, const char *fn, co } fp = NULL; - if (bm_subcommit(lg->catalog_bid, lg->catalog_nme, lg->catalog_bid, lg->catalog_nme, lg->dcatalog, NULL, lg->debug) != GDK_SUCCEED) { + if (bm_subcommit(lg, lg->catalog_bid, lg->catalog_nme, lg->catalog_bid, lg->catalog_nme, lg->dcatalog, NULL, lg->debug) != GDK_SUCCEED) { /* cannot commit catalog, so remove log */ unlink(filename); goto error; @@ -1420,22 +1444,8 @@ logger_new(int debug, const char *fn, co logger_fatal("Logger_new: cannot create BAT", 0, 0, 0); list[3] = b2->batCacheid; list[4] = n2->batCacheid; - if (BATmode(b, TRANSIENT) != GDK_SUCCEED) - logger_fatal("Logger_new: cannot convert old catalog_bid to transient", 0, 0, 0); - if (BATmode(n, TRANSIENT) != GDK_SUCCEED) - logger_fatal("Logger_new: cannot convert old catalog_nme to transient", 0, 0, 0); - snprintf(bak, sizeof(bak), "tmp_%o", b->batCacheid); - if (BBPrename(b->batCacheid, bak) != 0) - logger_fatal("Logger_new: cannot rename old catalog_bid", 0, 0, 0); - snprintf(bak, sizeof(bak), "tmp_%o", n->batCacheid); - if (BBPrename(n->batCacheid, bak) != 0) - logger_fatal("Logger_new: cannot rename old catalog_nme", 0, 0, 0); - snprintf(bak, sizeof(bak), "%s_catalog_bid", fn); - if (BBPrename(b2->batCacheid, bak) != 0) - logger_fatal("Logger_new: cannot rename new catalog_bid", 0, 0, 0); - snprintf(bak, sizeof(bak), "%s_catalog_nme", fn); - if (BBPrename(n2->batCacheid, bak) != 0) - logger_fatal("Logger_new: cannot rename new catalog_nme", 0, 0, 0); + logger_switch_bat(b, b2, fn, "catalog_bid"); + logger_switch_bat(n, n2, fn, "catalog_bid"); bi = bat_iterator(b); ni = bat_iterator(n); BATloop(b, p, q) { @@ -1529,7 +1539,7 @@ logger_new(int debug, const char *fn, co bak, 0, 0); logger_add_bat(lg, lg->dsnapshots, "dsnapshots"); - if (bm_subcommit(lg->catalog_bid, lg->catalog_nme, lg->catalog_bid, lg->catalog_nme, lg->dcatalog, NULL, lg->debug) != GDK_SUCCEED) + if (bm_subcommit(lg, lg->catalog_bid, lg->catalog_nme, lg->catalog_bid, lg->catalog_nme, lg->dcatalog, NULL, lg->debug) != GDK_SUCCEED) logger_fatal("Logger_new: commit failed", 0, 0, 0); } else { bat seqs_id = logger_find_bat(lg, "seqs_id"); @@ -2316,7 +2326,7 @@ log_tend(logger *lg) fprintf(stderr, "!ERROR: log_tend: semijoin failed\n"); return LOG_ERR; } - res = bm_subcommit(bids, NULL, lg->snapshots_bid, + res = bm_subcommit(lg, bids, NULL, lg->snapshots_bid, lg->snapshots_tid, lg->dsnapshots, NULL, lg->debug); BBPunfix(bids->batCacheid); } @@ -2473,7 +2483,7 @@ bm_commit(logger *lg) fprintf(stderr, "#bm_commit: create %d (%d)\n", bid, BBP_lrefs(bid)); } - res = bm_subcommit(lg->catalog_bid, lg->catalog_nme, lg->catalog_bid, lg->catalog_nme, lg->dcatalog, n, lg->debug); + res = bm_subcommit(lg, lg->catalog_bid, lg->catalog_nme, lg->catalog_bid, lg->catalog_nme, lg->dcatalog, n, lg->debug); BBPreclaim(n); BATclear(lg->freed, FALSE); BATcommit(lg->freed); diff --git a/monetdb5/modules/mal/bbp.c b/monetdb5/modules/mal/bbp.c --- a/monetdb5/modules/mal/bbp.c +++ b/monetdb5/modules/mal/bbp.c @@ -482,3 +482,15 @@ str CMDbbp(bat *ID, bat *NS, bat *HT, ba return MAL_SUCCEED; } +str +CMDsetName(str *rname, const bat *bid, str *name) +{ + BAT *b; + if ((b = BATdescriptor(*bid)) == NULL) { + throw(MAL, "bbp.setName", INTERNAL_BAT_ACCESS); + } + BBPrename(b->batCacheid, *name); + *rname = GDKstrdup(*name); + BBPunfix(b->batCacheid); + return MAL_SUCCEED; +} diff --git a/monetdb5/modules/mal/bbp.h b/monetdb5/modules/mal/bbp.h --- a/monetdb5/modules/mal/bbp.h +++ b/monetdb5/modules/mal/bbp.h @@ -54,4 +54,5 @@ bbp_export str CMDbbpgetIndex(int *res, bbp_export str CMDgetBATrefcnt(int *res, bat *bid); bbp_export str CMDgetBATlrefcnt(int *res, bat *bid); bbp_export str CMDbbp(bat *ID, bat *NS, bat *HT, bat *TT, bat *CNT, bat *REFCNT, bat *LREFCNT, bat *LOCATION, bat *HEAT, bat *DIRTY, bat *STATUS, bat *KIND); +bbp_export str CMDsetName(str *rname, const bat *b, str *name); #endif /* _BBP_H_*/ diff --git a/monetdb5/modules/mal/bbp.mal b/monetdb5/modules/mal/bbp.mal --- a/monetdb5/modules/mal/bbp.mal +++ b/monetdb5/modules/mal/bbp.mal @@ -30,6 +30,9 @@ comment "bpp"; command getName( b:bat[:oid,:any_1]):str address CMDbbpName comment "Map a BAT into its internal name"; +command setName( b:bat[:oid,:any_1], n:str):str +address CMDsetName +comment "Rename a BAT"; command getCount() :bat[:oid,:lng] address CMDbbpCount comment "Create a BAT with the cardinalities of all known BATs"; diff --git a/sql/test/leaks/Tests/check3.stable.out b/sql/test/leaks/Tests/check3.stable.out --- a/sql/test/leaks/Tests/check3.stable.out +++ b/sql/test/leaks/Tests/check3.stable.out @@ -178,9 +178,9 @@ Ready. [ "oid", "oid", 0 ] [ "oid", "oid", 0 ] [ "oid", "oid", 0 ] -[ "oid", "oid", 0 ] [ "oid", "oid", 1 ] [ "oid", "oid", 2 ] +[ "oid", "oid", 3 ] [ "oid", "sht", 0 ] [ "oid", "sht", 0 ] [ "oid", "sht", 0 ] @@ -267,7 +267,7 @@ Ready. [ "oid", "str", 55 ] [ "oid", "str", 55 ] [ "oid", "str", 110 ] -[ "oid", "str", 245 ] +[ "oid", "str", 248 ] [ "oid", "str", 363 ] [ "oid", "str", 363 ] [ "oid", "str", 363 ] diff --git a/sql/test/leaks/Tests/check3.stable.out.int128 b/sql/test/leaks/Tests/check3.stable.out.int128 --- a/sql/test/leaks/Tests/check3.stable.out.int128 +++ b/sql/test/leaks/Tests/check3.stable.out.int128 @@ -110,7 +110,7 @@ Ready. [ "oid", "int", 55 ] [ "oid", "int", 238 ] [ "oid", "int", 238 ] -[ "oid", "int", 245 ] +[ "oid", "int", 248 ] [ "oid", "int", 363 ] [ "oid", "int", 363 ] [ "oid", "int", 363 ] @@ -178,9 +178,9 @@ Ready. [ "oid", "oid", 0 ] [ "oid", "oid", 0 ] [ "oid", "oid", 0 ] -[ "oid", "oid", 0 ] [ "oid", "oid", 1 ] [ "oid", "oid", 2 ] +[ "oid", "oid", 3 ] [ "oid", "sht", 0 ] [ "oid", "sht", 0 ] [ "oid", "sht", 0 ] @@ -267,7 +267,7 @@ Ready. [ "oid", "str", 55 ] [ "oid", "str", 55 ] [ "oid", "str", 110 ] -[ "oid", "str", 245 ] _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list