Changeset: 9b0fa13b9280 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/9b0fa13b9280
Modified Files:
        gdk/gdk.h
        gdk/gdk_aggr.c
        gdk/gdk_analytic_bounds.c
        gdk/gdk_analytic_func.c
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        gdk/gdk_calc.c
        gdk/gdk_calc_addsub.c
        gdk/gdk_calc_convert.c
        gdk/gdk_firstn.c
        gdk/gdk_group.c
        gdk/gdk_hash.c
        gdk/gdk_join.c
        gdk/gdk_logger.c
        gdk/gdk_project.c
        gdk/gdk_rtree.c
        gdk/gdk_select.c
        gdk/gdk_storage.c
        gdk/gdk_strimps.c
        gdk/gdk_string.c
        gdk/gdk_subquery.c
        gdk/gdk_unique.c
        gdk/gdk_utils.c
        geom/monetdb5/geod.c
        geom/monetdb5/geom.c
        geom/monetdb5/geomBulk.c
        monetdb5/extras/rapi/rapi.c
        monetdb5/modules/atoms/batxml.c
        monetdb5/modules/atoms/blob.c
        monetdb5/modules/atoms/inet-46.c
        monetdb5/modules/atoms/json.c
        monetdb5/modules/atoms/mtime.c
        monetdb5/modules/atoms/str.c
        monetdb5/modules/atoms/url.c
        monetdb5/modules/atoms/uuid.c
        monetdb5/modules/kernel/algebra.c
        monetdb5/modules/kernel/batstr.c
        monetdb5/modules/mal/iterator.c
        monetdb5/modules/mal/manifold.c
        monetdb5/modules/mal/mkey.c
        monetdb5/modules/mal/pcre.c
        monetdb5/modules/mal/remote.c
        monetdb5/modules/mal/tablet.c
        monetdb5/modules/mal/txtsim.c
        sql/backends/monet5/UDF/capi/capi.c
        sql/backends/monet5/UDF/pyapi3/conversion3.c
        sql/backends/monet5/UDF/pyapi3/pyapi3.c
        sql/backends/monet5/UDF/udf/udf.c
        sql/backends/monet5/dict.c
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql_bincopy.c
        sql/backends/monet5/sql_bincopyconvert.c
        sql/backends/monet5/sql_cast.c
        sql/backends/monet5/sql_rank.c
        sql/backends/monet5/sql_result.c
        sql/backends/monet5/sql_round_impl.h
        sql/backends/monet5/sql_statistics.c
        sql/backends/monet5/sql_subquery.c
        sql/backends/monet5/sql_time.c
        sql/backends/monet5/sql_upgrades.c
        sql/backends/monet5/vaults/fits/fits.c
        sql/storage/bat/bat_logger.c
        sql/storage/bat/bat_storage.c
        sql/storage/bat/bat_table.c
        tools/monetdbe/monetdbe.c
Branch: default
Log Message:

Changed BUNt* and HASHloop* macros.
They now all get a pointer to a BATiter as first argument (instead of
the BATiter itself), and the BUNt* versions are now inline functions
instead of macros.
Also removed BUNtvaroff, Tmsk, and Tpos.  Use VarHeapVal, BUNtmsk, and
BUNtpos instead.


diffs (truncated from 5978 to 300 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -824,19 +824,144 @@ typedef var_t stridx_t;
 #define SIZEOF_STRIDX_T SIZEOF_VAR_T
 #define GDK_VARALIGN SIZEOF_STRIDX_T
 
-#define BUNtvaroff(bi,p) VarHeapVal((bi).base, (p), (bi).width)
-
-#define BUNtmsk(bi,p)  Tmsk(&(bi), (p))
-#define BUNtloc(bi,p)  (assert((bi).type != TYPE_msk), ((void *) ((char *) 
(bi).base + ((p) << (bi).shift))))
-#define BUNtpos(bi,p)  Tpos(&(bi),p)
-#define BUNtvar(bi,p)  (assert((bi).type && (bi).vh), (void *) 
((bi).vh->base+BUNtvaroff(bi,p)))
-#define BUNtail(bi,p)  
((bi).type?(bi).vh?BUNtvar(bi,p):(bi).type==TYPE_msk?BUNtmsk(bi,p):BUNtloc(bi,p):BUNtpos(bi,p))
+#include "gdk_atoms.h"
+#include "gdk_cand.h"
 
 #define BATcount(b)    ((b)->batCount)
 
-#include "gdk_atoms.h"
+__attribute__((__pure__))
+static inline bool
+Tmskval(const BATiter *bi, BUN p)
+{
+       assert(ATOMstorage(bi->type) == TYPE_msk);
+       return ((const uint32_t *) bi->base)[p / 32] & (1U << (p % 32));
+}
+
+__attribute__((__pure__))
+static inline void *
+BUNtmsk(BATiter *bi, BUN p)
+{
+       bi->tmsk = Tmskval(bi, p);
+       return &bi->tmsk;
+}
+
+__attribute__((__pure__))
+static inline void *
+BUNtloc(BATiter *bi, BUN p)
+{
+       assert(bi->type != TYPE_msk);
+       return (void *) ((char *) bi->base + (p << bi->shift));
+}
 
-#include "gdk_cand.h"
+__attribute__((__pure__))
+static inline void *
+BUNtpos(BATiter *bi, BUN p)
+{
+       assert(bi->base == NULL);
+       if (bi->vh) {
+               oid o;
+               assert(!is_oid_nil(bi->tseq));
+               if (((ccand_t *) bi->vh)->type == CAND_NEGOID) {
+                       BUN nexc = (bi->vhfree - sizeof(ccand_t)) / SIZEOF_OID;
+                       o = bi->tseq + p;
+                       if (nexc > 0) {
+                               const oid *exc = (const oid *) (bi->vh->base + 
sizeof(ccand_t));
+                               if (o >= exc[0]) {
+                                       if (o + nexc > exc[nexc - 1]) {
+                                               o += nexc;
+                                       } else {
+                                               BUN lo = 0;
+                                               BUN hi = nexc - 1;
+                                               while (hi - lo > 1) {
+                                                       BUN mid = (hi + lo) / 2;
+                                                       if (exc[mid] - mid > o)
+                                                               hi = mid;
+                                                       else
+                                                               lo = mid;
+                                               }
+                                               o += hi;
+                                       }
+                               }
+                       }
+               } else {
+                       const uint32_t *msk = (const uint32_t *) (bi->vh->base 
+ sizeof(ccand_t));
+                       BUN nmsk = (bi->vhfree - sizeof(ccand_t)) / 
sizeof(uint32_t);
+                       o = 0;
+                       for (BUN i = 0; i < nmsk; i++) {
+                               uint32_t m = candmask_pop(msk[i]);
+                               if (o + m > p) {
+                                       m = msk[i];
+                                       for (i = 0; i < 32; i++) {
+                                               if (m & (1U << i) && ++o == p)
+                                                       break;
+                                       }
+                                       break;
+                               }
+                               o += m;
+                       }
+               }
+               bi->tvid = o;
+       } else if (is_oid_nil(bi->tseq)) {
+               bi->tvid = oid_nil;
+       } else {
+               bi->tvid = bi->tseq + p;
+       }
+       return (void *) &bi->tvid;
+}
+
+__attribute__((__pure__))
+static inline void *
+BUNtvar(BATiter *bi, BUN p)
+{
+       assert(bi->type && bi->vh);
+       return (void *) (bi->vh->base + VarHeapVal(bi->base, p, bi->width));
+}
+
+__attribute__((__pure__))
+static inline void *
+BUNtail(BATiter *bi, BUN p)
+{
+       if (bi->type) {
+               if (bi->vh) {
+                       return BUNtvar(bi, p);
+               } else if (bi->type == TYPE_msk) {
+                       return BUNtmsk(bi, p);
+               } else {
+                       return BUNtloc(bi, p);
+               }
+       } else {
+               return BUNtpos(bi, p);
+       }
+}
+
+/* return the oid value at BUN position p from the (v)oid bat b
+ * works with any TYPE_void or TYPE_oid bat */
+__attribute__((__pure__))
+static inline oid
+BUNtoid(BAT *b, BUN p)
+{
+       assert(ATOMtype(b->ttype) == TYPE_oid);
+       /* BATcount is the number of valid entries, so with
+        * exceptions, the last value can well be larger than
+        * b->tseqbase + BATcount(b) */
+       assert(p < BATcount(b));
+       assert(b->ttype == TYPE_void || b->tvheap == NULL);
+       if (is_oid_nil(b->tseqbase)) {
+               if (b->ttype == TYPE_void)
+                       return oid_nil;
+               MT_lock_set(&b->theaplock);
+               oid o = ((const oid *) b->theap->base)[p + b->tbaseoff];
+               MT_lock_unset(&b->theaplock);
+               return o;
+       }
+       if (b->ttype == TYPE_oid || b->tvheap == NULL) {
+               return b->tseqbase + p;
+       }
+       /* b->tvheap != NULL, so we know there will be no parallel
+        * modifications (so no locking) */
+       BATiter bi = bat_iterator_nolock(b);
+       return * (oid *) BUNtpos(&bi, p);
+}
 
 gdk_export BUN BATcount_no_nil(BAT *b, BAT *s);
 gdk_export void BATsetcapacity(BAT *b, BUN cnt);
@@ -1319,105 +1444,6 @@ BBPcheck(bat x)
 
 gdk_export BAT *BATdescriptor(bat i);
 
-static inline void *
-Tpos(BATiter *bi, BUN p)
-{
-       assert(bi->base == NULL);
-       if (bi->vh) {
-               oid o;
-               assert(!is_oid_nil(bi->tseq));
-               if (((ccand_t *) bi->vh)->type == CAND_NEGOID) {
-                       BUN nexc = (bi->vhfree - sizeof(ccand_t)) / SIZEOF_OID;
-                       o = bi->tseq + p;
-                       if (nexc > 0) {
-                               const oid *exc = (const oid *) (bi->vh->base + 
sizeof(ccand_t));
-                               if (o >= exc[0]) {
-                                       if (o + nexc > exc[nexc - 1]) {
-                                               o += nexc;
-                                       } else {
-                                               BUN lo = 0;
-                                               BUN hi = nexc - 1;
-                                               while (hi - lo > 1) {
-                                                       BUN mid = (hi + lo) / 2;
-                                                       if (exc[mid] - mid > o)
-                                                               hi = mid;
-                                                       else
-                                                               lo = mid;
-                                               }
-                                               o += hi;
-                                       }
-                               }
-                       }
-               } else {
-                       const uint32_t *msk = (const uint32_t *) (bi->vh->base 
+ sizeof(ccand_t));
-                       BUN nmsk = (bi->vhfree - sizeof(ccand_t)) / 
sizeof(uint32_t);
-                       o = 0;
-                       for (BUN i = 0; i < nmsk; i++) {
-                               uint32_t m = candmask_pop(msk[i]);
-                               if (o + m > p) {
-                                       m = msk[i];
-                                       for (i = 0; i < 32; i++) {
-                                               if (m & (1U << i) && ++o == p)
-                                                       break;
-                                       }
-                                       break;
-                               }
-                               o += m;
-                       }
-               }
-               bi->tvid = o;
-       } else if (is_oid_nil(bi->tseq)) {
-               bi->tvid = oid_nil;
-       } else {
-               bi->tvid = bi->tseq + p;
-       }
-       return (void *) &bi->tvid;
-}
-
-__attribute__((__pure__))
-static inline bool
-Tmskval(const BATiter *bi, BUN p)
-{
-       assert(ATOMstorage(bi->type) == TYPE_msk);
-       return ((const uint32_t *) bi->base)[p / 32] & (1U << (p % 32));
-}
-
-static inline void *
-Tmsk(BATiter *bi, BUN p)
-{
-       bi->tmsk = Tmskval(bi, p);
-       return &bi->tmsk;
-}
-
-/* return the oid value at BUN position p from the (v)oid bat b
- * works with any TYPE_void or TYPE_oid bat */
-__attribute__((__pure__))
-static inline oid
-BUNtoid(BAT *b, BUN p)
-{
-       assert(ATOMtype(b->ttype) == TYPE_oid);
-       /* BATcount is the number of valid entries, so with
-        * exceptions, the last value can well be larger than
-        * b->tseqbase + BATcount(b) */
-       assert(p < BATcount(b));
-       assert(b->ttype == TYPE_void || b->tvheap == NULL);
-       if (is_oid_nil(b->tseqbase)) {
-               if (b->ttype == TYPE_void)
-                       return oid_nil;
-               MT_lock_set(&b->theaplock);
-               oid o = ((const oid *) b->theap->base)[p + b->tbaseoff];
-               MT_lock_unset(&b->theaplock);
-               return o;
-       }
-       if (b->ttype == TYPE_oid || b->tvheap == NULL) {
-               return b->tseqbase + p;
-       }
-       /* b->tvheap != NULL, so we know there will be no parallel
-        * modifications (so no locking) */
-       BATiter bi = bat_iterator_nolock(b);
-       return * (oid *) Tpos(&bi, p);
-}
-
 gdk_export gdk_return TMsubcommit_list(bat *restrict subcommit, BUN *restrict 
sizes, int cnt, lng logno)
        __attribute__((__warn_unused_result__));
 
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -3183,7 +3183,7 @@ BATgroupcount(BAT *b, BAT *g, BAT *e, BA
                                                gid = gids[i] - min;
                                        else
                                                gid = (oid) i;
-                                       if (!(*atomeq)(BUNtail(bi, i), nil)) {
+                                       if (!(*atomeq)(BUNtail(&bi, i), nil)) {
                                                cnts[gid]++;
                                        }
                                }
@@ -3337,7 +3337,7 @@ do_groupmin(oid *restrict oids, BATiter 
                        TIMEOUT_LOOP(ci->ncand, qry_ctx) {
                                i = canditer_next(ci) - hseq;
                                if (!skip_nils ||
-                                   !(*atomeq)(BUNtail(*bi, i), nil)) {
+                                   !(*atomeq)(BUNtail(bi, i), nil)) {
                                        oids[gid] = i + hseq;
                                        nils--;
                                }
@@ -3348,7 +3348,7 @@ do_groupmin(oid *restrict oids, BATiter 
                                i = canditer_next(ci) - hseq;
                                if (gids == NULL ||
                                    (gids[i] >= min && gids[i] <= max)) {
-                                       const void *v = BUNtail(*bi, i);
+                                       const void *v = BUNtail(bi, i);
                                        if (gids)
                                                gid = gids[i] - min;
                                        if (!skip_nils || !(*atomeq)(v, nil)) {
@@ -3356,7 +3356,7 @@ do_groupmin(oid *restrict oids, BATiter 
                                                        oids[gid] = i + hseq;
                                                        nils--;
                                                } else if (t != TYPE_void) {
-                                                       const void *g = 
BUNtail(*bi, (BUN) (oids[gid] - hseq));
+                                                       const void *g = 
BUNtail(bi, (BUN) (oids[gid] - hseq));
                                                        if (!(*atomeq)(g, nil) 
&&
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to