Changeset: 92d31aae167c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=92d31aae167c
Modified Files:
        gdk/gdk_calc.c
Branch: gdk-calc
Log Message:

Don't require dense head but copy head column to result bat.


diffs (truncated from 860 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
@@ -31,23 +31,11 @@
 static int
 checkbats(BAT *b1, BAT *b2, const char *func)
 {
-       if (!BAThdense(b1) || (b2 != NULL && !BAThdense(b2))) {
-               GDKerror("%s: head must be oid/dense.\n", func);
-               return GDK_FAIL;
-       }
        if (b2 != NULL) {
-               if (!BAThdense(b2)) {
-                       GDKerror("%s: head must be oid/dense.\n", func);
-                       return GDK_FAIL;
-               }
                if (b1->U->count != b2->U->count) {
                        GDKerror("%s: inputs not the same size.\n", func);
                        return GDK_FAIL;
                }
-               if (b1->H->seq != b2->H->seq) {
-                       GDKerror("%s: inputs not aligned.\n", func);
-                       return GDK_FAIL;
-               }
        }
        return GDK_SUCCEED;
 }
@@ -205,6 +193,12 @@ BATcalcnot(BAT *b, int accum)
                b->P->descdirty = 1;
        }
 
+       if (!accum && b->H->type != bn->H->type) {
+               BAT *bnn = VIEWcreate(b, bn);
+               BBPunfix(bn->batCacheid);
+               bn = bnn;
+       }
+
        return bn;
 }
 
@@ -326,6 +320,12 @@ BATcalcnegate(BAT *b, int accum)
                b->P->descdirty = 1;
        }
 
+       if (!accum && b->H->type != bn->H->type) {
+               BAT *bnn = VIEWcreate(b, bn);
+               BBPunfix(bn->batCacheid);
+               bn = bnn;
+       }
+
        return bn;
 }
 
@@ -453,6 +453,12 @@ BATcalcabsolute(BAT *b, int accum)
                b->P->descdirty = 1;
        }
 
+       if (!accum && b->H->type != bn->H->type) {
+               BAT *bnn = VIEWcreate(b, bn);
+               BBPunfix(bn->batCacheid);
+               bn = bnn;
+       }
+
        return bn;
 }
 
@@ -569,6 +575,12 @@ BATcalciszero(BAT *b)
                b->P->descdirty = 1;
        }
 
+       if (b->H->type != bn->H->type) {
+               BAT *bnn = VIEWcreate(b, bn);
+               BBPunfix(bn->batCacheid);
+               bn = bnn;
+       }
+
        return bn;
 }
 
@@ -685,6 +697,12 @@ BATcalcsign(BAT *b)
                b->P->descdirty = 1;
        }
 
+       if (b->H->type != bn->H->type) {
+               BAT *bnn = VIEWcreate(b, bn);
+               BBPunfix(bn->batCacheid);
+               bn = bnn;
+       }
+
        return bn;
 }
 
@@ -821,6 +839,12 @@ BATcalcisnil(BAT *b)
        bn->T->nonil = 1;
        bn->T->key = bn->U->count <= 1;
 
+       if (b->H->type != bn->H->type) {
+               BAT *bnn = VIEWcreate(b, bn);
+               BBPunfix(bn->batCacheid);
+               bn = bnn;
+       }
+
        return bn;
 }
 
@@ -1838,6 +1862,12 @@ BATcalcadd(BAT *b1, BAT *b2, int tp, int
        bn->T->nil = nils != 0;
        bn->T->nonil = nils == 0;
 
+       if (!accum && b1->H->type != bn->H->type) {
+               BAT *bnn = VIEWcreate(b1, bn);
+               BBPunfix(bn->batCacheid);
+               bn = bnn;
+       }
+
        return bn;
 }
 
@@ -1890,6 +1920,12 @@ BATcalcaddcst(BAT *b, const ValRecord *v
        bn->T->nil = nils != 0;
        bn->T->nonil = nils == 0;
 
+       if (!accum && b->H->type != bn->H->type) {
+               BAT *bnn = VIEWcreate(b, bn);
+               BBPunfix(bn->batCacheid);
+               bn = bnn;
+       }
+
        return bn;
 }
 
@@ -1942,6 +1978,12 @@ BATcalccstadd(const ValRecord *v, BAT *b
        bn->T->nil = nils != 0;
        bn->T->nonil = nils == 0;
 
+       if (!accum && b->H->type != bn->H->type) {
+               BAT *bnn = VIEWcreate(b, bn);
+               BBPunfix(bn->batCacheid);
+               bn = bnn;
+       }
+
        return bn;
 }
 
@@ -2013,6 +2055,12 @@ BATcalcincr(BAT *b, int accum, int abort
                b->P->descdirty = 1;
        }
 
+       if (!accum && b->H->type != bn->H->type) {
+               BAT *bnn = VIEWcreate(b, bn);
+               BBPunfix(bn->batCacheid);
+               bn = bnn;
+       }
+
        return bn;
 }
 
@@ -2975,6 +3023,12 @@ BATcalcsub(BAT *b1, BAT *b2, int tp, int
        bn->T->nil = nils != 0;
        bn->T->nonil = nils == 0;
 
+       if (!accum && b1->H->type != bn->H->type) {
+               BAT *bnn = VIEWcreate(b1, bn);
+               BBPunfix(bn->batCacheid);
+               bn = bnn;
+       }
+
        return bn;
 }
 
@@ -3027,6 +3081,12 @@ BATcalcsubcst(BAT *b, const ValRecord *v
        bn->T->nil = nils != 0;
        bn->T->nonil = nils == 0;
 
+       if (!accum && b->H->type != bn->H->type) {
+               BAT *bnn = VIEWcreate(b, bn);
+               BBPunfix(bn->batCacheid);
+               bn = bnn;
+       }
+
        return bn;
 }
 
@@ -3079,6 +3139,12 @@ BATcalccstsub(const ValRecord *v, BAT *b
        bn->T->nil = nils != 0;
        bn->T->nonil = nils == 0;
 
+       if (!accum && b->H->type != bn->H->type) {
+               BAT *bnn = VIEWcreate(b, bn);
+               BBPunfix(bn->batCacheid);
+               bn = bnn;
+       }
+
        return bn;
 }
 
@@ -3150,6 +3216,12 @@ BATcalcdecr(BAT *b, int accum, int abort
                b->P->descdirty = 1;
        }
 
+       if (!accum && b->H->type != bn->H->type) {
+               BAT *bnn = VIEWcreate(b, bn);
+               BBPunfix(bn->batCacheid);
+               bn = bnn;
+       }
+
        return bn;
 }
 
@@ -4193,6 +4265,12 @@ BATcalcmul(BAT *b1, BAT *b2, int tp, int
        bn->T->nil = nils != 0;
        bn->T->nonil = nils == 0;
 
+       if (!accum && b1->H->type != bn->H->type) {
+               BAT *bnn = VIEWcreate(b1, bn);
+               BBPunfix(bn->batCacheid);
+               bn = bnn;
+       }
+
        return bn;
 }
 
@@ -4245,6 +4323,12 @@ BATcalcmulcst(BAT *b, const ValRecord *v
        bn->T->nil = nils != 0;
        bn->T->nonil = nils == 0;
 
+       if (!accum && b->H->type != bn->H->type) {
+               BAT *bnn = VIEWcreate(b, bn);
+               BBPunfix(bn->batCacheid);
+               bn = bnn;
+       }
+
        return bn;
 }
 
@@ -4297,6 +4381,12 @@ BATcalccstmul(const ValRecord *v, BAT *b
        bn->T->nil = nils != 0;
        bn->T->nonil = nils == 0;
 
+       if (!accum && b->H->type != bn->H->type) {
+               BAT *bnn = VIEWcreate(b, bn);
+               BBPunfix(bn->batCacheid);
+               bn = bnn;
+       }
+
        return bn;
 }
 
@@ -5356,6 +5446,12 @@ BATcalcdiv(BAT *b1, BAT *b2, int tp, int
        bn->T->nil = nils != 0;
        bn->T->nonil = nils == 0;
 
+       if (!accum && b1->H->type != bn->H->type) {
+               BAT *bnn = VIEWcreate(b1, bn);
+               BBPunfix(bn->batCacheid);
+               bn = bnn;
+       }
+
        return bn;
 }
 
@@ -5408,6 +5504,12 @@ BATcalcdivcst(BAT *b, const ValRecord *v
        bn->T->nil = nils != 0;
        bn->T->nonil = nils == 0;
 
+       if (!accum && b->H->type != bn->H->type) {
+               BAT *bnn = VIEWcreate(b, bn);
+               BBPunfix(bn->batCacheid);
+               bn = bnn;
+       }
+
        return bn;
 }
 
@@ -5460,6 +5562,12 @@ BATcalccstdiv(const ValRecord *v, BAT *b
        bn->T->nil = nils != 0;
        bn->T->nonil = nils == 0;
 
+       if (!accum && b->H->type != bn->H->type) {
+               BAT *bnn = VIEWcreate(b, bn);
+               BBPunfix(bn->batCacheid);
+               bn = bnn;
+       }
+
        return bn;
 }
 
@@ -6064,6 +6172,12 @@ BATcalcmod(BAT *b1, BAT *b2, int tp, int
        bn->T->nil = nils != 0;
        bn->T->nonil = nils == 0;
 
+       if (!accum && b1->H->type != bn->H->type) {
+               BAT *bnn = VIEWcreate(b1, bn);
+               BBPunfix(bn->batCacheid);
+               bn = bnn;
+       }
+
        return bn;
 }
 
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to