Changeset: 397d5c1c0d32 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/397d5c1c0d32
Modified Files:
clients/Tests/exports.stable.out
gdk/gdk.h
gdk/gdk_aggr.c
gdk/gdk_batop.c
gdk/gdk_calc.c
gdk/gdk_cand.c
gdk/gdk_select.c
Branch: default
Log Message:
New interface canditer_init_bi to initialize candidate iterator using bat
iterator.
Using this, both iterators use the same view of the universe.
Conversion to the new interface is only partially done.
diffs (truncated from 1123 to 300 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -473,6 +473,7 @@ ssize_t bteToStr(allocator *ma, char **d
const bte bte_nil;
oid canditer_idx(const struct canditer *ci, BUN p);
void canditer_init(struct canditer *ci, BAT *b, BAT *s);
+void canditer_init_bi(struct canditer *ci, BATiter *bi, BAT *s);
oid canditer_last(const struct canditer *ci);
oid canditer_mask_next(const struct canditer *ci, oid o, bool next);
oid canditer_peek(const struct canditer *ci);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -2759,6 +2759,8 @@ canditer_next(struct canditer *ci)
gdk_export void canditer_init(struct canditer *ci, BAT *b, BAT *s)
ATTR_ACCESS(write_only, 1);
+gdk_export void canditer_init_bi(struct canditer *ci, BATiter *bi, BAT *s)
+ ATTR_ACCESS(write_only, 1);
gdk_export oid canditer_peek(const struct canditer *ci)
ATTR_PURE;
gdk_export oid canditer_last(const struct canditer *ci)
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -3389,9 +3389,10 @@ BATcalcavg(BAT *b, BAT *s, dbl *avg, BUN
QryCtx *qry_ctx = MT_thread_get_qry_ctx();
- canditer_init(&ci, b, s);
-
BATiter bi = bat_iterator(b);
+
+ canditer_init_bi(&ci, &bi, s);
+
src = bi.base;
switch (b->ttype) {
@@ -4069,7 +4070,7 @@ BATmin_skipnil(allocator *ma, BAT *b, vo
HEAPdecref(oidxh, false);
} else {
struct canditer ci;
- canditer_init(&ci, b, NULL);
+ canditer_init_bi(&ci, &bi, NULL);
(void) do_groupmin(&pos, &bi, NULL, 1, 0, 0,
&ci,
skipnil, false);
}
@@ -4204,7 +4205,7 @@ BATmax_skipnil(allocator *ma, BAT *b, vo
HEAPdecref(oidxh, false);
} else {
struct canditer ci;
- canditer_init(&ci, b, NULL);
+ canditer_init_bi(&ci, &bi, NULL);
(void) do_groupmax(&pos, &bi, NULL, 1, 0, 0,
&ci,
skipnil, false);
}
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -824,8 +824,11 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool
if (b == NULL || n == NULL || BATcount(n) == 0) {
return GDK_SUCCEED;
}
- canditer_init(&ci, n, s);
+
+ BATiter ni = bat_iterator(n);
+ canditer_init_bi(&ci, &ni, s);
if (ci.ncand == 0) {
+ bat_iterator_end(&ni);
return GDK_SUCCEED;
}
@@ -839,7 +842,8 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool
ALIGNapp(b, force, GDK_FAIL);
if (ATOMstorage(ATOMtype(b->ttype)) != ATOMstorage(ATOMtype(n->ttype)))
{
- GDKerror("Incompatible operands ("ALGOBATFMT" vs.
"ALGOBATFMT").\n", ALGOBATPAR(b), ALGOBATPAR(n));
+ GDKerror("Incompatible operands ("ALGOBATFMT" vs.
"ALGOBATFMT").\n", ALGOBATPAR(b), ALGOBATIPAR(&ni));
+ bat_iterator_end(&ni);
return GDK_FAIL;
}
@@ -851,8 +855,6 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool
QryCtx *qry_ctx = MT_thread_get_qry_ctx();
- BATiter ni = bat_iterator(n);
-
if (BATcount(b) + ci.ncand > BUN_MAX) {
bat_iterator_end(&ni);
GDKerror("combined BATs too large\n");
@@ -3411,8 +3413,8 @@ BATcount_no_nil(BAT *b, BAT *s)
BATcheck(b, 0);
hseq = b->hseqbase;
- canditer_init(&ci, b, s);
BATiter bi = bat_iterator(b);
+ canditer_init_bi(&ci, &bi, s);
if (bi.nonil) {
bat_iterator_end(&bi);
return ci.ncand;
diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -57,17 +57,21 @@ BATcalcnot(BAT *b, BAT *s)
BATcheck(b, NULL);
+ BATiter bi = bat_iterator(b);
bhseqbase = b->hseqbase;
- canditer_init(&ci, b, s);
- if (ci.ncand == 0)
+ canditer_init_bi(&ci, &bi, s);
+ if (ci.ncand == 0) {
+ bat_iterator_end(&bi);
return BATconstant(ci.hseq, b->ttype,
ATOMnilptr(b->ttype), ci.ncand, TRANSIENT);
+ }
bn = COLnew(ci.hseq, b->ttype, ci.ncand, TRANSIENT);
- if (bn == NULL)
+ if (bn == NULL) {
+ bat_iterator_end(&bi);
return NULL;
-
- BATiter bi = bat_iterator(b);
+ }
+
switch (ATOMbasetype(bi.type)) {
case TYPE_msk:
if (ci.tpe == cand_dense) {
@@ -148,7 +152,7 @@ BATcalcnot(BAT *b, BAT *s)
return bn;
-bailout:
+ bailout:
bat_iterator_end(&bi);
BBPunfix(bn->batCacheid);
return NULL;
@@ -268,17 +272,21 @@ BATcalcnegate(BAT *b, BAT *s)
BATcheck(b, NULL);
+ BATiter bi = bat_iterator(b);
bhseqbase = b->hseqbase;
- canditer_init(&ci, b, s);
- if (ci.ncand == 0)
+ canditer_init_bi(&ci, &bi, s);
+ if (ci.ncand == 0) {
+ bat_iterator_end(&bi);
return BATconstant(ci.hseq, b->ttype,
ATOMnilptr(b->ttype), ci.ncand, TRANSIENT);
+ }
bn = COLnew(ci.hseq, b->ttype, ci.ncand, TRANSIENT);
- if (bn == NULL)
+ if (bn == NULL) {
+ bat_iterator_end(&bi);
return NULL;
-
- BATiter bi = bat_iterator(b);
+ }
+
switch (ATOMbasetype(bi.type)) {
case TYPE_bte:
UNARY_2TYPE_FUNC(bte, bte, NEGATE);
@@ -406,17 +414,21 @@ BATcalcabsolute(BAT *b, BAT *s)
BATcheck(b, NULL);
+ BATiter bi = bat_iterator(b);
bhseqbase = b->hseqbase;
- canditer_init(&ci, b, s);
- if (ci.ncand == 0)
+ canditer_init_bi(&ci, &bi, s);
+ if (ci.ncand == 0) {
+ bat_iterator_end(&bi);
return BATconstant(ci.hseq, b->ttype,
ATOMnilptr(b->ttype), ci.ncand, TRANSIENT);
+ }
bn = COLnew(ci.hseq, b->ttype, ci.ncand, TRANSIENT);
- if (bn == NULL)
+ if (bn == NULL) {
+ bat_iterator_end(&bi);
return NULL;
-
- BATiter bi = bat_iterator(b);
+ }
+
switch (ATOMbasetype(bi.type)) {
case TYPE_bte:
UNARY_2TYPE_FUNC(bte, bte, (bte) abs);
@@ -548,16 +560,20 @@ BATcalciszero(BAT *b, BAT *s)
BATcheck(b, NULL);
bhseqbase = b->hseqbase;
- 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 BATconstant(ci.hseq, TYPE_bit,
ATOMnilptr(TYPE_bit), ci.ncand, TRANSIENT);
+ }
bn = COLnew(ci.hseq, TYPE_bit, ci.ncand, TRANSIENT);
- if (bn == NULL)
+ if (bn == NULL) {
+ bat_iterator_end(&bi);
return NULL;
-
- BATiter bi = bat_iterator(b);
+ }
+
switch (ATOMbasetype(bi.type)) {
case TYPE_bte:
UNARY_2TYPE_FUNC(bte, bit, ISZERO);
@@ -687,16 +703,20 @@ BATcalcsign(BAT *b, BAT *s)
BATcheck(b, NULL);
bhseqbase = b->hseqbase;
- 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 BATconstant(ci.hseq, TYPE_bte,
ATOMnilptr(TYPE_bte), ci.ncand, TRANSIENT);
+ }
bn = COLnew(ci.hseq, TYPE_bte, ci.ncand, TRANSIENT);
- if (bn == NULL)
+ if (bn == NULL) {
+ bat_iterator_end(&bi);
return NULL;
-
- BATiter bi = bat_iterator(b);
+ }
+
switch (ATOMbasetype(bi.type)) {
case TYPE_bte:
UNARY_2TYPE_FUNC(bte, bte, SIGN);
@@ -839,25 +859,29 @@ BATcalcisnil_implementation(BAT *b, BAT
BATcheck(b, NULL);
bhseqbase = b->hseqbase;
+ BATiter bi = bat_iterator(b);
canditer_init(&ci, b, s);
if (b->tnonil || BATtdense(b)) {
+ bat_iterator_end(&bi);
return BATconstant(ci.hseq, TYPE_bit, &(bit){notnil},
ci.ncand, TRANSIENT);
} else if (b->ttype == TYPE_void) {
/* non-nil handled above */
assert(is_oid_nil(b->tseqbase));
+ bat_iterator_end(&bi);
return BATconstant(ci.hseq, TYPE_bit, &(bit){!notnil},
ci.ncand, TRANSIENT);
}
bn = COLnew(ci.hseq, TYPE_bit, ci.ncand, TRANSIENT);
- if (bn == NULL)
+ if (bn == NULL) {
+ bat_iterator_end(&bi);
return NULL;
+ }
dst = (bit *) Tloc(bn, 0);
- BATiter bi = bat_iterator(b);
switch (ATOMbasetype(bi.type)) {
case TYPE_bte:
ISNIL_TYPE(bte, notnil);
@@ -1023,19 +1047,24 @@ BATcalcmin(BAT *b1, BAT *b2, BAT *s1, BA
return 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, ATOMtype(b1->ttype), ci1.ncand, TRANSIENT);
- if (bn == NULL)
+ if (bn == NULL) {
+ bat_iterator_end(&b1i);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]