Changeset: d3d4866c694c for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/d3d4866c694c Modified Files: sql/backends/monet5/sql.c Branch: sqloptimizer Log Message:
Merged with default diffs (truncated from 1299 to 300 lines): 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 @@ -166,7 +166,6 @@ BAT *BATmergecand(BAT *a, BAT *b); void *BATmin(BAT *b, void *aggr); void *BATmin_skipnil(BAT *b, void *aggr, bit skipnil); gdk_return BATmode(BAT *b, bool transient); -void BATmsync(BAT *b); BAT *BATnegcands(BUN nr, BAT *odels); BAT *BATnil_grp(BAT *l, BAT *g, BAT *e, BAT *s); bool BATordered(BAT *b); diff --git a/gdk/ChangeLog b/gdk/ChangeLog --- a/gdk/ChangeLog +++ b/gdk/ChangeLog @@ -1,6 +1,10 @@ # ChangeLog file for GDK # This file is updated with Maddlog +* Fri Mar 18 2022 Sjoerd Mullender <sjo...@acm.org> +- Get rid of macro Tsize, use ->twidth instead. +- Get rid of macro BUNlast, just use BATcount instead. + * Mon Jan 31 2022 Sjoerd Mullender <sjo...@acm.org> - The BLOB type has been moved into the GDK layer. diff --git a/gdk/ChangeLog.Jan2022 b/gdk/ChangeLog.Jan2022 --- a/gdk/ChangeLog.Jan2022 +++ b/gdk/ChangeLog.Jan2022 @@ -1,6 +1,11 @@ # ChangeLog file for GDK # This file is updated with Maddlog +* Fri Mar 18 2022 Sjoerd Mullender <sjo...@acm.org> +- Fixed a race condition which could cause a too large size being written + for a .theap file to the BBP.dir file after the correct size file had + been saved to disk. + * Wed Mar 9 2022 Sjoerd Mullender <sjo...@acm.org> - Fixed a bug in the append code for msk (bit mask) bats. - Conversions from floating point types to integral types that involve diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -1148,8 +1148,6 @@ gdk_export BUN BUNfnd(BAT *b, const void #define BATttype(b) (BATtdense(b) ? TYPE_oid : (b)->ttype) -#define Tsize(b) ((b)->twidth) - #define tailsize(b,p) ((b)->ttype ? \ (ATOMstorage((b)->ttype) == TYPE_msk ? \ (((size_t) (p) + 31) / 32) * 4 : \ @@ -1170,8 +1168,6 @@ typedef var_t stridx_t; #define BUNtvar(bi,p) (assert((bi).type && (bi).b->tvarsized), (void *) ((bi).vh->base+BUNtvaroff(bi,p))) #define BUNtail(bi,p) ((bi).type?(bi).b->tvarsized?BUNtvar(bi,p):(bi).type==TYPE_msk?BUNtmsk(bi,p):BUNtloc(bi,p):BUNtpos(bi,p)) -#define BUNlast(b) (assert((b)->batCount <= BUN_MAX), (b)->batCount) - #define BATcount(b) ((b)->batCount) #include "gdk_atoms.h" @@ -1310,7 +1306,6 @@ gdk_export gdk_return BATgroup(BAT **gro gdk_export gdk_return BATsave(BAT *b) __attribute__((__warn_unused_result__)); -gdk_export void BATmsync(BAT *b); #define NOFARM (-1) /* indicate to GDKfilepath to create relative path */ @@ -2228,7 +2223,7 @@ gdk_export void VIEWbounds(BAT *b, BAT * * is the iteration variable. */ #define BATloop(r, p, q) \ - for (q = BUNlast(r), p = 0; p < q; p++) + for (q = BATcount(r), p = 0; p < q; p++) /* * @+ Common BAT Operations diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c --- a/gdk/gdk_aggr.c +++ b/gdk/gdk_aggr.c @@ -102,7 +102,7 @@ BATgroupaggrinit(BAT *b, BAT *g, BAT *e, if (!is_oid_nil(min)) { /* found a non-nil, max must be last * value (and there is one!) */ - max = gids[BUNlast(g) - 1]; + max = gids[BATcount(g) - 1]; } } else { /* we'll do a complete scan */ diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c --- a/gdk/gdk_align.c +++ b/gdk/gdk_align.c @@ -179,7 +179,7 @@ BATmaterialize(BAT *b) if ((tail = GDKmalloc(sizeof(Heap))) == NULL) return GDK_FAIL; p = 0; - q = BUNlast(b); + q = BATcount(b); assert(cnt >= q - p); TRC_DEBUG(ALGO, "BATmaterialize(" ALGOBATFMT ")\n", ALGOBATPAR(b)); diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -631,7 +631,7 @@ BATclear(BAT *b, bool force) if (tatmdel) { BATiter bi = bat_iterator_nolock(b); - for (p = b->batInserted, q = BUNlast(b); p < q; p++) + for (p = b->batInserted, q = BATcount(b); p < q; p++) (*tatmdel)(b->tvheap, (var_t*) BUNtloc(bi,p)); b->tvheap->dirty = true; } @@ -951,7 +951,7 @@ COLcopy(BAT *b, int tt, bool writable, r bn->tunique_est = bi.unique_est; } else if (ATOMstorage(tt) == ATOMstorage(b->ttype) && ATOMcompare(tt) == ATOMcompare(b->ttype)) { - BUN h = BUNlast(b); + BUN h = BATcount(b); bn->tsorted = b->tsorted; bn->trevsorted = b->trevsorted; if (b->tkey) @@ -1018,7 +1018,7 @@ BUNappendmulti(BAT *b, const void *value TRC_DEBUG(ALGO, ALGOBATFMT " appending " BUNFMT " values%s\n", ALGOBATPAR(b), count, values ? "" : " (all nil)"); - p = BUNlast(b); /* insert at end */ + p = BATcount(b); /* insert at end */ if (p == BUN_MAX || BATcount(b) + count >= BUN_MAX) { GDKerror("bat too large\n"); return GDK_FAIL; @@ -1326,7 +1326,7 @@ BUNdelete(BAT *b, oid o) return GDK_FAIL; HASHdelete(b, p, val); ATOMdel(b->ttype, b->tvheap, (var_t *) BUNtloc(bi, p)); - if (p != BUNlast(b) - 1 && + if (p != BATcount(b) - 1 && (b->ttype != TYPE_void || BATtdense(b))) { /* replace to-be-delete BUN with last BUN; materialize * void column before doing so */ @@ -1334,20 +1334,20 @@ BUNdelete(BAT *b, oid o) BATmaterialize(b) != GDK_SUCCEED) return GDK_FAIL; if (ATOMstorage(b->ttype) == TYPE_msk) { - msk mval = mskGetVal(b, BUNlast(b) - 1); + msk mval = mskGetVal(b, BATcount(b) - 1); assert(b->thash == NULL); mskSetVal(b, p, mval); /* don't leave garbage */ - mskClr(b, BUNlast(b) - 1); + mskClr(b, BATcount(b) - 1); } else { - val = Tloc(b, BUNlast(b) - 1); - HASHdelete(b, BUNlast(b) - 1, val); - memcpy(Tloc(b, p), val, Tsize(b)); + val = Tloc(b, BATcount(b) - 1); + HASHdelete(b, BATcount(b) - 1, val); + memcpy(Tloc(b, p), val, b->twidth); HASHinsert(b, p, val); MT_lock_set(&b->theaplock); - if (b->tminpos == BUNlast(b) - 1) + if (b->tminpos == BATcount(b) - 1) b->tminpos = p; - if (b->tmaxpos == BUNlast(b) - 1) + if (b->tmaxpos == BATcount(b) - 1) b->tmaxpos = p; MT_lock_unset(&b->theaplock); } @@ -1394,7 +1394,7 @@ BUNdelete(BAT *b, oid o) static gdk_return BUNinplacemulti(BAT *b, const oid *positions, const void *values, BUN count, bool force, bool autoincr) { - BUN last = BUNlast(b) - 1; + BUN last = BATcount(b) - 1; BATiter bi = bat_iterator_nolock(b); int tt; BUN prv, nxt; @@ -1888,11 +1888,11 @@ BATsetcount(BAT *b, BUN cnt) b->tnosorted = b->tnorevsorted = 0; } /* if the BAT was made smaller, we need to zap some values */ - if (b->tnosorted >= BUNlast(b)) + if (b->tnosorted >= BATcount(b)) b->tnosorted = 0; - if (b->tnorevsorted >= BUNlast(b)) + if (b->tnorevsorted >= BATcount(b)) b->tnorevsorted = 0; - if (b->tnokey[0] >= BUNlast(b) || b->tnokey[1] >= BUNlast(b)) { + if (b->tnokey[0] >= BATcount(b) || b->tnokey[1] >= BATcount(b)) { b->tnokey[0] = 0; b->tnokey[1] = 0; } @@ -2524,7 +2524,7 @@ BATassertProps(BAT *b) cmpf = ATOMcompare(b->ttype); nilp = ATOMnilptr(b->ttype); - assert(b->theap->free >= tailsize(b, BUNlast(b))); + assert(b->theap->free >= tailsize(b, BATcount(b))); if (b->ttype != TYPE_void) { assert(b->batCount <= b->batCapacity); assert(b->theap->size >= b->theap->free); @@ -2774,7 +2774,7 @@ BATassertProps(BAT *b) TRANSIENT, b->ttype, hashheap)) < 0 || (hs->heapbckt.farmid = BBPselectfarm( TRANSIENT, b->ttype, hashheap)) < 0 || - HASHnew(hs, b->ttype, BUNlast(b), + HASHnew(hs, b->ttype, BATcount(b), mask, BUN_NONE, false) != GDK_SUCCEED) { GDKfree(hs); TRC_WARNING(BAT_, "Cannot allocate hash table\n"); diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -167,7 +167,7 @@ insert_string_bat(BAT *b, BAT *n, struct /* we don't need to do any translation of offset * values, so we can use fast memcpy */ MT_thread_setalgorithm("memcpy offsets"); - memcpy(Tloc(b, BUNlast(b)), (const char *) ni.base + ((ci->seq - n->hseqbase) << ni.shift), cnt << ni.shift); + memcpy(Tloc(b, BATcount(b)), (const char *) ni.base + ((ci->seq - n->hseqbase) << ni.shift), cnt << ni.shift); } else if (toff != ~(size_t) 0) { /* we don't need to insert any actual strings since we * have already made sure that they are all in b's @@ -374,11 +374,11 @@ append_varsized_bat(BAT *b, BAT *n, stru if (ci->tpe == cand_dense) { /* fast memcpy since we copy a consecutive * chunk of memory */ - memcpy(Tloc(b, BUNlast(b)), + memcpy(Tloc(b, BATcount(b)), (const var_t *) ni.base + (ci->seq - hseq), cnt << b->tshift); } else { - var_t *restrict dst = (var_t *) Tloc(b, BUNlast(b)); + var_t *restrict dst = (var_t *) Tloc(b, BATcount(b)); const var_t *restrict src = (const var_t *) ni.base; while (cnt > 0) { cnt--; @@ -425,7 +425,7 @@ append_varsized_bat(BAT *b, BAT *n, stru MT_lock_unset(&b->theaplock); } /* copy data from n to b */ - r = BUNlast(b); + r = BATcount(b); MT_rwlock_wrlock(&b->thashlock); while (cnt > 0) { cnt--; @@ -660,7 +660,7 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool goto doreturn; } - if (BUNlast(b) + cnt > BUN_MAX) { + if (BATcount(b) + cnt > BUN_MAX) { bat_iterator_end(&ni); GDKerror("combined BATs too large\n"); return GDK_FAIL; @@ -741,7 +741,7 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool } } - r = BUNlast(b); + r = BATcount(b); /* property setting */ if (BATcount(b) == 0) { @@ -832,7 +832,7 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool ni.type != TYPE_void && ci.tpe == cand_dense) { /* use fast memcpy if we can */ - memcpy(Tloc(b, BUNlast(b)), + memcpy(Tloc(b, BATcount(b)), (const char *) ni.base + ((ci.seq - hseq) << ni.shift), cnt << ni.shift); for (BUN i = 0; b->thash && i < cnt; i++) { @@ -934,7 +934,7 @@ BATdel(BAT *b, BAT *d) } else { memmove(Tloc(b, o), Tloc(b, o + c), - Tsize(b) * (BATcount(b) - (o + c))); + b->twidth * (BATcount(b) - (o + c))); } b->theap->dirty = true; // o += b->hseqbase; // if this were to be used again @@ -999,7 +999,7 @@ BATdel(BAT *b, BAT *d) } pos += n; } else { - n *= Tsize(b); + n *= b->twidth; memmove(p, Tloc(b, o[-1] + 1 - b->hseqbase), n); @@ -1782,7 +1782,7 @@ BATslice(BAT *b, BUN l, BUN h) (BATcount(bn) == 1 || (bn->tkey && bn->tsorted && - foid + BATcount(bn) - 1 == *(oid *) BUNtloc(bni, BUNlast(bn) - 1)))) { + foid + BATcount(bn) - 1 == *(oid *) BUNtloc(bni, BATcount(bn) - 1)))) { BATtseqbase(bn, foid); } } _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org