Changeset: 1e99b6f514fd for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1e99b6f514fd Modified Files: clients/Tests/exports.stable.out gdk/ChangeLog gdk/gdk.h gdk/gdk_bat.c gdk/gdk_batop.c gdk/gdk_logger.c gdk/gdk_private.h monetdb5/modules/kernel/bat5.c Branch: default Log Message:
Cleanup: unexport BUNreplace and change its interface. Note, there's also BUNinplace and void_inplace. diffs (218 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 @@ -201,7 +201,6 @@ void BBPunlock(const char *s); gdk_return BUNappend(BAT *b, const void *right, bit force); BUN BUNfnd(BAT *b, const void *right); gdk_return BUNinplace(BAT *b, BUN p, const void *right, bit force); -gdk_return BUNreplace(BAT *b, const void *left, const void *right, bit force); BAT *COLcopy(BAT *b, int tt, int writeable, int role); size_t GDK_mem_maxsize; size_t GDK_vm_maxsize; diff --git a/gdk/ChangeLog b/gdk/ChangeLog --- a/gdk/ChangeLog +++ b/gdk/ChangeLog @@ -1,6 +1,11 @@ # ChangeLog file for MonetDB # This file is updated with Maddlog +* Fri Dec 18 2015 Sjoerd Mullender <sjo...@acm.org> +- Removed BUNreplace from list of exported functions. It wasn't used, + and there is still BUNinplace and void_inplace that do more-or-less + the same thing. + * Thu Dec 17 2015 Sjoerd Mullender <sjo...@acm.org> - Changed BATderiveHeadProps to BATderiveTailProps (and it now works on the tail column). diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -1079,7 +1079,7 @@ gdk_export bte ATOMelmshift(int sz); * @item BAT* * @tab BUNappend (BAT *b, ptr right, bit force) * @item BAT* - * @tab BUNreplace (BAT *b, ptr left, ptr right, bit force) + * @tab BUNreplace (BAT *b, oid left, ptr right, bit force) * @item int * @tab BUNfnd (BAT *b, ptr tail) * @item BUN @@ -1258,7 +1258,6 @@ gdk_export gdk_return GDKupgradevarheap( gdk_export gdk_return BUNappend(BAT *b, const void *right, bit force); gdk_export gdk_return BATappend(BAT *b, BAT *c, bit force); -gdk_export gdk_return BUNreplace(BAT *b, const void *left, const void *right, bit force); gdk_export gdk_return BUNinplace(BAT *b, BUN p, const void *right, bit force); gdk_export gdk_return BATreplace(BAT *b, BAT *p, BAT *n, bit force); diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -1062,7 +1062,7 @@ BUNinplace(BAT *b, BUN p, const void *t, /* uncommitted BUN elements */ - ALIGNinp(b, "BUNreplace", force, GDK_FAIL); /* zap alignment info */ + ALIGNinp(b, "BUNinplace", force, GDK_FAIL); /* zap alignment info */ if (b->T->nil && atom_CMP(BUNtail(bi, p), ATOMnilptr(b->ttype), b->ttype) == 0 && atom_CMP(t, ATOMnilptr(b->ttype), b->ttype) != 0) { @@ -1122,57 +1122,47 @@ BUNinplace(BAT *b, BUN p, const void *t, return GDK_FAIL; } +/* very much like void_inplace, except this materializes a void tail + * column if necessarry */ gdk_return -BUNreplace(BAT *b, const void *h, const void *t, bit force) +BUNreplace(BAT *b, oid id, const void *t, bit force) { - BUN p; - BATcheck(b, "BUNreplace", GDK_FAIL); - BATcheck(h, "BUNreplace: head value is nil", GDK_FAIL); BATcheck(t, "BUNreplace: tail value is nil", GDK_FAIL); - if ((p = BUNfnd(BATmirror(b), h)) == BUN_NONE) + if (id < b->hseqbase || id >= b->hseqbase + BATcount(b)) return GDK_SUCCEED; if ((b->tkey & BOUND2BTRUE) && BUNfnd(b, t) != BUN_NONE) { return GDK_SUCCEED; } if (b->ttype == TYPE_void) { - BUN i; - /* no need to materialize if value doesn't change */ - if (b->tseqbase == oid_nil || (b->hseqbase + p) == *(oid *) t) + if (b->tseqbase == oid_nil || + b->tseqbase + id - b->hseqbase == *(const oid *) t) return GDK_SUCCEED; - i = p; if (BATmaterialize(b) != GDK_SUCCEED) return GDK_FAIL; - p = i; } - return BUNinplace(b, p, t, force); + return BUNinplace(b, id - b->hseqbase + BUNfirst(b), t, force); } +/* very much like BUNreplace, but this doesn't make any changes if the + * tail column is void */ gdk_return void_inplace(BAT *b, oid id, const void *val, bit force) { - gdk_return res = GDK_SUCCEED; - BUN p = BUN_NONE; - BUN oldInserted = b->batInserted; - BAT *bm = BATmirror(b); - - assert(b->htype == TYPE_void); - assert(b->hseqbase != oid_nil); - assert(b->batCount > (id - b->hseqbase)); - - b->batInserted = 0; - p = BUNfndVOID(bm, &id); - - assert(force || p >= b->batInserted); /* we don't want delete/ins */ - assert(force || !b->batRestricted); - res = BUNinplace(b, p, val, force); - - b->batInserted = oldInserted; - return res; + assert(id >= b->hseqbase && id < b->hseqbase + BATcount(b)); + if (id < b->hseqbase || id >= b->hseqbase + BATcount(b)) { + GDKerror("void_inplace: id out of range\n"); + return GDK_FAIL; + } + if ((b->tkey & BOUND2BTRUE) && BUNfnd(b, val) != BUN_NONE) + return GDK_SUCCEED; + if (b->ttype == TYPE_void) + return GDK_SUCCEED; + return BUNinplace(b, id - b->hseqbase + BUNfirst(b), val, force); } BUN diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -583,7 +583,6 @@ BATappend(BAT *b, BAT *n, bit force) * The last in this series is a BATreplace, which replaces all the * buns mentioned. */ -#define BUNreplace_force(a,b,c) BUNreplace(a,b,c,force) gdk_return BATreplace(BAT *b, BAT *p, BAT *n, bit force) { diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c --- a/gdk/gdk_logger.c +++ b/gdk/gdk_logger.c @@ -467,21 +467,21 @@ la_bat_updates(logger *lg, logaction *la BUN p, q; BATloop(la->b, p, q) { - const void *h = BUNtail(ii, p); + oid h = * (const oid *) BUNtail(ii, p); const void *t = BUNtail(vi, p); assert(b->htype == TYPE_void); - if (BUNfnd(BATmirror(b), h) == BUN_NONE) { + if (h < b->hseqbase || h >= b->hseqbase + BATcount(b)) { /* if value doesn't exist, - * insert it if b void headed, + * insert it; if b void headed, * maintain that by inserting * nils */ - if (b->batCount == 0 && *(const oid *) h != oid_nil) - b->hseqbase = *(const oid *) h; - if (b->hseqbase != oid_nil && *(const oid *) h != oid_nil) { + if (b->batCount == 0 && h != oid_nil) + b->hseqbase = h; + if (b->hseqbase != oid_nil && h != oid_nil) { const void *tv = ATOMnilptr(b->ttype); - while (b->hseqbase + b->batCount < *(const oid *) h) + while (b->hseqbase + b->batCount < h) BUNappend(b, tv, TRUE); } BUNappend(b, t, TRUE); @@ -2369,7 +2369,7 @@ log_delta(logger *lg, BAT *uid, BAT *uva logformat l; BUN p; - assert(uid->ttype == TYPE_oid || !uid->ttype); + assert(uid->ttype == TYPE_oid || uid->ttype == TYPE_void); if (lg->debug & 128) { /* logging is switched off */ return LOG_OK; diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h --- a/gdk/gdk_private.h +++ b/gdk/gdk_private.h @@ -94,6 +94,8 @@ void BBPdump(void); /* never called: fo __attribute__((__visibility__("hidden"))); __hidden void BBPunshare(bat b) __attribute__((__visibility__("hidden"))); +__hidden gdk_return BUNreplace(BAT *b, oid left, const void *right, bit force) + __attribute__((__visibility__("hidden"))); __hidden void GDKclrerr(void) __attribute__((__visibility__("hidden"))); __hidden gdk_return GDKextend(const char *fn, size_t size) diff --git a/monetdb5/modules/kernel/bat5.c b/monetdb5/modules/kernel/bat5.c --- a/monetdb5/modules/kernel/bat5.c +++ b/monetdb5/modules/kernel/bat5.c @@ -383,7 +383,6 @@ BKCbun_inplace(bat *r, const bat *bid, c { BAT *b; - (void) r; if ((b = BATdescriptor(*bid)) == NULL) throw(MAL, "bat.inplace", RUNTIME_OBJECT_MISSING); if (void_inplace(b, *id, t, FALSE) != GDK_SUCCEED) { @@ -399,7 +398,6 @@ BKCbun_inplace_force(bat *r, const bat * { BAT *b; - (void) r; if ((b = BATdescriptor(*bid)) == NULL) throw(MAL, "bat.inplace", RUNTIME_OBJECT_MISSING); if (void_inplace(b, *id, t, *force) != GDK_SUCCEED) { _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list