Changeset: fe9b67b5a15b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/fe9b67b5a15b
Modified Files:
gdk/gdk_calc.c
gdk/gdk_calc_addsub.c
gdk/gdk_calc_compare.h
gdk/gdk_calc_convert.c
gdk/gdk_calc_div.c
gdk/gdk_calc_mod.c
gdk/gdk_calc_mul.c
gdk/gdk_firstn.c
gdk/gdk_group.c
gdk/gdk_hash.c
gdk/gdk_join.c
gdk/gdk_rtree.c
gdk/gdk_sketch.c
gdk/gdk_strimps.c
gdk/gdk_string.c
gdk/gdk_unique.c
geom/monetdb5/geod.c
geom/monetdb5/geomBulk.c
monetdb5/modules/atoms/blob.c
monetdb5/modules/atoms/inet-46.c
monetdb5/modules/atoms/mtime.c
monetdb5/modules/atoms/str.c
monetdb5/modules/atoms/uuid.c
monetdb5/modules/kernel/aggr.c
monetdb5/modules/kernel/batmmath.c
monetdb5/modules/kernel/batstr.c
monetdb5/modules/mal/mkey.c
monetdb5/modules/mal/pcre.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_fround_impl.h
sql/backends/monet5/sql_round_impl.h
sql/storage/bat/bat_logger.c
Branch: default
Log Message:
Use BAT iterator to initialize candidate iterator where its easy to do.
diffs (truncated from 3329 to 300 lines):
diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -860,7 +860,7 @@ BATcalcisnil_implementation(BAT *b, BAT
bhseqbase = b->hseqbase;
BATiter bi = bat_iterator(b);
- canditer_init(&ci, b, s);
+ canditer_init_bi(&ci, &bi, s);
if (b->tnonil || BATtdense(b)) {
bat_iterator_end(&bi);
diff --git a/gdk/gdk_calc_addsub.c b/gdk/gdk_calc_addsub.c
--- a/gdk/gdk_calc_addsub.c
+++ b/gdk/gdk_calc_addsub.c
@@ -1490,21 +1490,24 @@ BATcalcadd(BAT *b1, BAT *b2, BAT *s1, BA
BATcheck(b1, NULL);
BATcheck(b2, NULL);
- canditer_init(&ci1, b1, s1);
- canditer_init(&ci2, b2, s2);
+ BATiter b1i = bat_iterator(b1);
+ BATiter b2i = bat_iterator(b2);
+ canditer_init_bi(&ci1, &b1i, s1);
+ canditer_init_bi(&ci2, &b2i, s2);
if (ci1.ncand != ci2.ncand || ci1.hseq != ci2.hseq) {
+ bat_iterator_end(&b1i);
+ bat_iterator_end(&b2i);
GDKerror("inputs not the same size.\n");
return NULL;
}
bn = COLnew(ci1.hseq, tp, ci1.ncand, TRANSIENT);
- if (bn == NULL)
- return NULL;
- if (ci1.ncand == 0)
+ if (bn == NULL || ci1.ncand == 0) {
+ bat_iterator_end(&b1i);
+ bat_iterator_end(&b2i);
return bn;
+ }
- BATiter b1i = bat_iterator(b1);
- BATiter b2i = bat_iterator(b2);
if (b1i.type == TYPE_str && b2i.type == TYPE_str && tp == TYPE_str) {
nils = addstr_loop(b1, NULL, b2, NULL, bn, &b1i, &b2i, &ci1,
&ci2);
} else {
@@ -1558,15 +1561,15 @@ BATcalcaddcst(BAT *b, const ValRecord *v
BATcheck(b, NULL);
- canditer_init(&ci, b, s);
+ BATiter bi = bat_iterator(b);
+ canditer_init_bi(&ci, &bi, s);
bn = COLnew(ci.hseq, tp, ci.ncand, TRANSIENT);
- if (bn == NULL)
- return NULL;
- if (ci.ncand == 0)
+ if (bn == NULL || ci.ncand == 0) {
+ bat_iterator_end(&bi);
return bn;
+ }
- BATiter bi = bat_iterator(b);
if (bi.type == TYPE_str && v->vtype == TYPE_str && tp == TYPE_str) {
nils = addstr_loop(b, NULL, NULL, v->val.sval, bn, &bi,
&(BATiter){0}, &ci, &(struct canditer){.tpe=cand_dense, .ncand=ci.ncand});
} else {
@@ -1617,15 +1620,15 @@ BATcalccstadd(const ValRecord *v, BAT *b
BATcheck(b, NULL);
- canditer_init(&ci, b, s);
+ BATiter bi = bat_iterator(b);
+ canditer_init_bi(&ci, &bi, s);
bn = COLnew(ci.hseq, tp, ci.ncand, TRANSIENT);
- if (bn == NULL)
- return NULL;
- if (ci.ncand == 0)
+ if (bn == NULL || ci.ncand == 0) {
+ bat_iterator_end(&bi);
return bn;
+ }
- BATiter bi = bat_iterator(b);
if (bi.type == TYPE_str && v->vtype == TYPE_str && tp == TYPE_str) {
nils = addstr_loop(NULL, v->val.sval, b, NULL, bn,
&(BATiter){0}, &bi, &(struct canditer){.tpe=cand_dense, .ncand=ci.ncand}, &ci);
} else {
@@ -1698,15 +1701,15 @@ BATcalcincrdecr(BAT *b, BAT *s,
BATcheck(b, NULL);
- canditer_init(&ci, b, s);
+ BATiter bi = bat_iterator(b);
+ canditer_init_bi(&ci, &bi, s);
- bn = COLnew(ci.hseq, b->ttype, ci.ncand, TRANSIENT);
- if (bn == NULL)
- return NULL;
- if (ci.ncand == 0)
+ bn = COLnew(ci.hseq, bi.type, ci.ncand, TRANSIENT);
+ if (bn == NULL || ci.ncand == 0) {
+ bat_iterator_end(&bi);
return bn;
+ }
- BATiter bi = bat_iterator(b);
nils = (*typeswitchloop)(bi.base, bi.type, true,
&(bte){1}, TYPE_bte, false,
Tloc(bn, 0), bn->ttype,
@@ -3178,21 +3181,24 @@ BATcalcsub(BAT *b1, BAT *b2, BAT *s1, BA
BATcheck(b1, NULL);
BATcheck(b2, NULL);
- canditer_init(&ci1, b1, s1);
- canditer_init(&ci2, b2, s2);
+ BATiter b1i = bat_iterator(b1);
+ BATiter b2i = bat_iterator(b2);
+ canditer_init_bi(&ci1, &b1i, s1);
+ canditer_init_bi(&ci2, &b2i, s2);
if (ci1.ncand != ci2.ncand || ci1.hseq != ci2.hseq) {
+ bat_iterator_end(&b1i);
+ bat_iterator_end(&b2i);
GDKerror("inputs not the same size.\n");
return NULL;
}
bn = COLnew(ci1.hseq, tp, ci1.ncand, TRANSIENT);
- if (bn == NULL)
- return NULL;
- if (ci1.ncand == 0)
+ if (bn == NULL || ci1.ncand == 0) {
+ bat_iterator_end(&b1i);
+ bat_iterator_end(&b2i);
return bn;
+ }
- BATiter b1i = bat_iterator(b1);
- BATiter b2i = bat_iterator(b2);
nils = sub_typeswitchloop(b1i.base, b1i.type, true,
b2i.base, b2i.type, true,
Tloc(bn, 0), tp,
@@ -3236,15 +3242,15 @@ BATcalcsubcst(BAT *b, const ValRecord *v
BATcheck(b, NULL);
- canditer_init(&ci, b, s);
+ BATiter bi = bat_iterator(b);
+ canditer_init_bi(&ci, &bi, s);
bn = COLnew(ci.hseq, tp, ci.ncand, TRANSIENT);
- if (bn == NULL)
- return NULL;
- if (ci.ncand == 0)
+ if (bn == NULL || ci.ncand == 0) {
+ bat_iterator_end(&bi);
return bn;
+ }
- BATiter bi = bat_iterator(b);
nils = sub_typeswitchloop(bi.base, bi.type, true,
VALptr(v), v->vtype, false,
Tloc(bn, 0), tp,
@@ -3291,15 +3297,15 @@ BATcalccstsub(const ValRecord *v, BAT *b
BATcheck(b, NULL);
- canditer_init(&ci, b, s);
+ BATiter bi = bat_iterator(b);
+ canditer_init_bi(&ci, &bi, s);
bn = COLnew(ci.hseq, tp, ci.ncand, TRANSIENT);
- if (bn == NULL)
- return NULL;
- if (ci.ncand == 0)
+ if (bn == NULL || ci.ncand == 0) {
+ bat_iterator_end(&bi);
return bn;
+ }
- BATiter bi = bat_iterator(b);
nils = sub_typeswitchloop(VALptr(v), v->vtype, false,
bi.base, bi.type, true,
Tloc(bn, 0), tp,
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
@@ -841,18 +841,27 @@ BATcalcop(BAT *b1, BAT *b2, BAT *s1, BAT
BATcheck(b1, NULL);
BATcheck(b2, NULL);
- canditer_init(&ci1, b1, s1);
- canditer_init(&ci2, b2, s2);
+ BATiter b1i = bat_iterator(b1);
+ BATiter b2i = bat_iterator(b2);
+ canditer_init_bi(&ci1, &b1i, s1);
+ canditer_init_bi(&ci2, &b2i, s2);
if (ci1.ncand != ci2.ncand || ci1.hseq != ci2.hseq) {
+ bat_iterator_end(&b1i);
+ bat_iterator_end(&b2i);
GDKerror("inputs not the same size.\n");
return NULL;
}
- if (ci1.ncand == 0)
+ if (ci1.ncand == 0) {
+ bat_iterator_end(&b1i);
+ bat_iterator_end(&b2i);
return COLnew(ci1.hseq, TYPE_TPE, 0, TRANSIENT);
+ }
if (BATtvoid(b1) && BATtvoid(b2) && ci1.tpe == cand_dense && ci2.tpe ==
cand_dense) {
TPE res;
+ bat_iterator_end(&b1i);
+ bat_iterator_end(&b2i);
if ((is_oid_nil(b1->tseqbase) || is_oid_nil(b2->tseqbase))
#ifdef NIL_MATCHES_FLAG
&& !nil_matches
@@ -865,8 +874,6 @@ BATcalcop(BAT *b1, BAT *b2, BAT *s1, BAT
return BATconstant(b1->hseqbase, TYPE_TPE, &res, ci1.ncand,
TRANSIENT);
}
- BATiter b1i = bat_iterator(b1);
- BATiter b2i = bat_iterator(b2);
BAT *bn = BATcalcop_intern(b1i.type == TYPE_void ? (const void *)
&b1->tseqbase : (const void *) b1i.base,
ATOMtype(b1i.type) == TYPE_oid ? b1i.type :
ATOMbasetype(b1i.type),
true,
@@ -901,11 +908,13 @@ BATcalcopcst(BAT *b, const ValRecord *v,
BATcheck(b, NULL);
- canditer_init(&ci, b, s);
- if (ci.ncand == 0)
+ BATiter bi = bat_iterator(b);
+ canditer_init_bi(&ci, &bi, s);
+ if (ci.ncand == 0) {
+ bat_iterator_end(&bi);
return COLnew(ci.hseq, TYPE_TPE, 0, TRANSIENT);
+ }
- BATiter bi = bat_iterator(b);
BAT *bn = BATcalcop_intern(bi.type == TYPE_void ? (const void *)
&b->tseqbase : (const void *) bi.base,
ATOMtype(bi.type) == TYPE_oid ? bi.type :
ATOMbasetype(bi.type),
true,
@@ -940,11 +949,13 @@ BATcalccstop(const ValRecord *v, BAT *b,
BATcheck(b, NULL);
- canditer_init(&ci, b, s);
- if (ci.ncand == 0)
+ BATiter bi = bat_iterator(b);
+ canditer_init_bi(&ci, &bi, s);
+ if (ci.ncand == 0) {
+ bat_iterator_end(&bi);
return COLnew(ci.hseq, TYPE_TPE, 0, TRANSIENT);
+ }
- BATiter bi = bat_iterator(b);
BAT *bn = BATcalcop_intern(VALptr(v),
ATOMtype(v->vtype) == TYPE_oid ? v->vtype :
ATOMbasetype(v->vtype),
false,
diff --git a/gdk/gdk_calc_convert.c b/gdk/gdk_calc_convert.c
--- a/gdk/gdk_calc_convert.c
+++ b/gdk/gdk_calc_convert.c
@@ -1848,8 +1848,8 @@ BATconvert(BAT *b, BAT *s, int tp,
tp = TYPE_oid;
BATiter bi = bat_iterator(b);
- cnt = BATcount(b);
- canditer_init(&ci, b, s);
+ cnt = bi.count;
+ canditer_init_bi(&ci, &bi, s);
if (ci.ncand == 0 || (bi.type == TYPE_void && is_oid_nil(b->tseqbase)))
{
bat_iterator_end(&bi);
return BATconstant(ci.hseq, tp,
diff --git a/gdk/gdk_calc_div.c b/gdk/gdk_calc_div.c
--- a/gdk/gdk_calc_div.c
+++ b/gdk/gdk_calc_div.c
@@ -1958,15 +1958,15 @@ BATcalcdivcst(BAT *b, const ValRecord *v
BATcheck(b, NULL);
- canditer_init(&ci, b, s);
+ BATiter bi = bat_iterator(b);
+ canditer_init_bi(&ci, &bi, s);
bn = COLnew(ci.hseq, tp, ci.ncand, TRANSIENT);
- if (bn == NULL)
- return NULL;
- if (ci.ncand == 0)
+ if (bn == NULL || ci.ncand == 0) {
+ bat_iterator_end(&bi);
return bn;
+ }
- BATiter bi = bat_iterator(b);
nils = div_typeswitchloop(bi.base, bi.type, true,
VALptr(v), v->vtype, false,
Tloc(bn, 0), tp,
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]