Changeset: 5452d9d5c7d7 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5452d9d5c7d7
Modified Files:
        gdk/gdk_string.c
        gdk/gdk_subquery.c
        gdk/gdk_unique.c
        geom/monetdb5/geom.c
        geom/monetdb5/geomBulk.c
        monetdb5/extras/rapi/rapi.c
        monetdb5/modules/atoms/mtime.c
        monetdb5/modules/atoms/uuid.c
        monetdb5/modules/kernel/aggr.c
        monetdb5/modules/kernel/alarm.c
        monetdb5/modules/kernel/algebra.c
        monetdb5/modules/kernel/bat5.c
        monetdb5/modules/kernel/batmmath.c
        monetdb5/modules/kernel/batstr.c
        monetdb5/modules/mal/manifold.c
        monetdb5/modules/mal/mkey.c
        monetdb5/modules/mal/pcre.c
        monetdb5/modules/mal/remote.c
        monetdb5/modules/mal/txtsim.c
        monetdb5/modules/mal/wlc.c
Branch: Jul2021
Log Message:

Use more bat iterators to access data.


diffs (truncated from 3580 to 300 lines):

diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c
--- a/gdk/gdk_string.c
+++ b/gdk/gdk_string.c
@@ -1248,7 +1248,7 @@ BATgroupstr_group_concat(BAT *b, BAT *g,
                                }       \
                        } else { /* sep case */ \
                                assert(sep != NULL);    \
-                               sl = BUNtvar(bis, m);   \
+                               sl = BUNtvar(sepi, m);  \
        \
                                if (!strNil(sb)) {      \
                                        next_group_length += strlen(sb);        
\
@@ -1300,7 +1300,7 @@ BATgroupstr_group_concat(BAT *b, BAT *g,
                                        empty = false;  \
                                } else { /* sep case */ \
                                        assert(sep != NULL);    \
-                                       sl = BUNtvar(bis, m);   \
+                                       sl = BUNtvar(sepi, m);  \
 \
                                        if (strNil(sb)) \
                                                continue;       \
@@ -1343,7 +1343,7 @@ BATgroupstr_group_concat(BAT *b, BAT *g,
                                                        nsep = (str) separator; 
\
                                                } else { /* sep case */ \
                                                        assert(sep != NULL);    
\
-                                                       nsep = BUNtvar(bis, j); 
\
+                                                       nsep = BUNtvar(sepi, 
j);        \
                                                }       \
                                                if (!strNil(nsep))      \
                                                        slice_length += 
strlen(nsep);   \
@@ -1414,28 +1414,34 @@ gdk_return
 GDKanalytical_str_group_concat(BAT *r, BAT *p, BAT *o, BAT *b, BAT *sep, BAT 
*s, BAT *e, const char *restrict separator, int frame_type)
 {
        bool has_nils = false, empty;
-       oid i = 0, j = 0, k = 0, cnt = BATcount(b), *restrict start = s ? 
(oid*)Tloc(s, 0) : NULL, *restrict end = e ? (oid*)Tloc(e, 0) : NULL;
-       bit *np = p ? Tloc(p, 0) : NULL, *op = o ? Tloc(o, 0) : NULL;
-       BATiter bi, bis = (BATiter) {0};
+       BATiter pi = bat_iterator(p);
+       BATiter oi = bat_iterator(o);
+       BATiter bi = bat_iterator(b);
+       BATiter sepi = bat_iterator(sep);
+       BATiter si = bat_iterator(s);
+       BATiter ei = bat_iterator(e);
+       oid i = 0, j = 0, k = 0, cnt = BATcount(b), *restrict start = si.base, 
*restrict end = ei.base;
+       bit *np = pi.base, *op = oi.base;
        str sb, sl, single_str = NULL, next_single_str;
        size_t separator_length = 0, next_group_length, max_group_length = 0, 
next_length, offset;
 
        assert((sep && !separator && BATcount(b) == BATcount(sep)) || (!sep && 
separator));
        if (b->ttype != TYPE_str || r->ttype != TYPE_str || (sep && sep->ttype 
!= TYPE_str)) {
                GDKerror("only string type is supported\n");
+               bat_iterator_end(&pi);
+               bat_iterator_end(&oi);
+               bat_iterator_end(&bi);
+               bat_iterator_end(&sepi);
+               bat_iterator_end(&si);
+               bat_iterator_end(&ei);
                return GDK_FAIL;
        }
        if (sep && BATcount(sep) == 1) { /* Only one element in sep */
-               bi = bat_iterator(sep);
-               separator = BUNtvar(bi, 0);
-               bat_iterator_end(&bi);
+               separator = BUNtvar(sepi, 0);
                sep = NULL;
        }
 
-       bi = bat_iterator(b);
-       if (sep)
-               bis = bat_iterator(sep);
-       else
+       if (sep == NULL)
                separator_length = strlen(separator);
 
        if (cnt > 0) {
@@ -1457,24 +1463,33 @@ GDKanalytical_str_group_concat(BAT *r, B
                }
        }
 
+       bat_iterator_end(&pi);
+       bat_iterator_end(&oi);
        bat_iterator_end(&bi);
-       if (sep)
-               bat_iterator_end(&bis);
+       bat_iterator_end(&sepi);
+       bat_iterator_end(&si);
+       bat_iterator_end(&ei);
        GDKfree(single_str);
        BATsetcount(r, cnt);
        r->tnonil = !has_nils;
        r->tnil = has_nils;
        return GDK_SUCCEED;
   allocation_error:
+       bat_iterator_end(&pi);
+       bat_iterator_end(&oi);
        bat_iterator_end(&bi);
-       if (sep)
-               bat_iterator_end(&bis);
+       bat_iterator_end(&sepi);
+       bat_iterator_end(&si);
+       bat_iterator_end(&ei);
        GDKfree(single_str);
        return GDK_FAIL;
   notimplemented:
+       bat_iterator_end(&pi);
+       bat_iterator_end(&oi);
        bat_iterator_end(&bi);
-       if (sep)
-               bat_iterator_end(&bis);
+       bat_iterator_end(&sepi);
+       bat_iterator_end(&si);
+       bat_iterator_end(&ei);
        GDKerror("str_group_concat not yet implemented for current row until 
unbounded case\n");
        return GDK_FAIL;
 }
diff --git a/gdk/gdk_subquery.c b/gdk/gdk_subquery.c
--- a/gdk/gdk_subquery.c
+++ b/gdk/gdk_subquery.c
@@ -14,7 +14,7 @@
 
 #define SQLall_grp_imp(TYPE)   \
        do {                    \
-               const TYPE *restrict vals = (const TYPE *) Tloc(l, 0); \
+               const TYPE *restrict vals = (const TYPE *) li.base;     \
                TYPE *restrict rp = (TYPE *) Tloc(res, 0); \
                while (ncand > 0) {                                     \
                        ncand--;                                        \
@@ -75,6 +75,8 @@ BATall_grp(BAT *l, BAT *g, BAT *e, BAT *
                if ((res = BATconstant(ngrp == 0 ? 0 : min, l->ttype, nilp, 
ngrp, TRANSIENT)) == NULL)
                        goto alloc_fail;
        } else {
+               BATiter li;
+
                if ((res = COLnew(min, l->ttype, ngrp, TRANSIENT)) == NULL)
                        goto alloc_fail;
                if ((oids = GDKmalloc(ngrp * sizeof(oid))) == NULL)
@@ -88,6 +90,7 @@ BATall_grp(BAT *l, BAT *g, BAT *e, BAT *
                else
                        gids = (const oid *) Tloc(g, 0);
 
+               li = bat_iterator(l);
                switch (ATOMbasetype(l->ttype)) {
                case TYPE_bte:
                        SQLall_grp_imp(bte);
@@ -115,7 +118,6 @@ BATall_grp(BAT *l, BAT *g, BAT *e, BAT *
                default: {
                        int (*ocmp) (const void *, const void *) = 
ATOMcompare(l->ttype);
                        const void *restrict nilp = ATOMnilptr(l->ttype);
-                       BATiter li = bat_iterator(l);
 
                        while (ncand > 0) {
                                ncand--;
@@ -171,9 +173,9 @@ BATall_grp(BAT *l, BAT *g, BAT *e, BAT *
                                        rcast += width;
                                }
                        }
-                       bat_iterator_end(&li);
                }
                }
+               bat_iterator_end(&li);
                BATsetcount(res, ngrp);
                res->tnil = hasnil != 0;
                res->tnonil = hasnil == 0;
@@ -201,7 +203,7 @@ alloc_fail:
 
 #define SQLnil_grp_imp(TYPE)   \
        do {                                                            \
-               const TYPE *restrict vals = (const TYPE *) Tloc(l, 0);          
\
+               const TYPE *restrict vals = (const TYPE *) li.base;     \
                while (ncand > 0) {                                     \
                        ncand--;                                        \
                        i = canditer_next(&ci) - l->hseqbase;           \
@@ -246,6 +248,7 @@ BATnil_grp(BAT *l, BAT *g, BAT *e, BAT *
 
        } else {
                bit *restrict ret;
+               BATiter li;
 
                if ((res = COLnew(min, TYPE_bit, ngrp, TRANSIENT)) == NULL)
                        goto alloc_fail;
@@ -257,6 +260,7 @@ BATnil_grp(BAT *l, BAT *g, BAT *e, BAT *
                else
                        gids = (const oid *) Tloc(g, 0);
 
+               li = bat_iterator(l);
                switch (ATOMbasetype(l->ttype)) {
                case TYPE_bte:
                        SQLnil_grp_imp(bte);
@@ -284,7 +288,6 @@ BATnil_grp(BAT *l, BAT *g, BAT *e, BAT *
                default: {
                        int (*ocmp) (const void *, const void *) = 
ATOMcompare(l->ttype);
                        const void *restrict nilp = ATOMnilptr(l->ttype);
-                       BATiter li = bat_iterator(l);
 
                        while (ncand > 0) {
                                ncand--;
@@ -300,9 +303,9 @@ BATnil_grp(BAT *l, BAT *g, BAT *e, BAT *
                                                ret[gid] = TRUE;
                                }
                        }
-                       bat_iterator_end(&li);
                }
                }
+               bat_iterator_end(&li);
                BATsetcount(res, ngrp);
                res->tkey = BATcount(res) <= 1;
                res->tsorted = BATcount(res) <= 1;
@@ -327,8 +330,8 @@ alloc_fail:
 
 #define SQLanyequal_or_not_grp_imp(TYPE, TEST) \
        do {                                                            \
-               const TYPE *vals1 = (const TYPE *) Tloc(l, 0);          \
-               const TYPE *vals2 = (const TYPE *) Tloc(r, 0);          \
+               const TYPE *vals1 = (const TYPE *) li.base;             \
+               const TYPE *vals2 = (const TYPE *) ri.base;             \
                while (ncand > 0) {                                     \
                        ncand--;                                        \
                        i = canditer_next(&ci) - l->hseqbase;           \
@@ -379,6 +382,7 @@ BATanyequal_grp(BAT *l, BAT *r, BAT *g, 
                        goto alloc_fail;
        } else {
                bit *restrict ret;
+               BATiter li, ri;
 
                if ((res = COLnew(min, TYPE_bit, ngrp, TRANSIENT)) == NULL)
                        goto alloc_fail;
@@ -390,6 +394,8 @@ BATanyequal_grp(BAT *l, BAT *r, BAT *g, 
                else
                        gids = (const oid *) Tloc(g, 0);
 
+               li = bat_iterator(l);
+               ri = bat_iterator(r);
                switch (ATOMbasetype(l->ttype)) {
                case TYPE_bte:
                        SQLanyequal_or_not_grp_imp(bte, TRUE);
@@ -417,7 +423,6 @@ BATanyequal_grp(BAT *l, BAT *r, BAT *g, 
                default: {
                        int (*ocmp) (const void *, const void *) = 
ATOMcompare(l->ttype);
                        const void *nilp = ATOMnilptr(l->ttype);
-                       BATiter li = bat_iterator(l), ri = bat_iterator(r);
 
                        while (ncand > 0) {
                                ncand--;
@@ -439,10 +444,10 @@ BATanyequal_grp(BAT *l, BAT *r, BAT *g, 
                                        }
                                }
                        }
-                       bat_iterator_end(&li);
-                       bat_iterator_end(&ri);
                }
                }
+               bat_iterator_end(&li);
+               bat_iterator_end(&ri);
                BATsetcount(res, ngrp);
                res->tkey = BATcount(res) <= 1;
                res->tsorted = BATcount(res) <= 1;
@@ -494,6 +499,7 @@ BATallnotequal_grp(BAT *l, BAT *r, BAT *
                        goto alloc_fail;
        } else {
                bit *restrict ret;
+               BATiter li, ri;
 
                if ((res = COLnew(min, TYPE_bit, ngrp, TRANSIENT)) == NULL)
                        goto alloc_fail;
@@ -505,6 +511,8 @@ BATallnotequal_grp(BAT *l, BAT *r, BAT *
                else
                        gids = (const oid *) Tloc(g, 0);
 
+               li = bat_iterator(l);
+               ri = bat_iterator(r);
                switch (ATOMbasetype(l->ttype)) {
                case TYPE_bte:
                        SQLanyequal_or_not_grp_imp(bte, FALSE);
@@ -532,7 +540,6 @@ BATallnotequal_grp(BAT *l, BAT *r, BAT *
                default: {
                        int (*ocmp) (const void *, const void *) = 
ATOMcompare(l->ttype);
                        const void *nilp = ATOMnilptr(l->ttype);
-                       BATiter li = bat_iterator(l), ri = bat_iterator(r);
 
                        while (ncand > 0) {
                                ncand--;
@@ -554,10 +561,10 @@ BATallnotequal_grp(BAT *l, BAT *r, BAT *
                                        }
                                }
                        }
-                       bat_iterator_end(&li);
-                       bat_iterator_end(&ri);
                }
                }
+               bat_iterator_end(&li);
+               bat_iterator_end(&ri);
                BATsetcount(res, ngrp);
                res->tkey = BATcount(res) <= 1;
                res->tsorted = BATcount(res) <= 1;
@@ -582,8 +589,8 @@ alloc_fail:
 
 #define SQLanyequal_or_not_grp2_imp(TYPE, VAL1, VAL2) \
        do {                                                            \
-               const TYPE *vals1 = (const TYPE *) Tloc(l, 0);          \
-               const TYPE *vals2 = (const TYPE *) Tloc(r, 0);          \
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to