Changeset: 929e19365437 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=929e19365437
Modified Files:
        monetdb5/modules/kernel/aggr_be_minmax.mx
        monetdb5/modules/kernel/aggr_bge_minmax.mx
        monetdb5/modules/kernel/aggr_ri.mx
Branch: Oct2012
Log Message:

A workaround fix for bug 3152 - DO NOT PROPAGATE.

The "trick" of creating a view and then forcing value updates does not work for 
strings if the vheap needs to be extended.


diffs (118 lines):

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
@@ -238,7 +238,7 @@ All Rights Reserved.
 static int
 aggrX3_@1_@3_@4_@5(BAT **ret, BAT *b, BAT *e)
 {
-       BAT *bn = BATnew(TYPE_void, BATttype(b), BATcount(e));
+       BAT *bn;
        BATiter bni, bi = bat_iterator(b);
        int (*cmp)(const void *, const void *);
        ptr nil;
@@ -254,6 +254,13 @@ 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));
+       }
        if( bn == NULL) {
                GDKerror("aggrX3_@1_@3_@4_@5(): BATnew() failed");
                return GDK_FAIL;
@@ -261,9 +268,14 @@ 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));
-       /* init: prepare the result bat;
-        * trick: by using "tail-type" void, we only write the head column, 
here */
-       @:init_result(void)@
+       /* 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)@
+       }
        bni = bat_iterator(bn);
        cmp = BATatoms[bn->ttype].atomCmp;
        nil =  ATOMnilptr(bn->ttype);
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
@@ -326,15 +326,26 @@ aggrX3_@13_@3_@4_@5(BAT **ret, BAT *b, B
                return rtrn;
        }
 
-       bn = BATnew(TYPE_void, BATttype(b), BATcount(e));
+       /* 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));
+       }
        if( bn == NULL) {
                GDKerror("aggrX3_@13_@3_@4_@5(): BATnew() failed");
                return GDK_FAIL;
        }
 
-       /* init: prepare the result bat;
-        * trick: by using "tail-type" void, we only write the head column, 
here */
-       @:init_result(void)@
+       /* 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)@
+       }
        bni = bat_iterator(bn);
        cmp = BATatoms[bn->ttype].atomCmp;
        nil = ATOMnilptr(bn->ttype);
diff --git a/monetdb5/modules/kernel/aggr_ri.mx 
b/monetdb5/modules/kernel/aggr_ri.mx
--- a/monetdb5/modules/kernel/aggr_ri.mx
+++ b/monetdb5/modules/kernel/aggr_ri.mx
@@ -57,7 +57,7 @@ All Rights Reserved.
                        BATaccessEnd(e,USE_HEAD,MMAP_SEQUENTIAL);
                }
        }
-#if TYPE_@1 != TYPE_void
+#if (TYPE_@1 != TYPE_void) && (TYPE_@1 != TYPE_str)
 {
        /* set all sums/avgs/counts to zero; for prod, zero is 1 */
        BUN _i = 0;
@@ -69,6 +69,21 @@ All Rights Reserved.
 }
 #endif
        BATsetcount(bn, _cnt);
+#if TYPE_@1 == TYPE_str
+{
+       /* copy head values */
+       BUN _i = 0;
+       oid *bnh = (oid*)Hloc(bn,BUNfirst(bn));
+       oid *eh = (oid*)Hloc(e,BUNfirst(e));
+       (void) bm; /* silence compiler */
+       BATaccessBegin(bn,USE_HEAD,MMAP_SEQUENTIAL);
+       BATaccessBegin(e,USE_HEAD,MMAP_SEQUENTIAL);
+       for (_i = 0; _i < _cnt; _i++)
+               bnh[_i] = eh[_i];
+       BATaccessEnd(bn,USE_HEAD,MMAP_SEQUENTIAL);
+       BATaccessEnd(e,USE_HEAD,MMAP_SEQUENTIAL);
+}
+#else
        if (!bn->batDirty)
                bn->batDirty = TRUE;
        bm = VIEWcreate(e,bn);
@@ -76,4 +91,5 @@ All Rights Reserved.
        bn = bm;
        bm = 0;
        ALIGNsetH(bn, e);
+#endif
 }
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to