Changeset: fa6ae4ab9c7c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fa6ae4ab9c7c
Modified Files:
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        gdk/gdk_bbp.c
        gdk/gdk_delta.c
        gdk/gdk_logger.c
        gdk/gdk_private.h
        monetdb5/modules/mal/tablet.c
        monetdb5/optimizer/opt_statistics.c
Branch: default
Log Message:

Cleanup and simplicy: head columns are (almost invariably) VOID.
(There is one case where they may not be, indicated by the LEGACY
comment in gdk_logger.c.)


diffs (truncated from 459 to 300 lines):

diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -775,10 +775,9 @@ COLcopy(BAT *b, int tt, int writable, in
                        BATiter bi = bat_iterator(b);
 
                        BATloop(b, p, q) {
-                               const void *h = BUNhead(bi, p);
                                const void *t = BUNtail(bi, p);
 
-                               bunfastins_nocheck(bn, r, h, t, Hsize(bn), 
Tsize(bn));
+                               bunfastapp_nocheck(bn, r, t, Tsize(bn));
                                r++;
                        }
                } else if (tt != TYPE_void && b->ttype == TYPE_void) {
@@ -913,6 +912,7 @@ setcolprops(BAT *b, COLrec *col, const v
        const void *prv;
        int cmp;
 
+       assert(col == b->T);
        /* x may only be NULL if the column type is VOID */
        assert(x != NULL || col->type == TYPE_void);
        if (b->batCount == 0) {
@@ -961,7 +961,7 @@ setcolprops(BAT *b, COLrec *col, const v
        } else {
                bi = bat_iterator(b);
                pos = BUNlast(b);
-               prv = col == b->H ? BUNhead(bi, pos - 1) : BUNtail(bi, pos - 1);
+               prv = BUNtail(bi, pos - 1);
                cmp = atom_CMP(prv, x, col->type);
 
                if (col->key == 1 && /* assume outside check if BOUND2BTRUE */
@@ -997,27 +997,6 @@ setcolprops(BAT *b, COLrec *col, const v
        }
 }
 
-oid
-MAXoid(BAT *i)
-{
-       BATiter ii = bat_iterator(i);
-       oid o = i->hseqbase - 1;
-
-       if (i->batCount)
-               o = *(oid *) BUNhead(ii, BUNlast(i) - 1);
-       if (!BAThordered(i)) {
-               BUN r, s;
-
-               BATloop(i, r, s) {
-                       oid v = *(oid *) BUNhead(ii, r);
-
-                       if (v > o)
-                               o = v;
-               }
-       }
-       return o;
-}
-
 /*
  * @+ BUNappend
  * The BUNappend function can be used to add a single value to void
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -54,14 +54,14 @@ unshare_string_heap(BAT *b)
  * of inserting individual strings.  See the comments in the code for
  * more information. */
 static gdk_return
-insert_string_bat(BAT *b, BAT *n, int append, int force)
+insert_string_bat(BAT *b, BAT *n, int force)
 {
        BATiter ni;             /* iterator */
        int tt;                 /* tail type */
        size_t toff = ~(size_t) 0;      /* tail offset */
        BUN p, q;               /* loop variables */
        oid o = 0;              /* in case we're appending */
-       const void *hp, *tp;    /* head and tail value pointers */
+       const void *tp;         /* tail value pointer */
        unsigned char tbv;      /* tail value-as-bte */
        unsigned short tsv;     /* tail value-as-sht */
 #if SIZEOF_VAR_T == 8
@@ -70,16 +70,13 @@ insert_string_bat(BAT *b, BAT *n, int ap
        var_t v;                /* value */
        size_t off;             /* offset within n's string heap */
 
-       assert(b->htype == TYPE_void || b->htype == TYPE_oid);
+       assert(BAThdense(b));
+       assert(b->htype == TYPE_void);
+       assert(BAThdense(n));
        if (n->batCount == 0)
                return GDK_SUCCEED;
        ni = bat_iterator(n);
-       hp = NULL;
        tp = NULL;
-       if (append && b->htype != TYPE_void) {
-               hp = &o;
-               o = MAXoid(b);
-       }
        tt = b->ttype;
        if (tt == TYPE_str &&
            (!GDK_ELIMDOUBLES(b->T->vheap) || b->batCount == 0) &&
@@ -209,28 +206,12 @@ insert_string_bat(BAT *b, BAT *n, int ap
                        b->ttype = tt;
                }
        }
-       if (!append) {
-               if (b->htype == TYPE_void)
-                       hp = NULL;
-               else if (n->htype == TYPE_void) {
-                       assert(b->htype == TYPE_oid);
-                       o = n->hseqbase;
-                       hp = &o;
-                       append = 1;
-               }
-       }
-       if (toff == 0 && n->T->width == b->T->width && (b->htype == TYPE_void 
|| !append)) {
+       if (toff == 0 && n->T->width == b->T->width) {
                /* we don't need to do any translation of offset
                 * values, nor do we need to do any calculations for
                 * the head column, so we can use fast memcpy */
                memcpy(Tloc(b, BUNlast(b)), Tloc(n, BUNfirst(n)),
                       BATcount(n) * n->T->width);
-               if (b->htype != TYPE_void) {
-                       assert(n->htype == b->htype);
-                       assert(!append);
-                       memcpy(Hloc(b, BUNlast(b)), Hloc(n, BUNfirst(n)),
-                              BATcount(n) * Hsize(n));
-               }
                BATsetcount(b, BATcount(b) + BATcount(n));
        } else if (toff != ~(size_t) 0) {
                /* we don't need to insert any actual strings since we
@@ -251,9 +232,6 @@ insert_string_bat(BAT *b, BAT *n, int ap
                const var_t *restrict tvp = (const var_t *) Tloc(n, 
BUNfirst(n));
 
                BATloop(n, p, q) {
-                       if (!append && b->htype)
-                               hp = BUNhloc(ni, p);
-
                        switch (n->T->width) {
                        case 1:
                                v = (var_t) *tbp++ + GDK_VAROFFSET;
@@ -291,7 +269,7 @@ insert_string_bat(BAT *b, BAT *n, int ap
                        default:
                                break;
                        }
-                       bunfastins(b, hp, tp);
+                       bunfastapp(b, tp);
                        o++;
                }
        } else {
@@ -302,9 +280,6 @@ insert_string_bat(BAT *b, BAT *n, int ap
                 * n's).  If this is the case, we just copy the
                 * offset, otherwise we insert normally.  */
                BATloop(n, p, q) {
-                       if (!append && b->htype)
-                               hp = BUNhloc(ni, p);
-
                        off = BUNtvaroff(ni, p); /* the offset */
                        tp = n->T->vheap->base + off; /* the string */
                        if (off < b->T->vheap->free &&
@@ -316,8 +291,6 @@ insert_string_bat(BAT *b, BAT *n, int ap
                                 * in n's string heap, so we don't
                                 * have to insert a new string into b:
                                 * we can just copy the offset */
-                               if (b->H->type)
-                                       *(oid *) Hloc(b, BUNlast(b)) = *(oid *) 
hp;
                                v = (var_t) (off >> GDK_VARSHIFT);
                                if (b->T->width < SIZEOF_VAR_T &&
                                    ((size_t) 1 << 8 * b->T->width) <= 
(b->T->width <= 2 ? v - GDK_VAROFFSET : v)) {
@@ -352,7 +325,7 @@ insert_string_bat(BAT *b, BAT *n, int ap
                                }
                                b->batCount++;
                        } else {
-                               bunfastins(b, hp, tp);
+                               bunfastapp(b, tp);
                        }
                        o++;
                }
@@ -494,7 +467,7 @@ BATappend(BAT *b, BAT *n, bit force)
                    (b->batCount == 0 || !GDK_ELIMDOUBLES(b->T->vheap)) &&
                    !GDK_ELIMDOUBLES(n->T->vheap) &&
                    b->T->vheap->hashash == n->T->vheap->hashash) {
-                       if (insert_string_bat(b, n, 1, force) != GDK_SUCCEED)
+                       if (insert_string_bat(b, n, force) != GDK_SUCCEED)
                                return GDK_FAIL;
                } else {
                        if (!ATOMvarsized(b->ttype) &&
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -2880,20 +2880,12 @@ BBPdestroy(BAT *b)
                VIEWdestroy(b);
        } else {
                /* bats that get destroyed must unfix their atoms */
-               int (*hunfix) (const void *) = BATatoms[b->htype].atomUnfix;
                int (*tunfix) (const void *) = BATatoms[b->ttype].atomUnfix;
                BUN p, q;
                BATiter bi = bat_iterator(b);
 
                assert(b->batSharecnt == 0);
-               if (hunfix) {
-                       DELloop(b, p, q) {
-                               (*hunfix) (BUNhead(bi, p));
-                       }
-                       BATloop(b, p, q) {
-                               (*hunfix) (BUNhead(bi, p));
-                       }
-               }
+               assert(BATatoms[b->htype].atomUnfix == NULL);
                if (tunfix) {
                        DELloop(b, p, q) {
                                (*tunfix) (BUNtail(bi, p));
diff --git a/gdk/gdk_delta.c b/gdk/gdk_delta.c
--- a/gdk/gdk_delta.c
+++ b/gdk/gdk_delta.c
@@ -47,23 +47,16 @@ BATcommit(BAT *b)
        ALIGNcommit(b);
        if (b->batDeleted < b->batFirst && BBP_cache(b->batCacheid)) {
                BATiter bi = bat_iterator(b);
-               int (*hunfix) (const void *) = BATatoms[b->htype].atomUnfix;
                int (*tunfix) (const void *) = BATatoms[b->ttype].atomUnfix;
-               void (*hatmdel) (Heap *, var_t *) = BATatoms[b->htype].atomDel;
                void (*tatmdel) (Heap *, var_t *) = BATatoms[b->ttype].atomDel;
                BUN p, q;
 
-               if (hatmdel || hunfix || tatmdel || tunfix) {
+               assert(BATatoms[b->htype].atomUnfix == NULL);
+               assert(BATatoms[b->htype].atomDel == NULL);
+               if (tatmdel || tunfix) {
                        DELloop(b, p, q) {
-                               ptr h = BUNhead(bi, p);
                                ptr t = BUNtail(bi, p);
 
-                               if (hunfix) {
-                                       (*hunfix) (h);
-                               }
-                               if (hatmdel) {
-                                       (*hatmdel) (b->H->vheap, (var_t *) 
BUNhloc(bi, p));
-                               }
                                if (tunfix) {
                                        (*tunfix) (t);
                                }
@@ -139,23 +132,17 @@ BATundo(BAT *b)
        bunlast = BUNlast(b) - 1;
        if (bunlast >= b->batInserted) {
                BUN i = bunfirst;
-               int (*hunfix) (const void *) = BATatoms[b->htype].atomUnfix;
                int (*tunfix) (const void *) = BATatoms[b->ttype].atomUnfix;
-               void (*hatmdel) (Heap *, var_t *) = BATatoms[b->htype].atomDel;
                void (*tatmdel) (Heap *, var_t *) = BATatoms[b->ttype].atomDel;
 
-               if (hunfix || tunfix || hatmdel || tatmdel || b->H->hash || 
b->T->hash) {
+               assert(BATatoms[b->htype].atomUnfix == NULL);
+               assert(BATatoms[b->htype].atomDel == NULL);
+               assert(b->H->hash == NULL);
+               if (tunfix || tatmdel || b->T->hash) {
                        HASHdestroy(b);
                        for (p = bunfirst; p <= bunlast; p++, i++) {
-                               ptr h = BUNhead(bi, p);
                                ptr t = BUNtail(bi, p);
 
-                               if (hunfix) {
-                                       (*hunfix) (h);
-                               }
-                               if (hatmdel) {
-                                       (*hatmdel) (b->H->vheap, (var_t *) 
BUNhloc(bi, p));
-                               }
                                if (tunfix) {
                                        (*tunfix) (t);
                                }
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -1506,6 +1506,7 @@ logger_load(int debug, const char* fn, c
                        BBPincref(d->batCacheid, TRUE);
                        if (BBPrename(d->batCacheid, bak) < 0)
                                logger_fatal("logger_load: BBPrename to %s 
failed", bak, 0, 0);
+/* LEGACY */
                        if (!BAThdense(b) || !BAThdense(n)) {
                                /* we need to convert catalog_bid and
                                 * catalog_nme to be dense-headed; we
@@ -1513,7 +1514,6 @@ logger_load(int debug, const char* fn, c
                                 * new, dense versions */
                                BATiter bi, ni;
                                BUN r;
-                               const oid *o;
                                BAT *b2, *n2;
                                bat list[5];
 
@@ -1531,8 +1531,8 @@ logger_load(int debug, const char* fn, c
                                bi = bat_iterator(b);
                                ni = bat_iterator(n);
                                BATloop(b, p, q) {
-                                       o = (const oid *) BUNhloc(bi, p);
-                                       r = BUNfnd(BATmirror(n), o);
+                                       oid o = ((const oid *) 
b->H->heap.base)[p];
+                                       r = BUNfnd(BATmirror(n), &o);
                                        if (r != BUN_NONE) {
                                                if (BUNappend(b2, BUNtloc(bi, 
p), 0) != GDK_SUCCEED ||
                                                    BUNappend(n2, BUNtvar(ni, 
r), 0) != GDK_SUCCEED)
@@ -2478,6 +2478,7 @@ log_bat(logger *lg, BAT *b, const char *
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to