Changeset: 323cef212243 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=323cef212243
Modified Files:
        monetdb5/scheduler/mut_pack.c
Branch: mutation
Log Message:

Handle the multiple packs coming from a join


diffs (114 lines):

diff --git a/monetdb5/scheduler/mut_pack.c b/monetdb5/scheduler/mut_pack.c
--- a/monetdb5/scheduler/mut_pack.c
+++ b/monetdb5/scheduler/mut_pack.c
@@ -60,22 +60,23 @@ validswitch(InstrPtr p, InstrPtr q)
 
 void 
 mutationPack(Client cntxt, Mutant m){
+       MalBlkPtr mb = m->src;
     int pc = m->target, i, j, mvar, svar, dvar, limit;
-    InstrPtr p=0, *old= m->src->stmt, q, qq =0, newpack = 0;
+    InstrPtr p=0, *old= mb->stmt, q, newpack = 0, newpack1=0, newpack2 = 0;
        int profiler=0;
 
     (void) cntxt;
-    limit= m->src->stop;
-    if ( newMalBlkStmt(m->src, m->src->ssize) < 0)
+    limit= mb->stop;
+    if ( newMalBlkStmt(mb, mb->ssize) < 0)
         return;
-       pushInstruction(m->src,old[0]);//needed for debugging
+       pushInstruction(mb,old[0]);//needed for debugging
 
        // first phase, see if we need to undo a bat.partition
        svar = -1; mvar = -1; dvar = -1;
     for (j = i = 1; i < limit; i++) {
         p= old[i];
                if (  i == pc){
-                       if ( m->stk->stksize < m->src->vtop + p->argc){
+                       if ( m->stk->stksize < mb->vtop + p->argc){
                                old[j++] = p;
                                continue;
                        }
@@ -93,7 +94,6 @@ mutationPack(Client cntxt, Mutant m){
                                freeInstruction(p);
                        } else  old[j++] = q;
                        newpack = p;
-                       qq = q;
                        m->comment = GDKstrdup("mutationPack");
                } else
                // rollback all but one partitioned instruction
@@ -112,42 +112,56 @@ mutationPack(Client cntxt, Mutant m){
        DEBUG_MULTICORE {
                mnstr_printf(cntxt->fdout,"#mutationPack mvar %d svar %d dvar 
%d leftover %d\n", mvar,svar,dvar,limit);
                for( i= 0; i< limit; i++)
-                       printInstruction(cntxt->fdout, m->src, 0, old[i], 
LIST_MAL_ALL);
+                       printInstruction(cntxt->fdout, mb, 0, old[i], 
LIST_MAL_ALL);
        }
 
        // second phase, replace matpack with its successor
     for (i = 1; i < limit; i++) {
         p= old[i];
-               profiler = m->src->profiler[i].trace;
+               profiler = mb->profiler[i].trace;
 
-               if (qq && newpack && getArgPos(p, mvar) >=0 )
+               if (newpack && getArgPos(p, mvar) >=0 )
                {
-                       if (qq == p &&  getModuleId(p) == algebraRef)
+                       if (getModuleId(p) == algebraRef)
                        {
+                               newpack1 = copyInstruction(newpack);
                                if (getFunctionId(p) == joinRef || 
getFunctionId(p)== leftjoinRef || getFunctionId(p) == subselectRef){
+                                       getArg(newpack1,0) = getArg(p,0);
+                                       setArgType(mb, newpack1, 0, 
getArgType(mb,p,0));
+                                       if( getFunctionId(p) == joinRef || 
getFunctionId(p) == leftjoinRef) {
+                                               newpack2 = 
copyInstruction(newpack);
+                                               getArg(newpack2,0) = 
getArg(p,1);
+                                               setArgType(mb, newpack2,0, 
getArgType(mb,p,1));
+                                       }
+
                                        for( j= newpack->retc; j 
<newpack->argc; j++){
-                                               qq= copyInstruction(p);
-                                               getArg(qq,getArgPos(qq,mvar)) = 
getArg(newpack,j);
-                                               getArg(qq,0) = 
newTmpVariable(m->src, getArgType(m->src, qq,0));
-                                               getArg(newpack,j)= getArg(qq,0);
-                                               pushInstruction(m->src,qq);
-                                               
m->src->profiler[m->src->stop-1].trace = profiler;
+                                               q= copyInstruction(p);
+                                               getArg(q,getArgPos(q,mvar)) = 
getArg(newpack,j);
+                                               getArg(q,0) = 
newTmpVariable(mb, getArgType(mb, q, 0));
+                                               getArg(newpack1,j)= getArg(q,0);
+                                               if ( newpack2){
+                                                       getArg(q,1) = 
newTmpVariable(mb, getArgType(mb, q, 1));
+                                                       getArg(newpack2,j)= 
getArg(q,1);
+                                               }
+                                               pushInstruction(mb,q);
+                                               mb->profiler[mb->stop-1].trace 
= profiler;
                                        }
-                                       setArgType(m->src, newpack,0, 
getArgType(m->src,p,0));
-                                       pushInstruction(m->src,newpack);
-                                       newpack = 0;
+                                       pushInstruction(mb, newpack1);
+                                       if ( newpack2)
+                                               pushInstruction(mb, newpack2);
+                                       newpack1 = 0;
+                                       newpack2 = 0;
                                        continue;
                                } 
                        }
-                       pushInstruction(m->src, p);
+                       pushInstruction(mb, p);
                } 
                // handle non-partitioned operators
-               pushInstruction(m->src,p);
+               pushInstruction(mb,p);
        }
        DEBUG_MULTICORE {
                mnstr_printf(cntxt->fdout,"#mutationPack mvar %d svar %d dvar 
%d leftover %d\n", mvar,svar,dvar,limit);
-               for( i= 0; i< limit; i++)
-                       printFunction(cntxt->fdout, m->src, 0, LIST_MAL_ALL);
+               printFunction(cntxt->fdout, mb, 0, LIST_MAL_ALL);
        }
     GDKfree(old);
 }
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to