Changeset: 01a132cac840 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=01a132cac840
Modified Files:
        gdk/gdk_aggr.c
        gdk/gdk_atoms.c
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        gdk/gdk_calc.c
        gdk/gdk_firstn.c
        gdk/gdk_group.c
        gdk/gdk_imprints.c
        gdk/gdk_join.c
        gdk/gdk_private.h
        gdk/gdk_qsort.c
        gdk/gdk_search.c
        gdk/gdk_select.c
        gdk/gdk_setop.c
        gdk/gdk_ssort_impl.h
        gdk/gdk_unique.c
        monetdb5/modules/mal/batcalc.c
        monetdb5/modules/mal/mal_io.c
        monetdb5/modules/mal/manifold.c
        sql/backends/monet5/sql_result.c
Branch: Oct2014
Log Message:

Only use ATOMstorage when it is about storage, not when it is about values.
To help with this, we introduce a new macro ATOMbasetype in
gdk_private.h.  This macro will be moved to gdk_atoms.h in the default
branch.


diffs (truncated from 1206 to 300 lines):

diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -1073,7 +1073,7 @@ BATprod(void *res, int tp, BAT *b, BAT *
                GDKerror("BATprod: %s\n", err);
                return GDK_FAIL;
        }
-       switch (ATOMstorage(tp)) {
+       switch (tp) {
        case TYPE_bte:
                * (bte *) res = nil_if_empty ? bte_nil : (bte) 1;
                break;
@@ -1670,11 +1670,8 @@ BATgroupcount(BAT *b, BAT *g, BAT *e, BA
 
        t = b->T->type;
        nil = ATOMnilptr(t);
-       atomcmp = BATatoms[t].atomCmp;
-       if (t != ATOMstorage(t) &&
-           ATOMnilptr(ATOMstorage(t)) == nil &&
-           BATatoms[ATOMstorage(t)].atomCmp == atomcmp)
-               t = ATOMstorage(t);
+       atomcmp = ATOMcompare(t);
+       t = ATOMbasetype(t);
        switch (t) {
        case TYPE_bte:
                AGGR_COUNT(bte);
@@ -1900,11 +1897,8 @@ do_groupmin(oid *restrict oids, BAT *b, 
 
        t = b->T->type;
        nil = ATOMnilptr(t);
-       atomcmp = BATatoms[t].atomCmp;
-       if (t != ATOMstorage(t) &&
-           ATOMnilptr(ATOMstorage(t)) == nil &&
-           BATatoms[ATOMstorage(t)].atomCmp == atomcmp)
-               t = ATOMstorage(t);
+       atomcmp = ATOMcompare(t);
+       t = ATOMbasetype(t);
        switch (t) {
        case TYPE_bte:
                AGGR_CMP(bte, LT);
@@ -2024,11 +2018,8 @@ do_groupmax(oid *restrict oids, BAT *b, 
 
        t = b->T->type;
        nil = ATOMnilptr(t);
-       atomcmp = BATatoms[t].atomCmp;
-       if (t != ATOMstorage(t) &&
-           ATOMnilptr(ATOMstorage(t)) == nil &&
-           BATatoms[ATOMstorage(t)].atomCmp == atomcmp)
-               t = ATOMstorage(t);
+       atomcmp = ATOMcompare(t);
+       t = ATOMbasetype(t);
        switch (t) {
        case TYPE_bte:
                AGGR_CMP(bte, GT);
@@ -2381,7 +2372,7 @@ BATgroupquantile(BAT *b, BAT *g, BAT *e,
 
        bi = bat_iterator(b);
        nil = ATOMnilptr(b->ttype);
-       atomcmp = BATatoms[b->ttype].atomCmp;
+       atomcmp = ATOMcompare(b->ttype);
 
        if (g) { /* we have to do this by group */
                const oid *restrict grps;
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -268,10 +268,7 @@ ATOMheap(int t, Heap *hp, size_t cap)
 int
 ATOMcmp(int t, const void *l, const void *r)
 {
-       switch (t != ATOMstorage(t) &&
-               ATOMnilptr(t) == ATOMnilptr(ATOMstorage(t)) &&
-               ATOMcompare(t) == ATOMcompare(ATOMstorage(t)) ?
-               ATOMstorage(t) : t) {
+       switch (ATOMbasetype(t)) {
        case TYPE_bte:
                return simple_CMP(l, r, bte);
        case TYPE_sht:
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -905,7 +905,7 @@ BATcopy(BAT *b, int ht, int tt, int writ
                         * the heap as in the source */
                        bn->batFirst = b->batFirst;
                        bn->batInserted = b->batInserted;
-               } else if (BATatoms[ht].atomFix || BATatoms[tt].atomFix || (ht 
&& tt) || ATOMstorage(MAX(ht, tt)) >= TYPE_str) {
+               } else if (BATatoms[ht].atomFix || BATatoms[tt].atomFix || (ht 
&& tt) || ATOMextern(MAX(ht, tt))) {
                        /* case (4): one-by-one BUN insert (really slow) */
                        BUN p, q, r = BUNfirst(bn);
                        BATiter bi = bat_iterator(b);
@@ -952,7 +952,7 @@ BATcopy(BAT *b, int ht, int tt, int writ
        if (ATOMtype(ht) == ATOMtype(b->htype)) {
                ALIGNsetH(bn, b);
        } else if (ATOMstorage(ht) == ATOMstorage(b->htype) &&
-                  BATatoms[ht].atomCmp == BATatoms[b->htype].atomCmp) {
+                  ATOMcompare(ht) == ATOMcompare(b->htype)) {
                bn->hsorted = b->hsorted;
                bn->hrevsorted = b->hrevsorted;
                bn->hdense = b->hdense && ATOMtype(bn->htype) == TYPE_oid;
@@ -966,7 +966,7 @@ BATcopy(BAT *b, int ht, int tt, int writ
        if (ATOMtype(tt) == ATOMtype(b->ttype)) {
                ALIGNsetT(bn, b);
        } else if (ATOMstorage(tt) == ATOMstorage(b->ttype) &&
-                  BATatoms[tt].atomCmp == BATatoms[b->ttype].atomCmp) {
+                  ATOMcompare(tt) == ATOMcompare(b->ttype)) {
                bn->tsorted = b->tsorted;
                bn->trevsorted = b->trevsorted;
                bn->tdense = b->tdense && ATOMtype(bn->ttype) == TYPE_oid;
@@ -1768,7 +1768,7 @@ slowfnd(BAT *b, const void *v)
 {
        BATiter bi = bat_iterator(b);
        BUN p, q;
-       int (*cmp)(const void *, const void *) = BATatoms[b->htype].atomCmp;
+       int (*cmp)(const void *, const void *) = ATOMcompare(b->htype);
 
        BATloop(b, p, q) {
                if ((*cmp)(v, BUNhead(bi, p)) == 0)
@@ -1856,8 +1856,8 @@ BUNlocate(BAT *b, const void *x, const v
 
        BATcheck(b, "BUNlocate: BAT parameter required");
        BATcheck(x, "BUNlocate: value parameter required");
-       hcmp = BATatoms[b->htype].atomCmp;
-       tcmp = BATatoms[b->ttype].atomCmp;
+       hcmp = ATOMcompare(b->htype);
+       tcmp = ATOMcompare(b->ttype);
        p = BUNfirst(b);
        q = BUNlast(b);
        if (p == q)
@@ -1960,9 +1960,9 @@ BUNlocate(BAT *b, const void *x, const v
        }
 
        /* exploit string double elimination, when present */
-       htpe = ATOMstorage(b->htype);
-       ttpe = ATOMstorage(b->ttype);
-       if (htpe == TYPE_str && GDK_ELIMDOUBLES(b->H->vheap) && b->H->width > 
2) {
+       htpe = ATOMbasetype(b->htype);
+       ttpe = ATOMbasetype(b->ttype);
+       if (ATOMstorage(htpe) == TYPE_str && GDK_ELIMDOUBLES(b->H->vheap) && 
b->H->width > 2) {
                hidx.v = strLocate(b->H->vheap, x);
                if (hidx.v == 0)
                        return BUN_NONE;        /* x does not occur */
@@ -1981,7 +1981,7 @@ BUNlocate(BAT *b, const void *x, const v
                        }
                }
        }
-       if (ttpe == TYPE_str && GDK_ELIMDOUBLES(b->T->vheap) && b->T->width > 
2) {
+       if (ATOMstorage(ttpe) == TYPE_str && GDK_ELIMDOUBLES(b->T->vheap) && 
b->T->width > 2) {
                tidx.v = strLocate(b->T->vheap, y);
                if (tidx.v == 0)
                        return BUN_NONE;        /* y does not occur */
@@ -2042,7 +2042,7 @@ BUNlocate(BAT *b, const void *x, const v
 
        /* linear check; we get here for small ranges, [bte,bte] bats,
         * and hash alloc failure */
-       if (ATOMstorage(b->htype) == TYPE_bte && ATOMstorage(b->ttype) == 
TYPE_bte) {
+       if (htpe == TYPE_bte && ttpe == TYPE_bte) {
                for (; p < q; p++)
                        if (*(bte *) BUNhloc(bi, p) == *(bte *) x &&
                            *(bte *) BUNtloc(bi, p) == *(bte *) y)
@@ -2797,7 +2797,7 @@ BATassertHeadProps(BAT *b)
               b->H->vheap == NULL ||
               (BBPfarms[b->H->vheap->farmid].roles & (1 << b->batRole)));
 
-       cmpf = BATatoms[b->htype].atomCmp;
+       cmpf = ATOMcompare(b->htype);
        nilp = ATOMnilptr(b->htype);
        p = BUNfirst(b);
        q = BUNlast(b);
@@ -3056,7 +3056,7 @@ BATderiveHeadProps(BAT *b, int expensive
                return;
        assert((b->hkey & BOUND2BTRUE) == 0);
        COLsettrivprop(b, b->H);
-       cmpf = BATatoms[b->htype].atomCmp;
+       cmpf = ATOMcompare(b->htype);
        nilp = ATOMnilptr(b->htype);
        b->batDirtydesc = 1;    /* we will be changing things */
        if (b->htype == TYPE_void || b->batCount <= 1) {
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -2016,11 +2016,7 @@ BATcount_no_nil(BAT *b)
        if (b->T->nonil)
                return n;
        p = Tloc(b, b->batFirst);
-       t = b->ttype;
-       if (t != ATOMstorage(t) &&
-           ATOMnilptr(ATOMstorage(t)) == ATOMnilptr(t) &&
-           BATatoms[ATOMstorage(t)].atomCmp == BATatoms[t].atomCmp)
-               t = ATOMstorage(t);
+       t = ATOMbasetype(b->ttype);
        switch (t) {
        case TYPE_void:
                cnt = b->tseqbase == oid_nil ? 0 : n;
@@ -2074,7 +2070,7 @@ BATcount_no_nil(BAT *b)
                break;
        default:
                nil = ATOMnilptr(t);
-               cmp = BATatoms[t].atomCmp;
+               cmp = ATOMcompare(t);
                if (b->tvarsized) {
                        base = b->T->vheap->base;
                        for (i = 0; i < n; i++)
diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -45,14 +45,6 @@
 #define FMTdbl "%.17g"
 #define FMToid OIDFMT
 
-/* The base type is the storage type if the comparison function and
- * nil values are the same as those of the storage type; otherwise it
- * is the type itself. */
-#define BASETYPE(t)    ((t) != ATOMstorage(t) &&                       \
-                        ATOMnilptr(t) == ATOMnilptr(ATOMstorage(t)) && \
-                        ATOMcompare(t) == ATOMcompare(ATOMstorage(t)) ? \
-                        ATOMstorage(t) : (t))
-
 /* Most of the internal routines return a count of the number of NIL
  * values they produced.  They indicate an error by returning a value
  * >= BUN_NONE.  BUN_NONE means that the error was dealt with by
@@ -203,7 +195,7 @@ BATcalcnot(BAT *b, BAT *s)
        if (bn == NULL)
                return NULL;
 
-       switch (BASETYPE(b->T->type)) {
+       switch (ATOMbasetype(b->T->type)) {
        case TYPE_bte:
                if (b->T->type == TYPE_bit) {
                        UNARY_2TYPE_FUNC(bit, bit, NOTBIT);
@@ -253,7 +245,7 @@ int
 VARcalcnot(ValPtr ret, const ValRecord *v)
 {
        ret->vtype = v->vtype;
-       switch (BASETYPE(v->vtype)) {
+       switch (ATOMbasetype(v->vtype)) {
        case TYPE_bte:
                if (v->val.btval == bit_nil)
                        ret->val.btval = bit_nil;
@@ -310,7 +302,7 @@ BATcalcnegate(BAT *b, BAT *s)
        if (bn == NULL)
                return NULL;
 
-       switch (BASETYPE(b->T->type)) {
+       switch (ATOMbasetype(b->T->type)) {
        case TYPE_bte:
                UNARY_2TYPE_FUNC(bte, bte, NEGATE);
                break;
@@ -362,7 +354,7 @@ int
 VARcalcnegate(ValPtr ret, const ValRecord *v)
 {
        ret->vtype = v->vtype;
-       switch (BASETYPE(v->vtype)) {
+       switch (ATOMbasetype(v->vtype)) {
        case TYPE_bte:
                if (v->val.btval == bte_nil)
                        ret->val.btval = bte_nil;
@@ -427,7 +419,7 @@ BATcalcabsolute(BAT *b, BAT *s)
        if (bn == NULL)
                return NULL;
 
-       switch (BASETYPE(b->T->type)) {
+       switch (ATOMbasetype(b->T->type)) {
        case TYPE_bte:
                UNARY_2TYPE_FUNC(bte, bte, (bte) abs);
                break;
@@ -481,7 +473,7 @@ int
 VARcalcabsolute(ValPtr ret, const ValRecord *v)
 {
        ret->vtype = v->vtype;
-       switch (BASETYPE(v->vtype)) {
+       switch (ATOMbasetype(v->vtype)) {
        case TYPE_bte:
                if (v->val.btval == bte_nil)
                        ret->val.btval = bte_nil;
@@ -548,7 +540,7 @@ BATcalciszero(BAT *b, BAT *s)
        if (bn == NULL)
                return NULL;
 
-       switch (BASETYPE(b->T->type)) {
+       switch (ATOMbasetype(b->T->type)) {
        case TYPE_bte:
                UNARY_2TYPE_FUNC(bte, bit, ISZERO);
                break;
@@ -599,7 +591,7 @@ int
 VARcalciszero(ValPtr ret, const ValRecord *v)
 {
        ret->vtype = TYPE_bit;
-       switch (BASETYPE(v->vtype)) {
+       switch (ATOMbasetype(v->vtype)) {
        case TYPE_bte:
                if (v->val.btval == bte_nil)
                        ret->val.btval = bit_nil;
@@ -667,7 +659,7 @@ BATcalcsign(BAT *b, BAT *s)
        if (bn == NULL)
                return NULL;
 
-       switch (BASETYPE(b->T->type)) {
+       switch (ATOMbasetype(b->T->type)) {
        case TYPE_bte:
                UNARY_2TYPE_FUNC(bte, bte, SIGN);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to