Changeset: 7b7730305ebf for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/7b7730305ebf Modified Files: gdk/ChangeLog gdk/gdk.h gdk/gdk_aggr.c gdk/gdk_align.c gdk/gdk_bat.c gdk/gdk_batop.c gdk/gdk_delta.c gdk/gdk_delta.h gdk/gdk_group.c gdk/gdk_join.c gdk/gdk_logger.c gdk/gdk_logger_old.c gdk/gdk_select.c gdk/gdk_unique.c monetdb5/modules/atoms/batxml.c monetdb5/modules/kernel/algebra.c monetdb5/modules/kernel/bat5.c monetdb5/modules/mal/batMask.c monetdb5/modules/mal/iterator.c monetdb5/modules/mal/manifold.c monetdb5/modules/mal/pcre.c monetdb5/modules/mal/wlc.c sql/backends/monet5/sql.c sql/backends/monet5/sql_subquery.c sql/storage/bat/bat_logger.c sql/storage/bat/bat_storage.c Branch: default Log Message:
Get rid of macro BUNlast, just use BATcount instead. diffs (truncated from 747 to 300 lines): diff --git a/gdk/ChangeLog b/gdk/ChangeLog --- a/gdk/ChangeLog +++ b/gdk/ChangeLog @@ -1,6 +1,9 @@ # ChangeLog file for GDK # This file is updated with Maddlog +* Fri Mar 18 2022 Sjoerd Mullender <sjo...@acm.org> +- 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/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -1170,8 +1170,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" @@ -2228,7 +2226,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); + val = Tloc(b, BATcount(b) - 1); + HASHdelete(b, BATcount(b) - 1, val); memcpy(Tloc(b, p), val, Tsize(b)); 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++) { @@ -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); } } @@ -1805,7 +1805,7 @@ BATslice(BAT *b, BUN l, BUN h) #define BAT_ORDERED(TPE) \ do { \ const TPE *restrict vals = Tloc(b, 0); \ - for (BUN q = BUNlast(b), p = 1; p < q; p++) { \ + for (BUN q = BATcount(b), p = 1; p < q; p++) { \ if (vals[p - 1] > vals[p]) { \ b->tnosorted = p; \ TRC_DEBUG(ALGO, "Fixed nosorted(" BUNFMT ") for " ALGOBATFMT " (" LLFMT " usec)\n", p, ALGOBATPAR(b), GDKusec() - t0); \ @@ -1828,7 +1828,7 @@ BATslice(BAT *b, BUN l, BUN h) const TPE *restrict vals = Tloc(b, 0); \ TPE prev = vals[0]; \ bool prevnil = is_##TPE##_nil(prev); \ - for (BUN q = BUNlast(b), p = 1; p < q; p++) { \ + for (BUN q = BATcount(b), p = 1; p < q; p++) { \ TPE next = vals[p]; \ int cmp = prevnil ? -!(prevnil = is_##TPE##_nil(next)) : (prevnil = is_##TPE##_nil(next)) ? 1 : (prev > next) - (prev < next); \ prev = next; \ @@ -1897,7 +1897,7 @@ BATordered(BAT *b) BAT_ORDERED_FP(dbl); break; case TYPE_str: - for (BUN q = BUNlast(b), p = 1; p < q; p++) { + for (BUN q = BATcount(b), p = 1; p < q; p++) { int c; const char *p1 = BUNtail(bi, p - 1); const char *p2 = BUNtail(bi, p); @@ -1932,7 +1932,7 @@ BATordered(BAT *b) break; default: { int (*cmpf)(const void *, const void *) = ATOMcompare(b->ttype); - for (BUN q = BUNlast(b), p = 1; p < q; p++) { + for (BUN q = BATcount(b), p = 1; p < q; p++) { int c; if ((c = cmpf(BUNtail(bi, p - 1), BUNtail(bi, p))) > 0) { b->tnosorted = p; @@ -1976,7 +1976,7 @@ BATordered(BAT *b) #define BAT_REVORDERED(TPE) \ do { \ const TPE *restrict vals = Tloc(b, 0); \ - for (BUN q = BUNlast(b), p = 1; p < q; p++) { \ + for (BUN q = BATcount(b), p = 1; p < q; p++) { \ if (vals[p - 1] < vals[p]) { \ b->tnorevsorted = p; \ TRC_DEBUG(ALGO, "Fixed norevsorted(" BUNFMT ") for " ALGOBATFMT " (" LLFMT " usec)\n", p, ALGOBATPAR(b), GDKusec() - t0); \ @@ -1988,7 +1988,7 @@ BATordered(BAT *b) #define BAT_REVORDERED_FP(TPE) \ do { \ const TPE *restrict vals = Tloc(b, 0); \ - for (BUN q = BUNlast(b), p = 1; p < q; p++) { \ + for (BUN q = BATcount(b), p = 1; p < q; p++) { \ TPE prev = vals[p - 1], next = vals[p]; \ int cmp = is_flt_nil(prev) ? -!is_flt_nil(next) : is_flt_nil(next) ? 1 : (prev > next) - (prev < next); \ if (cmp < 0) { \ @@ -2045,7 +2045,7 @@ BATordered_rev(BAT *b) break; default: { int (*cmpf)(const void *, const void *) = ATOMcompare(b->ttype); - for (BUN q = BUNlast(b), p = 1; p < q; p++) { + for (BUN q = BATcount(b), p = 1; p < q; p++) { if (cmpf(BUNtail(bi, p - 1), BUNtail(bi, p)) < 0) { b->tnorevsorted = p; TRC_DEBUG(ALGO, "Fixed norevsorted(" BUNFMT ") for " ALGOBATFMT " (" LLFMT " usec)\n", p, ALGOBATPAR(b), GDKusec() - t0); _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org