Changeset: 98e4b2ac3e5c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=98e4b2ac3e5c
Modified Files:
        monetdb5/modules/mal/mat.c
Branch: Feb2013
Log Message:

Estimate also the variable heap
The size of the variable heap is simply derived from the first one.
It may be an overshoot due to recurring values, though.


diffs (31 lines):

diff --git a/monetdb5/modules/mal/mat.c b/monetdb5/modules/mal/mat.c
--- a/monetdb5/modules/mal/mat.c
+++ b/monetdb5/modules/mal/mat.c
@@ -141,7 +141,9 @@ str
 MATpackIncrement(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
 {
        int *ret = (int*) getArgReference(stk,p,0);
+       int     pieces;
        BAT *b, *bb, *bn;
+       size_t newsize;
 
        (void) cntxt;
        b = BATdescriptor( stk->stk[getArg(p,1)].val.ival);
@@ -150,9 +152,16 @@ MATpackIncrement(Client cntxt, MalBlkPtr
 
        if ( getArgType(mb,p,2) == TYPE_int){
                /* first step */
-               bn = BATnew(TYPE_void, b->ttype, BATcount(b) * 
stk->stk[getArg(p,2)].val.ival);
+               pieces = stk->stk[getArg(p,2)].val.ival;
+               bn = BATnew(TYPE_void, b->ttype, BATcount(b) * pieces);
                if (bn == NULL)
                        throw(MAL, "mat.pack", MAL_MALLOC_FAIL);
+               /* allocate enough space for the strings */
+               if ( b->T->vheap ){
+                       newsize =  b->T->vheap->size * pieces;
+                       if (HEAPextend(b->T->vheap, newsize) < 0) 
+                               throw(MAL, "mat.pack", MAL_MALLOC_FAIL);
+               }
                BATsettrivprop(bn);
                BATseqbase(bn, b->H->seq);
                BATseqbase(BATmirror(bn), b->T->seq);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to