Changeset: 9826ae03c66f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9826ae03c66f
Modified Files:
        gdk/gdk.h
        gdk/gdk_atoms.c
        gdk/gdk_atoms.h
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        gdk/gdk_bbp.c
        gdk/gdk_calc.c
        gdk/gdk_calc_compare.h
        gdk/gdk_join.c
        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
        gdk/gdk_value.c
        monetdb5/mal/mal_atom.c
        monetdb5/mal/mal_instruction.c
        monetdb5/mal/mal_recycle.c
        monetdb5/modules/mal/inspect.c
        monetdb5/modules/mal/manifold.c
        monetdb5/modules/mal/mat.c
        monetdb5/modules/mal/mkey.c
        monetdb5/optimizer/opt_support.c
        sql/backends/monet5/sql.c
Branch: default
Log Message:

Use access macros for BATatoms fields.


diffs (truncated from 652 to 300 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1680,7 +1680,7 @@ gdk_export void GDKqsort_rev(void *h, vo
                        }                                               \
                        (col)->sorted = 1;                              \
                } else if ((b)->batCount <= 1) {                        \
-                       if (BATatoms[(col)->type].linear) {             \
+                       if (ATOMlinear((col)->type)) {                  \
                                (col)->sorted = 1;                      \
                                (col)->revsorted = 1;                   \
                        }                                               \
@@ -1707,7 +1707,7 @@ gdk_export void GDKqsort_rev(void *h, vo
                                (col)->seq = sqbs;                      \
                        }                                               \
                }                                                       \
-               if (!BATatoms[(col)->type].linear) {                    \
+               if (!ATOMlinear((col)->type)) {                         \
                        (col)->sorted = 0;                              \
                        (col)->revsorted = 0;                           \
                }                                                       \
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -218,7 +218,7 @@ ATOMisdescendant(int tpe, int parent)
                cur = tpe;
                if (cur == parent)
                        return TRUE;
-               tpe = BATatoms[tpe].storage;
+               tpe = ATOMstorage(tpe);
        }
        return FALSE;
 }
diff --git a/gdk/gdk_atoms.h b/gdk/gdk_atoms.h
--- a/gdk/gdk_atoms.h
+++ b/gdk/gdk_atoms.h
@@ -25,15 +25,15 @@
 #define simple_GT(x,y,tpe)     ((*(const tpe*) (x))  > (*(const tpe*) (y)))
 #define simple_LE(x,y,tpe)     ((*(const tpe*) (x)) <= (*(const tpe*) (y)))
 #define simple_GE(x,y,tpe)     ((*(const tpe*) (x)) >= (*(const tpe*) (y)))
-#define atom_CMP(x,y,id)       (*BATatoms[id].atomCmp)(x,y)
-#define atom_EQ(x,y,id)                ((*BATatoms[id].atomCmp)(x,y) == 0)
-#define atom_NE(x,y,id,nl)     
((*BATatoms[id].atomCmp)(y,BATatoms[id].atomNull) != 0 && 
(*BATatoms[id].atomCmp)(x,y) != 0)
-#define atom_LT(x,y,id)                ((*BATatoms[id].atomCmp)(x,y) < 0)
-#define atom_GT(x,y,id)                ((*BATatoms[id].atomCmp)(x,y) > 0)
-#define atom_LE(x,y,id)                ((*BATatoms[id].atomCmp)(x,y) <= 0)
-#define atom_GE(x,y,id)                ((*BATatoms[id].atomCmp)(x,y) >= 0)
+#define atom_CMP(x,y,id)       (*ATOMcompare(id))(x,y)
+#define atom_EQ(x,y,id)                ((*ATOMcompare(id))(x,y) == 0)
+#define atom_NE(x,y,id,nl)     ((*ATOMcompare(id))(y,ATOMnilptr(id)) != 0 && 
(*ATOMcompare(id))(x,y) != 0)
+#define atom_LT(x,y,id)                ((*ATOMcompare(id))(x,y) < 0)
+#define atom_GT(x,y,id)                ((*ATOMcompare(id))(x,y) > 0)
+#define atom_LE(x,y,id)                ((*ATOMcompare(id))(x,y) <= 0)
+#define atom_GE(x,y,id)                ((*ATOMcompare(id))(x,y) >= 0)
 #define simple_HASH(v,tpe,dst) ((dst) *(const tpe *) (v))
-#define atom_HASH(v,id,dst)    ((dst) (*BATatoms[id].atomHash)(v))
+#define atom_HASH(v,id,dst)    ((dst) ATOMhash(id, v))
 
 /*
  * @- maximum atomic string lengths
@@ -250,7 +250,7 @@ gdk_export const ptr ptr_nil;
                                                                        \
                assert(BATatoms[t_].atomPut == NULL);                   \
                ATOMfix(t_, s_);                                        \
-               switch (BATatoms[t_].size) {                            \
+               switch (ATOMsize(t_)) {                                 \
                case 0:         /* void */                              \
                        break;                                          \
                case 1:                                                 \
@@ -267,7 +267,7 @@ gdk_export const ptr ptr_nil;
                        break;                                          \
                ATOM_CASE_16_hge;                                       \
                default:                                                \
-                       memcpy(d_, s_, (size_t) BATatoms[t_].size);     \
+                       memcpy(d_, s_, (size_t) ATOMsize(t_));          \
                        break;                                          \
                }                                                       \
        } while (0)
@@ -297,7 +297,7 @@ gdk_export const ptr ptr_nil;
                assert(BATatoms[t_].atomPut == NULL);                   \
                ATOMfix(t_, s_);                                        \
                ATOMunfix(t_, d_);                                      \
-               switch (BATatoms[t_].size) {                            \
+               switch (ATOMsize(t_)) {                                 \
                case 0:      /* void */                                 \
                        break;                                          \
                case 1:                                                 \
@@ -314,7 +314,7 @@ gdk_export const ptr ptr_nil;
                        break;                                          \
                ATOM_CASE_16_hge;                                       \
                default:                                                \
-                       memcpy(d_, s_, (size_t) BATatoms[t_].size);     \
+                       memcpy(d_, s_, (size_t) ATOMsize(t_));          \
                        break;                                          \
                }                                                       \
        } while (0)
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -960,11 +960,11 @@ BATcopy(BAT *b, int ht, int tt, int writ
                bn->tdense = bn->T->nonil = 0;
        }
        if (BATcount(bn) <= 1) {
-               bn->hsorted = BATatoms[b->htype].linear;
-               bn->hrevsorted = BATatoms[b->htype].linear;
+               bn->hsorted = ATOMlinear(b->htype);
+               bn->hrevsorted = ATOMlinear(b->htype);
                bn->hkey = 1;
-               bn->tsorted = BATatoms[b->ttype].linear;
-               bn->trevsorted = BATatoms[b->ttype].linear;
+               bn->tsorted = ATOMlinear(b->ttype);
+               bn->trevsorted = ATOMlinear(b->ttype);
                bn->tkey = 1;
        }
        if (writable != TRUE)
@@ -1059,7 +1059,7 @@ setcolprops(BAT *b, COLrec *col, const v
        assert(x != NULL || col->type == TYPE_void);
        if (b->batCount == 0) {
                /* first value */
-               col->sorted = col->revsorted = BATatoms[col->type].linear != 0;
+               col->sorted = col->revsorted = ATOMlinear(col->type) != 0;
                col->key |= 1;
                if (col->type == TYPE_void) {
                        if (x) {
@@ -2067,8 +2067,8 @@ BATsetcount(BAT *b, BUN cnt)
        if (b->H->type == TYPE_void && b->T->type == TYPE_void)
                b->batCapacity = cnt;
        if (cnt <= 1) {
-               b->hsorted = b->hrevsorted = BATatoms[b->htype].linear != 0;
-               b->tsorted = b->trevsorted = BATatoms[b->ttype].linear != 0;
+               b->hsorted = b->hrevsorted = ATOMlinear(b->htype) != 0;
+               b->tsorted = b->trevsorted = ATOMlinear(b->ttype) != 0;
        }
        assert(b->batCapacity >= cnt);
 }
@@ -2821,8 +2821,8 @@ BATassertHeadProps(BAT *b)
                }
        }
        /* only linear atoms can be sorted */
-       assert(!b->hsorted || BATatoms[b->htype].linear);
-       assert(!b->hrevsorted || BATatoms[b->htype].linear);
+       assert(!b->hsorted || ATOMlinear(b->htype));
+       assert(!b->hrevsorted || ATOMlinear(b->htype));
 
        if (!b->hkey && !b->hsorted && !b->hrevsorted &&
            !b->H->nonil && !b->H->nil) {
@@ -3041,7 +3041,7 @@ BATderiveHeadProps(BAT *b, int expensive
        }
        /* tentatively set until proven otherwise */
        key = 1;
-       sorted = revsorted = (BATatoms[b->htype].linear != 0);
+       sorted = revsorted = (ATOMlinear(b->htype) != 0);
        dense = (b->htype == TYPE_oid);
        /* if no* props already set correctly, we can maybe speed
         * things up, if not set correctly, reset them now and set
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -1058,10 +1058,10 @@ BATslice(BAT *b, BUN l, BUN h)
                }
        }
        if (bn->batCount <= 1) {
-               bn->hsorted = BATatoms[b->htype].linear;
-               bn->tsorted = BATatoms[b->ttype].linear;
-               bn->hrevsorted = BATatoms[b->htype].linear;
-               bn->trevsorted = BATatoms[b->ttype].linear;
+               bn->hsorted = ATOMlinear(b->htype);
+               bn->tsorted = ATOMlinear(b->ttype);
+               bn->hrevsorted = ATOMlinear(b->htype);
+               bn->trevsorted = ATOMlinear(b->ttype);
                BATkey(bn, 1);
                BATkey(BATmirror(bn), 1);
        } else {
@@ -1747,7 +1747,7 @@ BATconstant(int tailtype, const void *v,
                n -= BUNfirst(bn);
                break;
        }
-       bn->T->nil = n >= 1 && (*BATatoms[tailtype].atomCmp)(v, 
BATatoms[tailtype].atomNull) == 0;
+       bn->T->nil = n >= 1 && (*ATOMcompare(tailtype))(v, 
ATOMnilptr(tailtype)) == 0;
        BATsetcount(bn, n);
        bn->tsorted = 1;
        bn->trevsorted = 1;
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -726,13 +726,13 @@ heapinit(COLrec *col, const char *buf, i
        else if (var != (t == TYPE_void || BATatoms[t].atomPut != NULL))
                GDKfatal("BBPinit: inconsistent entry in BBP.dir: %s.varsized 
mismatch for BAT " LLFMT "\n", HT, batid);
        else if (var && t != 0 ?
-                BATatoms[t].size < width ||
+                ATOMsize(t) < width ||
                 (width != 1 && width != 2 && width != 4
 #if SIZEOF_VAR_T == 8
                  && width != 8
 #endif
                         ) :
-                BATatoms[t].size != width
+                ATOMsize(t) != width
 #if SIZEOF_SIZE_T == 8 && SIZEOF_OID == 8
                 && (t != TYPE_oid || oidsize == 0 || width != oidsize)
 #endif
diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -11765,7 +11765,7 @@ BATcalcbetween_intern(const void *src, i
        default:
                assert(tp != TYPE_oid);
                assert(tp != TYPE_wrd);
-               if (!BATatoms[tp].linear ||
+               if (!ATOMlinear(tp) ||
                    (atomcmp = ATOMcompare(tp)) == NULL) {
                        BBPunfix(bn->batCacheid);
                        GDKerror("%s: bad input type %s.\n",
@@ -11981,7 +11981,7 @@ VARcalcbetween(ValPtr ret, const ValReco
                GDKerror("VARcalcbetween: incompatible input types.\n");
                return GDK_FAIL;
        }
-       if (!BATatoms[t].linear) {
+       if (!ATOMlinear(t)) {
                GDKerror("VARcalcbetween: non-linear input type.\n");
                return GDK_FAIL;
        }
@@ -13309,7 +13309,7 @@ VARconvert(ValPtr ret, const ValRecord *
                } else {
                        int len;
                        p = VALget(ret);
-                       ret->len = BATatoms[ret->vtype].size;
+                       ret->len = ATOMsize(ret->vtype);
                        if ((len = (*BATatoms[ret->vtype].atomFromStr)(
                                     v->val.sval, &ret->len, &p)) <= 0 ||
                            len < (int) strlen(v->val.sval)) {
diff --git a/gdk/gdk_calc_compare.h b/gdk/gdk_calc_compare.h
--- a/gdk/gdk_calc_compare.h
+++ b/gdk/gdk_calc_compare.h
@@ -528,29 +528,29 @@ op_typeswitchloop(const void *lft, int t
                break;
        default:
                if (tp1 != tp2 ||
-                   !BATatoms[tp1].linear ||
-                   (atomcmp = BATatoms[tp1].atomCmp) == NULL)
+                   !ATOMlinear(tp1) ||
+                   (atomcmp = ATOMcompare(tp1)) == NULL)
                        goto unsupported;
                /* a bit of a hack: for inherited types, use
                 * type-expanded version if comparison function is
                 * equal to the inherited-from comparison function,
                 * and yes, we jump right into the middle of a switch,
                 * but that is legal (although not encouraged) C */
-               if (atomcmp == BATatoms[TYPE_bte].atomCmp)
+               if (atomcmp == ATOMcompare(TYPE_bte))
                        goto btebte;
-               if (atomcmp == BATatoms[TYPE_sht].atomCmp)
+               if (atomcmp == ATOMcompare(TYPE_sht))
                        goto shtsht;
-               if (atomcmp == BATatoms[TYPE_int].atomCmp)
+               if (atomcmp == ATOMcompare(TYPE_int))
                        goto intint;
-               if (atomcmp == BATatoms[TYPE_lng].atomCmp)
+               if (atomcmp == ATOMcompare(TYPE_lng))
                        goto lnglng;
 #ifdef HAVE_HGE
-               if (atomcmp == BATatoms[TYPE_hge].atomCmp)
+               if (atomcmp == ATOMcompare(TYPE_hge))
                        goto hgehge;
 #endif
-               if (atomcmp == BATatoms[TYPE_flt].atomCmp)
+               if (atomcmp == ATOMcompare(TYPE_flt))
                        goto fltflt;
-               if (atomcmp == BATatoms[TYPE_dbl].atomCmp)
+               if (atomcmp == ATOMcompare(TYPE_dbl))
                        goto dbldbl;
                nil = ATOMnilptr(tp1);
                CANDLOOP(dst, k, TPE_nil, 0, start);
diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -344,7 +344,7 @@ mergejoin(BAT *r1, BAT *r2, BAT *l, BAT 
        const char *lvars, *rvars;
        int lwidth, rwidth;
        const void *nil = ATOMnilptr(l->ttype);
-       int (*cmp)(const void *, const void *) = BATatoms[l->ttype].atomCmp;
+       int (*cmp)(const void *, const void *) = ATOMcompare(l->ttype);
        const char *v, *prev = NULL;
        BUN nl, nr;
        BUN total;              /* number of rows in l we scan */
@@ -1273,7 +1273,7 @@ hashjoin(BAT *r1, BAT *r2, BAT *l, BAT *
        const char *lvars;
        int lwidth;
        const void *nil = ATOMnilptr(l->ttype);
-       int (*cmp)(const void *, const void *) = BATatoms[l->ttype].atomCmp;
+       int (*cmp)(const void *, const void *) = ATOMcompare(l->ttype);
        oid lval = oid_nil;     /* hold value if l has dense tail */
        const char *v = (const char *) &lval;
        int lskipped = 0;       /* whether we skipped values in l */
@@ -1615,7 +1615,7 @@ thetajoin(BAT *r1, BAT *r2, BAT *l, BAT 
        const char *lvars, *rvars;
        int lwidth, rwidth;
        const void *nil = ATOMnilptr(l->ttype);
-       int (*cmp)(const void *, const void *) = BATatoms[l->ttype].atomCmp;
+       int (*cmp)(const void *, const void *) = ATOMcompare(l->ttype);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to