Changeset: 822e78b1baa5 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=822e78b1baa5
Modified Files:
        monetdb5/modules/kernel/aggr_be_avg.mx
        monetdb5/modules/kernel/aggr_be_count.mx
        monetdb5/modules/kernel/aggr_be_minmax.mx
        monetdb5/modules/kernel/aggr_be_prod.mx
        monetdb5/modules/kernel/aggr_be_sum.mx
        monetdb5/modules/kernel/aggr_bge_avg.mx
        monetdb5/modules/kernel/aggr_bge_count.mx
        monetdb5/modules/kernel/aggr_bge_minmax.mx
        monetdb5/modules/kernel/aggr_bge_prod.mx
        monetdb5/modules/kernel/aggr_bge_sum.mx
        monetdb5/modules/kernel/aggr_ri.mx
Branch: Oct2012
Log Message:

A more ellegant fix for bug 3152 - DO NOT PROPAGATE.


diffs (truncated from 378 to 300 lines):

diff --git a/monetdb5/modules/kernel/aggr_be_avg.mx 
b/monetdb5/modules/kernel/aggr_be_avg.mx
--- a/monetdb5/modules/kernel/aggr_be_avg.mx
+++ b/monetdb5/modules/kernel/aggr_be_avg.mx
@@ -218,6 +218,7 @@ CMDaggrX3_avg_@1(BAT **ret, BAT *b, BAT 
                BATgetId(b),BATgetId(e));
        /* init: set all sums & counts to zero and calculate min/max oid */
        @:init_result(dbl)@
+       @:finalize_result@
        bni = bat_iterator(bn);
        off = BUNfirst(bn);
        range = max - min + 1;
@@ -271,7 +272,6 @@ CMDaggrX3_avg_@1(BAT **ret, BAT *b, BAT 
                        
@:aggrX3_avg(0,1,HASHfnd_oid,loc,BUNhloc(bi,p),@1,@2,BUNt@2(bni,r),r-off)@
                }
        }
-
        *ret = bn;
        return GDK_SUCCEED;
 }
diff --git a/monetdb5/modules/kernel/aggr_be_count.mx 
b/monetdb5/modules/kernel/aggr_be_count.mx
--- a/monetdb5/modules/kernel/aggr_be_count.mx
+++ b/monetdb5/modules/kernel/aggr_be_count.mx
@@ -218,6 +218,7 @@ CMDaggrX3_count(BAT **ret, BAT *b, BAT *
 
        /* init: set all counts to zero and calculate min/max oid */
        @:init_result(wrd)@
+       @:finalize_result@
        bni = bat_iterator(bn);
        range = max - min + 1;
 
diff --git a/monetdb5/modules/kernel/aggr_be_minmax.mx 
b/monetdb5/modules/kernel/aggr_be_minmax.mx
--- a/monetdb5/modules/kernel/aggr_be_minmax.mx
+++ b/monetdb5/modules/kernel/aggr_be_minmax.mx
@@ -90,7 +90,7 @@ All Rights Reserved.
                        ptr t = BUNt@7(bi,p);
                        oid *h = (oid*) @5;
 
-                       @3(r, bni, h);
+                       @3(r, ei, h);
                        if (r != BUN_NONE) {
                                ptr *val = &extremes[@8];
                                if (*val == NULL || (*cmp)(t,*val) @1 0) {
@@ -103,7 +103,7 @@ All Rights Reserved.
                        ptr t = BUNt@7(bi,p);
                        oid *h = (oid*) @5;
 
-                       @3(r, bni, h);
+                       @3(r, ei, h);
                        if (r != BUN_NONE) {
                                ptr *val = &extremes[@8];
                                if (*val != nil) {
@@ -121,7 +121,7 @@ All Rights Reserved.
        /* insert the extreme values into the result */
        BATaccessBegin(bn,USE_HEAD|USE_TAIL,MMAP_SEQUENTIAL);
        BATloop(bn, r, q) {
-               oid *h = (oid*)BUNh@4(bni,r);
+               oid *h = (oid*)BUNh@4(ei,r);
                ptr val = extremes[@8];
                (void) h;       /* silence compiler about unused variable */
                /* trick: using a void head-type, only the tail are 
(over)written */
@@ -182,7 +182,7 @@ All Rights Reserved.
                        ptr t = BUNt@7(bi,p);
                        oid *h = (oid*) @5;
 
-                       @3(r, bni, h);
+                       @3(r, ei, h);
                        if (r != BUN_NONE) {
                                oid *val = &extremes[@8];
                                if ((*cmp)(t,val) @1 0) {
@@ -196,7 +196,7 @@ All Rights Reserved.
                        ptr t = BUNt@7(bi,p);
                        oid *h = (oid*) @5;
 
-                       @3(r, bni, h);
+                       @3(r, ei, h);
                        if (r != BUN_NONE) {
                                oid *val = &extremes[@8];
                                if (*val != *(oid*)nil) {
@@ -215,7 +215,7 @@ All Rights Reserved.
        /* insert the extreme values into the result */
        BATaccessBegin(bn,USE_HEAD|USE_TAIL,MMAP_SEQUENTIAL);
        BATloop(bn, r, q) {
-               oid *h = (oid*)BUNh@4(bni,r);
+               oid *h = (oid*)BUNh@4(ei,r);
                oid val = hit[@8] ? extremes[@8] : *(oid*)nil;
                (void) h;       /* silence compiler about unused variable */
                /* trick: using a void head-type, only the tail are 
(over)written */
@@ -239,7 +239,7 @@ static int
 aggrX3_@1_@3_@4_@5(BAT **ret, BAT *b, BAT *e)
 {
        BAT *bn;
-       BATiter bni, bi = bat_iterator(b);
+       BATiter bni, bi = bat_iterator(b), ei = bat_iterator(e);
        int (*cmp)(const void *, const void *);
        ptr nil;
        BUN off;
@@ -254,13 +254,7 @@ aggrX3_@1_@3_@4_@5(BAT **ret, BAT *b, BA
        oid bhsb;
        int b_use = USE_TAIL;
 
-       /* workaround for bug 3152: if type is str do not create a view and
-          because an assert will be triggered if the vheap is extended */
-       if (BATttype(b) == TYPE_str) {
-               bn = BATnew(TYPE_oid, BATttype(b), BATcount(e));
-       } else {
-               bn = BATnew(TYPE_void, BATttype(b), BATcount(e));
-       }
+       bn = BATnew(TYPE_void, BATttype(b), BATcount(e));
        if( bn == NULL) {
                GDKerror("aggrX3_@1_@3_@4_@5(): BATnew() failed");
                return GDK_FAIL;
@@ -268,14 +262,9 @@ aggrX3_@1_@3_@4_@5(BAT **ret, BAT *b, BA
 
        ALGODEBUG fprintf(stderr, "#aggrX3_@1_@3_@4_@5[@2,@6](b=%s,e=%s);\n",
                BATgetId(b),BATgetId(e));
-       /* do not do "the trick" if str */
-       if (BATttype(b) == TYPE_str) {
-               @:init_result(str)@
-       } else {
-               /* init: prepare the result bat;
-                * trick: by using "tail-type" void, we only write the head 
column, here */
-               @:init_result(void)@
-       }
+       /* init: prepare the result bat;
+        * trick: by using "tail-type" void, we only write the head column, 
here */
+       @:init_result(void)@
        bni = bat_iterator(bn);
        cmp = BATatoms[bn->ttype].atomCmp;
        nil =  ATOMnilptr(bn->ttype);
@@ -287,6 +276,7 @@ aggrX3_@1_@3_@4_@5(BAT **ret, BAT *b, BA
        slots = BATcount(e);
        if (slots == 0) {
                /* empty extend => empty result */
+               @:finalize_result@
                *ret = bn;
                return GDK_SUCCEED;
        }
@@ -332,6 +322,7 @@ aggrX3_@1_@3_@4_@5(BAT **ret, BAT *b, BA
                        
@:aggrX3_minmax_@5(@2,1,HASHfnd_oid,loc,BUNhloc(bi,p),@3,@4,r-off,@6)@
                }
        }
+       @:finalize_result@
        *ret = bn;
 bunins_failed:
        if (extremes)
diff --git a/monetdb5/modules/kernel/aggr_be_prod.mx 
b/monetdb5/modules/kernel/aggr_be_prod.mx
--- a/monetdb5/modules/kernel/aggr_be_prod.mx
+++ b/monetdb5/modules/kernel/aggr_be_prod.mx
@@ -216,6 +216,7 @@ CMDaggrX3_prod_@1_@3(BAT **ret, BAT *b, 
                BATgetId(b), BATgetId(e));
        /* init: set all prods to zero and calculate min/max oid */
        @:init_result(@3)@
+       @:finalize_result@
        bni = bat_iterator(bn);
        off = BUNfirst(bn);
        range = max - min + 1;
diff --git a/monetdb5/modules/kernel/aggr_be_sum.mx 
b/monetdb5/modules/kernel/aggr_be_sum.mx
--- a/monetdb5/modules/kernel/aggr_be_sum.mx
+++ b/monetdb5/modules/kernel/aggr_be_sum.mx
@@ -214,6 +214,7 @@ CMDaggrX3_sum_@1_@3(BAT **ret, BAT *b, B
                BATgetId(b), BATgetId(e));
        /* init: set all sums to zero and calculate min/max oid */
        @:init_result(@3)@
+       @:finalize_result@
        bni = bat_iterator(bn);
        off = BUNfirst(bn);
        range = max - min + 1;
diff --git a/monetdb5/modules/kernel/aggr_bge_avg.mx 
b/monetdb5/modules/kernel/aggr_bge_avg.mx
--- a/monetdb5/modules/kernel/aggr_bge_avg.mx
+++ b/monetdb5/modules/kernel/aggr_bge_avg.mx
@@ -263,6 +263,7 @@ CMDaggrX3_avg3_@1(BAT **ret, BAT *b, BAT
 
        /* init: set all sums & counts to zero and calculate min/max oid */
        @:init_result(dbl)@
+       @:finalize_result@
        bni = bat_iterator(bn);
        off = BUNfirst(bn);
        range = max - min + 1;
diff --git a/monetdb5/modules/kernel/aggr_bge_count.mx 
b/monetdb5/modules/kernel/aggr_bge_count.mx
--- a/monetdb5/modules/kernel/aggr_bge_count.mx
+++ b/monetdb5/modules/kernel/aggr_bge_count.mx
@@ -254,6 +254,7 @@ CMDaggrX3_count3(BAT **ret, BAT *b, BAT 
 
        /* init: set all counts to zero and calculate min/max oid */
        @:init_result(wrd)@
+       @:finalize_result@
        bni = bat_iterator(bn);
        bn->T->nonil = 1;
        range = max - min + 1;
diff --git a/monetdb5/modules/kernel/aggr_bge_minmax.mx 
b/monetdb5/modules/kernel/aggr_bge_minmax.mx
--- a/monetdb5/modules/kernel/aggr_bge_minmax.mx
+++ b/monetdb5/modules/kernel/aggr_bge_minmax.mx
@@ -102,7 +102,7 @@ All Rights Reserved.
        /* insert the extreme values into the result */
        BATaccessBegin(bn,USE_HEAD|USE_TAIL,MMAP_SEQUENTIAL);
        BATloop(bn, r, q) {
-               oid *h = (oid*)BUNh@4(bni,r);
+               oid *h = (oid*)BUNh@4(ei,r);
                ptr val = extremes[@8];
                (void) h;       /* silence compiler about unused variable */
                Tputvalue(bn, BUNtloc(bni,r), val?val:nil, 0);
@@ -125,7 +125,7 @@ All Rights Reserved.
                        if (w >= base && w < end) {
                                @[10];
 
-                               @3(r, bni, (oid*)h);
+                               @3(r, ei, (oid*)h);
                                if (r != BUN_NONE) {
                                        ptr *val = &extremes[@8];
                                        if (*val == NULL || (*cmp)(t,*val) @1 
0) {
@@ -143,7 +143,7 @@ All Rights Reserved.
                        if (w >= base && w < end) {
                                @[10];
 
-                               @3(r, bni, (oid*)h);
+                               @3(r, ei, (oid*)h);
                                if (r != BUN_NONE) {
                                        ptr *val = &extremes[@8];
                                        if (*val != nil) {
@@ -234,7 +234,7 @@ All Rights Reserved.
                        if (w >= base && w < end) {
                                @[10];
 
-                               @3(r, bni, (oid*)h);
+                               @3(r, ei, (oid*)h);
                                if (r != BUN_NONE) {
                                        oid *val = &extremes[@8];
                                        if ((*cmp)(t,val) @1 0) {
@@ -253,7 +253,7 @@ All Rights Reserved.
                        if (w >= base && w < end) {
                                @[10];
 
-                               @3(r, bni, (oid*)h);
+                               @3(r, ei, (oid*)h);
                                if (r != BUN_NONE) {
                                        oid *val = &extremes[@8];
                                        if (*val != *(oid*)nil) {
@@ -273,7 +273,7 @@ All Rights Reserved.
                BATaccessEnd(b,b_use,MMAP_SEQUENTIAL);
        /* insert the extreme values into the result */
        BATloop(bn, r, q) {
-               oid *h = (oid*)BUNh@4(bni,r);
+               oid *h = (oid*)BUNh@4(ei,r);
                oid val = hit[@8] ? extremes[@8] : *(oid*)nil;
                (void) h;       /* silence compiler about unused variable */
                Tputvalue(bn, BUNtloc(bni,r), &val, 0);
@@ -295,7 +295,7 @@ static int
 aggrX3_@13_@3_@4_@5(BAT **ret, BAT *b, BAT *g, BAT *e)
 {
        BAT *bn;
-       BATiter bni, bi = bat_iterator(b);
+       BATiter bni, bi = bat_iterator(b), ei = bat_iterator(e);
        int (*cmp)(const void *, const void *);
        ptr nil;
        BUN off;
@@ -326,26 +326,15 @@ aggrX3_@13_@3_@4_@5(BAT **ret, BAT *b, B
                return rtrn;
        }
 
-       /* workaround for bug 3152: if type is str do not create a view and
-          because an assert will be triggered if the vheap is extended */
-       if (BATttype(b) == TYPE_str) {
-               bn = BATnew(TYPE_oid, BATttype(b), BATcount(e));
-       } else {
-               bn = BATnew(TYPE_void, BATttype(b), BATcount(e));
-       }
+       bn = BATnew(TYPE_void, BATttype(b), BATcount(e));
        if( bn == NULL) {
                GDKerror("aggrX3_@13_@3_@4_@5(): BATnew() failed");
                return GDK_FAIL;
        }
 
-       /* do not do "the trick" if str */
-       if (BATttype(b) == TYPE_str) {
-               @:init_result(str)@
-       } else {
-               /* init: prepare the result bat;
-               * trick: by using "tail-type" void, we only write the head 
column, here */
-               @:init_result(void)@
-       }
+       /* init: prepare the result bat;
+       * trick: by using "tail-type" void, we only write the head column, here 
*/
+       @:init_result(void)@
        bni = bat_iterator(bn);
        cmp = BATatoms[bn->ttype].atomCmp;
        nil = ATOMnilptr(bn->ttype);
@@ -356,6 +345,7 @@ aggrX3_@13_@3_@4_@5(BAT **ret, BAT *b, B
        slots = BATcount(e);
        if (slots == 0) {
                /* empty extend => empty result */
+               @:finalize_result@
                *ret = bn;
                return GDK_SUCCEED;
        }
@@ -401,6 +391,7 @@ aggrX3_@13_@3_@4_@5(BAT **ret, BAT *b, B
                        
@:aggrX3_minmax3_@5(@2,1,HASHfnd_oid,loc,BUNhloc(bi,p),@3,@4,r-off,@6)@
                }
        }
+       @:finalize_result@
        *ret = bn;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to