Changeset: 70b034f342d0 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=70b034f342d0
Modified Files:
        gdk/gdk_aggr.c
        monetdb5/modules/mal/batcalc.c
Branch: default
Log Message:

Cleanup: don't accept non-dense heads in batcalc and for aggregates.


diffs (truncated from 545 to 300 lines):

diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -2396,11 +2396,8 @@ BATminmax(BAT *b, void *aggr,
        int needdecref = 0;
        BATiter bi;
 
-       if (!BAThdense(b)) {
-               if ((b = BATmirror(BATmark(BATmirror(b), 0))) == NULL)
-                       return NULL;
-               needdecref = 1;
-       }
+       if (!BAThdense(b))
+               return NULL;
        if (b->T->imprints &&
            (VIEWtparent(b) == 0 ||
             BATcount(b) == BATcount(BBPdescriptor(VIEWtparent(b))))) {
diff --git a/monetdb5/modules/mal/batcalc.c b/monetdb5/modules/mal/batcalc.c
--- a/monetdb5/modules/mal/batcalc.c
+++ b/monetdb5/modules/mal/batcalc.c
@@ -56,11 +56,12 @@ CMDbatUNARY(MalStkPtr stk, InstrPtr pci,
                        BAT *(*batfunc)(BAT *, BAT *), const char *malfunc)
 {
        bat *bid;
-       BAT *bn, *b, *s = NULL, *t, *map;
+       BAT *bn, *b, *s = NULL;
 
        bid = getArgReference_bat(stk, pci, 1);
        if ((b = BATdescriptor(*bid)) == NULL)
                throw(MAL, malfunc, RUNTIME_OBJECT_MISSING);
+       assert(BAThdense(b));
        if (pci->argc == 3) {
                bat *sid = getArgReference_bat(stk, pci, 2);
                if (*sid && (s = BATdescriptor(*sid)) == NULL) {
@@ -69,30 +70,13 @@ CMDbatUNARY(MalStkPtr stk, InstrPtr pci,
                }
        }
 
-       if (!BAThdense(b)) {
-               map = BATmark(b, 0);
-               t = BATmirror(BATmark(BATmirror(b), 0));
-               BBPunfix(b->batCacheid);
-               b = t;
-               assert(s == NULL);
-       } else {
-               map = NULL;
-       }
        bn = (*batfunc)(b, s);
        BBPunfix(b->batCacheid);
        if (s)
                BBPunfix(s->batCacheid);
        if (bn == NULL) {
-               if (map)
-                       BBPunfix(map->batCacheid);
                return mythrow(MAL, malfunc, OPERATION_FAILED);
        }
-       if (map) {
-               t = BATleftfetchjoin(map, bn, BATcount(bn));
-               BBPunfix(bn->batCacheid);
-               bn = t;
-               BBPunfix(map->batCacheid);
-       }
        bid = getArgReference_bat(stk, pci, 0);
        BBPkeepref(*bid = bn->batCacheid);
        return MAL_SUCCEED;
@@ -103,11 +87,12 @@ CMDbatUNARY1(MalStkPtr stk, InstrPtr pci
                         BAT *(*batfunc)(BAT *, BAT *, int), const char 
*malfunc)
 {
        bat *bid;
-       BAT *bn, *b, *s = NULL, *t, *map;
+       BAT *bn, *b, *s = NULL;
 
        bid = getArgReference_bat(stk, pci, 1);
        if ((b = BATdescriptor(*bid)) == NULL)
                throw(MAL, malfunc, RUNTIME_OBJECT_MISSING);
+       assert(BAThdense(b));
        if (pci->argc == 3) {
                bat *sid = getArgReference_bat(stk, pci, 2);
                if (*sid && (s = BATdescriptor(*sid)) == NULL) {
@@ -116,30 +101,13 @@ CMDbatUNARY1(MalStkPtr stk, InstrPtr pci
                }
        }
 
-       if (!BAThdense(b)) {
-               map = BATmark(b, 0);
-               t = BATmirror(BATmark(BATmirror(b), 0));
-               BBPunfix(b->batCacheid);
-               b = t;
-               assert(s == NULL);
-       } else {
-               map = NULL;
-       }
        bn = (*batfunc)(b, s, abort_on_error);
        BBPunfix(b->batCacheid);
        if (s)
                BBPunfix(s->batCacheid);
        if (bn == NULL) {
-               if (map)
-                       BBPunfix(map->batCacheid);
                return mythrow(MAL, malfunc, OPERATION_FAILED);
        }
-       if (map) {
-               t = BATleftfetchjoin(map, bn, BATcount(bn));
-               BBPunfix(bn->batCacheid);
-               bn = t;
-               BBPunfix(map->batCacheid);
-       }
        bid = getArgReference_bat(stk, pci, 0);
        BBPkeepref(*bid = bn->batCacheid);
        return MAL_SUCCEED;
@@ -354,7 +322,7 @@ CMDbatBINARY2(MalStkPtr stk, InstrPtr pc
                          int abort_on_error, const char *malfunc)
 {
        bat *bid;
-       BAT *bn, *b, *s = NULL, *t, *map;
+       BAT *bn, *b, *s = NULL;
        int tp1, tp2;
 
        tp1 = stk->stk[getArg(pci, 1)].vtype;
@@ -374,6 +342,7 @@ CMDbatBINARY2(MalStkPtr stk, InstrPtr pc
                                BBPunfix(s->batCacheid);
                        throw(MAL, malfunc, RUNTIME_OBJECT_MISSING);
                }
+               assert(BAThdense(b));
                if (tp2 == TYPE_bat || isaBatType(tp2)) {
                        bid = getArgReference_bat(stk, pci, 2);
                        b2 = BATdescriptor(*bid);
@@ -383,20 +352,7 @@ CMDbatBINARY2(MalStkPtr stk, InstrPtr pc
                                        BBPunfix(s->batCacheid);
                                throw(MAL, malfunc, RUNTIME_OBJECT_MISSING);
                        }
-               }
-               if (!BAThdense(b) || (b2 != NULL && !BAThdense(b2))) {
-                       map = BATmark(b, 0); /* [head,dense] */
-                       t = BATmirror(BATmark(BATmirror(b), 0)); /* 
[dense,tail] */
-                       BBPunfix(b->batCacheid);
-                       b = t;
-                       if (b2) {
-                               t = BATmirror(BATmark(BATmirror(b2), 0)); /* 
[dense,tail] */
-                               BBPunfix(b2->batCacheid);
-                               b2 = t;
-                       }
-                       assert(s == NULL);
-               } else {
-                       map = NULL;
+                       assert(BAThdense(b2));
                }
                if (b2) {
                        bn = (*batfunc)(b, b2, s, (*typefunc)(b->T->type, 
b2->T->type),
@@ -416,30 +372,14 @@ CMDbatBINARY2(MalStkPtr stk, InstrPtr pc
                                BBPunfix(s->batCacheid);
                        throw(MAL, malfunc, RUNTIME_OBJECT_MISSING);
                }
-               if (!BAThdense(b)) {
-                       map = BATmark(b, 0); /* [head,dense] */
-                       t = BATmirror(BATmark(BATmirror(b), 0)); /* 
[dense,tail] */
-                       BBPunfix(b->batCacheid);
-                       b = t;
-                       assert(s == NULL);
-               } else {
-                       map = NULL;
-               }
+               assert(BAThdense(b));
                bn = (*batfunc2)(&stk->stk[getArg(pci, 1)], b, s,
                                                 (*typefunc)(tp1, b->T->type), 
abort_on_error);
        }
        BBPunfix(b->batCacheid);
        if (bn == NULL) {
-               if (map)
-                       BBPunfix(map->batCacheid);
                return mythrow(MAL, malfunc, OPERATION_FAILED);
        }
-       if (map) {
-               t = BATleftfetchjoin(map, bn, BATcount(bn));
-               BBPunfix(bn->batCacheid);
-               bn = t;
-               BBPunfix(map->batCacheid);
-       }
        bid = getArgReference_bat(stk, pci, 0);
        BBPkeepref(*bid = bn->batCacheid);
        return MAL_SUCCEED;
@@ -454,7 +394,7 @@ CMDbatBINARY1(MalStkPtr stk, InstrPtr pc
                          const char *malfunc)
 {
        bat *bid;
-       BAT *bn, *b, *s = NULL, *t, *map;
+       BAT *bn, *b, *s = NULL;
        int tp1, tp2;
 
        tp1 = stk->stk[getArg(pci, 1)].vtype;
@@ -474,6 +414,7 @@ CMDbatBINARY1(MalStkPtr stk, InstrPtr pc
                                BBPunfix(s->batCacheid);
                        throw(MAL, malfunc, RUNTIME_OBJECT_MISSING);
                }
+               assert(BAThdense(b));
                if (tp2 == TYPE_bat || isaBatType(tp2)) {
                        bid = getArgReference_bat(stk, pci, 2);
                        b2 = BATdescriptor(*bid);
@@ -483,20 +424,7 @@ CMDbatBINARY1(MalStkPtr stk, InstrPtr pc
                                        BBPunfix(s->batCacheid);
                                throw(MAL, malfunc, RUNTIME_OBJECT_MISSING);
                        }
-               }
-               if (!BAThdense(b) || (b2 != NULL && !BAThdense(b2))) {
-                       map = BATmark(b, 0); /* [head,dense] */
-                       t = BATmirror(BATmark(BATmirror(b), 0)); /* 
[dense,tail] */
-                       BBPunfix(b->batCacheid);
-                       b = t;
-                       if (b2) {
-                               t = BATmirror(BATmark(BATmirror(b2), 0)); /* 
[dense,tail] */
-                               BBPunfix(b2->batCacheid);
-                               b2 = t;
-                       }
-                       assert(s == NULL);
-               } else {
-                       map = NULL;
+                       assert(BAThdense(b));
                }
                if (b2) {
                        bn = (*batfunc)(b, b2, s, abort_on_error);
@@ -514,31 +442,15 @@ CMDbatBINARY1(MalStkPtr stk, InstrPtr pc
                                BBPunfix(s->batCacheid);
                        throw(MAL, malfunc, RUNTIME_OBJECT_MISSING);
                }
-               if (!BAThdense(b)) {
-                       map = BATmark(b, 0); /* [head,dense] */
-                       t = BATmirror(BATmark(BATmirror(b), 0)); /* 
[dense,tail] */
-                       BBPunfix(b->batCacheid);
-                       b = t;
-                       assert(s == NULL);
-               } else {
-                       map = NULL;
-               }
+               assert(BAThdense(b));
                bn = (*batfunc2)(&stk->stk[getArg(pci, 1)], b, s, 
abort_on_error);
        }
        BBPunfix(b->batCacheid);
        if (s)
                BBPunfix(s->batCacheid);
        if (bn == NULL) {
-               if (map)
-                       BBPunfix(map->batCacheid);
                return mythrow(MAL, malfunc, OPERATION_FAILED);
        }
-       if (map) {
-               t = BATleftfetchjoin(map, bn, BATcount(bn));
-               BBPunfix(bn->batCacheid);
-               bn = t;
-               BBPunfix(map->batCacheid);
-       }
        bid = getArgReference_bat(stk, pci, 0);
        BBPkeepref(*bid = bn->batCacheid);
        return MAL_SUCCEED;
@@ -552,7 +464,7 @@ CMDbatBINARY0(MalStkPtr stk, InstrPtr pc
                          const char *malfunc)
 {
        bat *bid;
-       BAT *bn, *b, *s = NULL, *t, *map;
+       BAT *bn, *b, *s = NULL;
        int tp1, tp2;
 
        tp1 = stk->stk[getArg(pci, 1)].vtype;
@@ -572,6 +484,7 @@ CMDbatBINARY0(MalStkPtr stk, InstrPtr pc
                                BBPunfix(s->batCacheid);
                        throw(MAL, malfunc, RUNTIME_OBJECT_MISSING);
                }
+               assert(BAThdense(b));
                if (tp2 == TYPE_bat || isaBatType(tp2)) {
                        bid = getArgReference_bat(stk, pci, 2);
                        b2 = BATdescriptor(*bid);
@@ -581,20 +494,7 @@ CMDbatBINARY0(MalStkPtr stk, InstrPtr pc
                                        BBPunfix(s->batCacheid);
                                throw(MAL, malfunc, RUNTIME_OBJECT_MISSING);
                        }
-               }
-               if (!BAThdense(b) || (b2 != NULL && !BAThdense(b2))) {
-                       map = BATmark(b, 0); /* [head,dense] */
-                       t = BATmirror(BATmark(BATmirror(b), 0)); /* 
[dense,tail] */
-                       BBPunfix(b->batCacheid);
-                       b = t;
-                       if (b2) {
-                               t = BATmirror(BATmark(BATmirror(b2), 0)); /* 
[dense,tail] */
-                               BBPunfix(b2->batCacheid);
-                               b2 = t;
-                       }
-                       assert(s == NULL);
-               } else {
-                       map = NULL;
+                       assert(BAThdense(b));
                }
                if (b2) {
                        bn = (*batfunc)(b, b2, s);
@@ -619,30 +519,15 @@ CMDbatBINARY0(MalStkPtr stk, InstrPtr pc
                                BBPunfix(s->batCacheid);
                        throw(MAL, malfunc, RUNTIME_OBJECT_MISSING);
                }
-               if (!BAThdense(b)) {
-                       map = BATmark(b, 0); /* [head,dense] */
-                       t = BATmirror(BATmark(BATmirror(b), 0)); /* 
[dense,tail] */
-                       BBPunfix(b->batCacheid);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to