Changeset: b2126763d6a3 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b2126763d6a3
Modified Files:
        clients/Tests/exports.stable.out
        gdk/gdk.h
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        gdk/gdk_bbp.c
        gdk/gdk_heap.c
Branch: default
Log Message:

Change functions that work on a COLrec into functions that work on a BAT.


diffs (truncated from 693 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
@@ -255,7 +255,7 @@ str GDKstrdup(const char *s) __attribute
 str GDKstrndup(const char *s, size_t n) 
__attribute__((__warn_unused_result__));
 void GDKsyserror(_In_z_ _Printf_format_string_ const char *format, ...) 
__attribute__((__format__(__printf__, 1, 2)));
 ThreadRec GDKthreads[THREADS];
-gdk_return GDKupgradevarheap(COLrec *c, var_t v, int copyall, int mayshare);
+gdk_return GDKupgradevarheap(BAT *b, var_t v, int copyall, int mayshare);
 lng GDKusec(void);
 BAT *GDKval;
 const char *GDKversion(void);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1119,7 +1119,7 @@ gdk_export bte ATOMelmshift(int sz);
                        if ((b)->twidth < SIZEOF_VAR_T &&               \
                            ((b)->twidth <= 2 ? _d - GDK_VAROFFSET : _d) >= 
((size_t) 1 << (8 * (b)->twidth))) { \
                                /* doesn't fit in current heap, upgrade it */ \
-                               if (GDKupgradevarheap((b)->T, _d, (copyall), 
(b)->batRestricted == BAT_READ) != GDK_SUCCEED) \
+                               if (GDKupgradevarheap((b), _d, (copyall), 
(b)->batRestricted == BAT_READ) != GDK_SUCCEED) \
                                        goto bunins_failed;             \
                        }                                               \
                        _ptr = (p);                                     \
@@ -1165,7 +1165,7 @@ gdk_export bte ATOMelmshift(int sz);
                        if ((b)->twidth < SIZEOF_VAR_T &&               \
                            ((b)->twidth <= 2 ? _d - GDK_VAROFFSET : _d) >= 
((size_t) 1 << (8 * (b)->twidth))) { \
                                /* doesn't fit in current heap, upgrade it */ \
-                               if (GDKupgradevarheap((b)->T, _d, 0, 
(b)->batRestricted == BAT_READ) != GDK_SUCCEED) \
+                               if (GDKupgradevarheap((b), _d, 0, 
(b)->batRestricted == BAT_READ) != GDK_SUCCEED) \
                                        goto bunins_failed;             \
                        }                                               \
                        _ptr = (p);                                     \
@@ -1197,7 +1197,7 @@ gdk_export bte ATOMelmshift(int sz);
                        if ((b)->twidth < SIZEOF_VAR_T &&               \
                            ((b)->twidth <= 2 ? _d - GDK_VAROFFSET : _d) >= 
((size_t) 1 << (8 * (b)->twidth))) { \
                                /* doesn't fit in current heap, upgrade it */ \
-                               if (GDKupgradevarheap((b)->T, _d, (copyall), 
(b)->batRestricted == BAT_READ) != GDK_SUCCEED) \
+                               if (GDKupgradevarheap((b), _d, (copyall), 
(b)->batRestricted == BAT_READ) != GDK_SUCCEED) \
                                        goto bunins_failed;             \
                        }                                               \
                        _ptr = (p);                                     \
@@ -1237,7 +1237,7 @@ gdk_export bte ATOMelmshift(int sz);
                        if ((b)->twidth < SIZEOF_VAR_T &&               \
                            ((b)->twidth <= 2 ? _d - GDK_VAROFFSET : _d) >= 
((size_t) 1 << (8 * (b)->twidth))) { \
                                /* doesn't fit in current heap, upgrade it */ \
-                               if (GDKupgradevarheap((b)->T, _d, 0, 
(b)->batRestricted == BAT_READ) != GDK_SUCCEED) \
+                               if (GDKupgradevarheap((b), _d, 0, 
(b)->batRestricted == BAT_READ) != GDK_SUCCEED) \
                                        goto bunins_failed;             \
                        }                                               \
                        _ptr = (p);                                     \
@@ -1290,7 +1290,7 @@ gdk_export bte ATOMelmshift(int sz);
                bunfastapp_nocheck(b, _p, t, Tsize(b));                 \
        } while (0)
 
-gdk_export gdk_return GDKupgradevarheap(COLrec *c, var_t v, int copyall, int 
mayshare);
+gdk_export gdk_return GDKupgradevarheap(BAT *b, var_t v, int copyall, int 
mayshare);
 gdk_export gdk_return BUNappend(BAT *b, const void *right, bit force);
 gdk_export gdk_return BATappend(BAT *b, BAT *c, bit force);
 
@@ -1590,62 +1590,58 @@ gdk_export void GDKqsort_rev(void *h, vo
 #define BATtkey(b)     (b->tkey != FALSE || BATtdense(b))
 
 /* set some properties that are trivial to deduce */
-#define COLsettrivprop(b, col)                                         \
-       do {                                                            \
-               if ((col)->type == TYPE_void) {                         \
-                       if ((col)->seq == oid_nil) {                    \
-                               (col)->nonil = (b)->batCount == 0;      \
-                               (col)->nil = !(col)->nonil;             \
-                               (col)->revsorted = 1;                   \
-                               (col)->key = (b)->batCount <= 1;        \
-                               (col)->dense = 0;                       \
-                       } else {                                        \
-                               (col)->dense = 1;                       \
-                               (col)->nonil = 1;                       \
-                               (col)->nil = 0;                         \
-                               (col)->key = 1;                         \
-                               (col)->revsorted = (b)->batCount <= 1;  \
-                       }                                               \
-                       (col)->sorted = 1;                              \
-               } else if ((b)->batCount <= 1) {                        \
-                       if (ATOMlinear((col)->type)) {                  \
-                               (col)->sorted = 1;                      \
-                               (col)->revsorted = 1;                   \
-                       }                                               \
-                       (col)->key = 1;                                 \
-                       if ((b)->batCount == 0) {                       \
-                               (col)->nonil = 1;                       \
-                               (col)->nil = 0;                         \
-                               if ((col)->type == TYPE_oid) {          \
-                                       (col)->dense = 1;               \
-                                       (col)->seq = 0;                 \
-                               }                                       \
-                       } else if ((col)->type == TYPE_oid) {           \
-                               /* b->batCount == 1 */                  \
-                               oid sqbs;                               \
-                               if ((sqbs = ((oid *) 
(col)->heap.base)[(b)->batFirst]) == oid_nil) { \
-                                       (col)->dense = 0;               \
-                                       (col)->nonil = 0;               \
-                                       (col)->nil = 1;                 \
-                               } else {                                \
-                                       (col)->dense = 1;               \
-                                       (col)->nonil = 1;               \
-                                       (col)->nil = 0;                 \
-                               }                                       \
-                               (col)->seq = sqbs;                      \
-                       }                                               \
-               }                                                       \
-               if (!ATOMlinear((col)->type)) {                         \
-                       (col)->sorted = 0;                              \
-                       (col)->revsorted = 0;                           \
-               }                                                       \
-       } while (0)
 #define BATsettrivprop(b)                                              \
        do {                                                            \
                assert((b)->hseqbase != oid_nil);                       \
                (b)->batDirtydesc = 1;  /* likely already set */        \
                /* the other head properties should already be correct */ \
-               COLsettrivprop((b), (b)->T);                            \
+               if ((b)->ttype == TYPE_void) {                          \
+                       if ((b)->tseqbase == oid_nil) {                 \
+                               (b)->tnonil = (b)->batCount == 0;       \
+                               (b)->tnil = !(b)->tnonil;               \
+                               (b)->trevsorted = 1;                    \
+                               (b)->tkey = (b)->batCount <= 1;         \
+                               (b)->tdense = 0;                        \
+                       } else {                                        \
+                               (b)->tdense = 1;                        \
+                               (b)->tnonil = 1;                        \
+                               (b)->tnil = 0;                          \
+                               (b)->tkey = 1;                          \
+                               (b)->trevsorted = (b)->batCount <= 1;   \
+                       }                                               \
+                       (b)->tsorted = 1;                               \
+               } else if ((b)->batCount <= 1) {                        \
+                       if (ATOMlinear((b)->ttype)) {                   \
+                               (b)->tsorted = 1;                       \
+                               (b)->trevsorted = 1;                    \
+                       }                                               \
+                       (b)->tkey = 1;                                  \
+                       if ((b)->batCount == 0) {                       \
+                               (b)->tnonil = 1;                        \
+                               (b)->tnil = 0;                          \
+                               if ((b)->ttype == TYPE_oid) {           \
+                                       (b)->tdense = 1;                \
+                                       (b)->tseqbase = 0;              \
+                               }                                       \
+                       } else if ((b)->ttype == TYPE_oid) {            \
+                               /* b->batCount == 1 */                  \
+                               oid sqbs;                               \
+                               if ((sqbs = ((oid *) 
(b)->theap.base)[(b)->batFirst]) == oid_nil) { \
+                                       (b)->tdense = 0;                \
+                                       (b)->tnonil = 0;                \
+                                       (b)->tnil = 1;                  \
+                               } else {                                \
+                                       (b)->tdense = 1;                \
+                                       (b)->tnonil = 1;                \
+                                       (b)->tnil = 0;                  \
+                               }                                       \
+                               (b)->tseqbase = sqbs;                   \
+                       }                                               \
+               }                                                       \
+               if (!ATOMlinear((b)->ttype)) {                          \
+                       (b)->tsorted = 0;                               \
+                       (b)->trevsorted = 0;                            \
+               }                                                       \
        } while (0)
 
 /*
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -832,96 +832,95 @@ COLcopy(BAT *b, int tt, int writable, in
        } while (0)
 
 static void
-setcolprops(BAT *b, COLrec *col, const void *x)
+setcolprops(BAT *b, const void *x)
 {
-       int isnil = col->type != TYPE_void &&
-               atom_CMP(x, ATOMnilptr(col->type), col->type) == 0;
+       int isnil = b->ttype != TYPE_void &&
+               atom_CMP(x, ATOMnilptr(b->ttype), b->ttype) == 0;
        BATiter bi;
        BUN pos;
        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);
+       assert(x != NULL || b->ttype == TYPE_void);
        if (b->batCount == 0) {
                /* first value */
-               col->sorted = col->revsorted = ATOMlinear(col->type) != 0;
-               col->nosorted = col->norevsorted = 0;
-               col->key |= 1;
-               col->nokey[0] = col->nokey[1] = 0;
-               col->nodense = 0;
-               if (col->type == TYPE_void) {
+               b->tsorted = b->trevsorted = ATOMlinear(b->ttype) != 0;
+               b->tnosorted = b->tnorevsorted = 0;
+               b->tkey |= 1;
+               b->tnokey[0] = b->tnokey[1] = 0;
+               b->tnodense = 0;
+               if (b->ttype == TYPE_void) {
                        if (x) {
-                               col->seq = * (const oid *) x;
+                               b->tseqbase = * (const oid *) x;
                        }
-                       col->nil = col->seq == oid_nil;
-                       col->nonil = !col->nil;
+                       b->tnil = b->tseqbase == oid_nil;
+                       b->tnonil = !b->tnil;
                } else {
-                       col->nil = isnil;
-                       col->nonil = !isnil;
-                       if (col->type == TYPE_oid) {
-                               col->dense = !isnil;
-                               col->seq = * (const oid *) x;
+                       b->tnil = isnil;
+                       b->tnonil = !isnil;
+                       if (b->ttype == TYPE_oid) {
+                               b->tdense = !isnil;
+                               b->tseqbase = * (const oid *) x;
                                if (isnil)
-                                       col->nodense = BUNlast(b);
+                                       b->tnodense = BUNlast(b);
                        }
                }
-       } else if (col->type == TYPE_void) {
+       } else if (b->ttype == TYPE_void) {
                /* not the first value in a VOID column: we keep the
                 * seqbase, and x is not used, so only some properties
                 * are affected */
-               if (col->seq != oid_nil) {
-                       if (col->revsorted) {
-                               col->norevsorted = BUNlast(b);
-                               col->revsorted = 0;
+               if (b->tseqbase != oid_nil) {
+                       if (b->trevsorted) {
+                               b->tnorevsorted = BUNlast(b);
+                               b->trevsorted = 0;
                        }
-                       col->nil = 0;
-                       col->nonil = 1;
+                       b->tnil = 0;
+                       b->tnonil = 1;
                } else {
-                       if (col->key) {
-                               col->nokey[0] = BUNfirst(b);
-                               col->nokey[1] = BUNlast(b);
-                               col->key = 0;
+                       if (b->tkey) {
+                               b->tnokey[0] = BUNfirst(b);
+                               b->tnokey[1] = BUNlast(b);
+                               b->tkey = 0;
                        }
-                       col->nil = 1;
-                       col->nonil = 0;
+                       b->tnil = 1;
+                       b->tnonil = 0;
                }
        } else {
                bi = bat_iterator(b);
                pos = BUNlast(b);
                prv = BUNtail(bi, pos - 1);
-               cmp = atom_CMP(prv, x, col->type);
+               cmp = atom_CMP(prv, x, b->ttype);
 
-               if (col->key == 1 && /* assume outside check if BOUND2BTRUE */
+               if (b->tkey == 1 && /* assume outside check if BOUND2BTRUE */
                    (cmp == 0 || /* definitely not KEY */
                     (b->batCount > 1 && /* can't guarantee KEY if unordered */
-                     ((col->sorted && cmp > 0) ||
-                      (col->revsorted && cmp < 0) ||
-                      (!col->sorted && !col->revsorted))))) {
-                       col->key = 0;
+                     ((b->tsorted && cmp > 0) ||
+                      (b->trevsorted && cmp < 0) ||
+                      (!b->tsorted && !b->trevsorted))))) {
+                       b->tkey = 0;
                        if (cmp == 0) {
-                               col->nokey[0] = pos - 1;
-                               col->nokey[1] = pos;
+                               b->tnokey[0] = pos - 1;
+                               b->tnokey[1] = pos;
                        }
                }
-               if (col->sorted && cmp > 0) {
+               if (b->tsorted && cmp > 0) {
                        /* out of order */
-                       col->sorted = 0;
-                       col->nosorted = pos;
+                       b->tsorted = 0;
+                       b->tnosorted = pos;
                }
-               if (col->revsorted && cmp < 0) {
+               if (b->trevsorted && cmp < 0) {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to