Changeset: 9929ce107934 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9929ce107934
Modified Files:
monetdb5/optimizer/opt_centipede.c
Branch: default
Log Message:
Sync on SSBM query set
These queries seemingly produce correct centipede plans.
diffs (truncated from 417 to 300 lines):
diff --git a/monetdb5/optimizer/opt_centipede.c
b/monetdb5/optimizer/opt_centipede.c
--- a/monetdb5/optimizer/opt_centipede.c
+++ b/monetdb5/optimizer/opt_centipede.c
@@ -59,13 +59,13 @@ static int nrservers;
* geared at parallel execution
*/
static MalBlkPtr
-OPTexecController(Client cntxt, MalBlkPtr mb, MalBlkPtr pmb, Slices *slices,
oid plantag)
+OPTexecController(Client cntxt, MalBlkPtr mb, MalBlkPtr pmb, InstrPtr ret,
Slices *slices, oid plantag)
{
MalBlkPtr cmb;
Symbol s;
char nme[BUFSIZ], *plan, *stub;
int barrier, x, i, j, k, *alias, nrpack;
- InstrPtr ret, p, q, *pack;
+ InstrPtr p, q, *pack;
/* define the query controller */
//snprintf(nme, BUFSIZ, "%s_plan"OIDFMT, getFunctionId(
getInstrPtr(mb,0)), plantag);
@@ -132,7 +132,7 @@ OPTexecController(Client cntxt, MalBlkPt
pack[k] = newInstruction(cmb,ASSIGNsymbol);
getModuleId(pack[k]) = matRef;
getFunctionId(pack[k]) = packRef;
- getArg(pack[k],0) = getArg(p,k); //newTmpVariable(cmb,
newBatType(TYPE_oid, getTailType(getArgType(cmb,p,k))) );
+ getArg(pack[k],0) = getArg(p,k);
}
}
@@ -211,60 +211,70 @@ OPTexecController(Client cntxt, MalBlkPt
for ( i=1; i < pmb->stop; i++){
InstrPtr pq= getInstrPtr(pmb,0);
q= getInstrPtr(pmb,i);
- for( k = 0; k < pq->retc; k++)
- if ( getArg(pq,k) == getArg(q,0))
- break;
if (getModuleId(q) == groupRef && (getFunctionId(q) ==
subgroupdoneRef)){
+ char nme[BUFSIZ], v;
+
+ q= copyInstruction(q);
+
+ for( j= q->retc; j<q->argc; j++){
+ snprintf(nme,BUFSIZ,"C_%d",getArg(q,j));
+ v= findVariable(cmb,nme);
+ if ( v >= 0)
+ getArg(q,j) = v;
+
+ pq= getInstrPtr(cmb,0);
+ for ( k = 0; k< pq->retc; k++)
+ if (getArg(pq,k) == getArg(q, q->retc)){
+ delArgument(pq,k);
+ break;
+ }
+ }
pushInstruction(cmb,q);
- pq= getInstrPtr(cmb,0);
- for ( k = 0; k< pq->retc; k++)
- if (getArg(pq,k) == getArg(q, q->retc)){
- delArgument(pq,k);
- break;
- }
+
} else
if (getModuleId(q) == aggrRef && getFunctionId(q) ==
subcountRef ){
q= copyInstruction(q);
getFunctionId(q) = subsumRef;
- getArg(q,1)= getArg(q,0);
q= pushBit(cmb,q,1);
+ getArg(q,1) = getArg(q,0);
pushInstruction(cmb,q);
} else
if (getModuleId(q) == aggrRef && (getFunctionId(q)==subsumRef
|| getFunctionId(q) == subminRef ||
getFunctionId(q) == submaxRef || getFunctionId(q) ==
subavgRef)){
q= copyInstruction(q);
- getArg(q,1)= getArg(q,0);
+ getArg(q,1) = getArg(q,0);
pushInstruction(cmb,q);
}
}
- /* consolidate the result */
- ret = copyInstruction(getInstrPtr(cmb,0));
+ /* consolidate the result of the control function */
+ ret = copyInstruction(ret);
clrFunction(ret);
ret->barrier = RETURNsymbol;
- ret->argc = ret->retc;
- /* make it a correct assignment to ensure ref counts */
- q= getInstrPtr(cmb,0);
- for( k= 0; k< ret->retc; k++) {
- getArg(ret,k) = getArg(q,k);
- setVarUsed(cmb,getArg(ret,k));
- //ret = pushArgument(cmb,ret,getArg(ret,k));
- ret = pushArgument(cmb,ret,getArg(pack[k],0));
- //mnstr_printf(cntxt->fdout,"#return map %d = %d\n",
getArg(ret,k), getArg(pack[k],0));
- }
+ for( i=0; i< ret->retc; i++)
+ ret= pushArgument(mb,ret,getArg(ret,i));
pushInstruction(cmb,ret);
- getInstrPtr(cmb,0)->argc -= 2;
+ getInstrPtr(cmb,0)->argc-= 2; // remove the bounds
+ // fix the calling of the cntrl function
+ while ( cmb->stmt[0]->retc )
+ delArgument(cmb->stmt[0],0);
+ for( i =0; i< ret->retc; i++)
+ cmb->stmt[0]= pushReturn(cmb, cmb->stmt[0], getArg(ret,i));
pushEndInstruction(cmb);
#ifdef _DEBUG_OPT_CENTIPEDE_
- mnstr_printf(cntxt->fdout,"#rough cntrl plan %d \n", cmb->errors);
- printFunction(cntxt->fdout, cmb, 0, LIST_MAL_STMT);
+ mnstr_printf(cntxt->fdout,"\n#pmb stmt\n");
+ printInstruction(cntxt->fdout, pmb, 0,
getInstrPtr(pmb,0),LIST_MAL_STMT);
+ mnstr_printf(cntxt->fdout,"\n#cmb stmt\n");
+ printInstruction(cntxt->fdout,cmb, 0, getInstrPtr(cmb,0),LIST_MAL_STMT);
+ //mnstr_printf(cntxt->fdout,"#rough cntrl plan %d \n", cmb->errors);
+ //printFunction(cntxt->fdout, cmb, 0, LIST_MAL_STMT);
#endif
chkProgram(cntxt->fdout, cntxt->nspace, cmb);
#ifdef _DEBUG_OPT_CENTIPEDE_
- mnstr_printf(cntxt->fdout,"#cntrl plan %d \n", cmb->errors);
- printFunction(cntxt->fdout, cmb, 0, LIST_MAL_STMT);
+ //mnstr_printf(cntxt->fdout,"#cntrl plan %d \n", cmb->errors);
+ //printFunction(cntxt->fdout, cmb, 0, LIST_MAL_STMT);
#endif
GDKfree(alias);
GDKfree(pack);
@@ -514,6 +524,10 @@ OPTbakePlans(Client cntxt, MalBlkPtr mb,
vars[getArg(p,0)] = PARTITION;
} else
if ( getModuleId(p) == sqlRef && getFunctionId(p) == deltaRef ){
+ // Use a readonly view on the database TO BE FIXED
+ //clrFunction(p);
+ //p->argc =2;
+ //p->token = ASSIGNsymbol;
if ( vars[getArg(p,1)] ){
status[i] = PARTITION;
vars[getArg(p,0)] = PARTITION;
@@ -546,18 +560,20 @@ OPTbakePlans(Client cntxt, MalBlkPtr mb,
}
} else
if ( getModuleId(p) == aggrRef && (getFunctionId(p) ==
subcountRef || getFunctionId(p) == subsumRef ||
- getFunctionId(p) == subminRef || getFunctionId(p) ==
submaxRef || getFunctionId(p) == subavgRef)){
+ getFunctionId(p) == subminRef || getFunctionId(p) ==
submaxRef || getFunctionId(p) == subavgRef )){
if (vars[getArg(p,p->retc)] ){
status[i] = PIVOT;
- vars[getArg(p,0)] = PARTITION;
+ for(j = 0; j < p->argc; j++)
+ if ( vars[getArg(p,j)] ==0)
+ vars[getArg(p,j)] = PIVOT;
}
} else
if ( getModuleId(p) == groupRef && ( getFunctionId(p) ==
subgroupRef || getFunctionId(p) == subgroupdoneRef) && p->retc== 3){
if ( vars[getArg(p,p->retc)] ){
status[i] = PIVOT;
- vars[getArg(p,0)] = PARTITION;
- vars[getArg(p,1)] = PARTITION;
- vars[getArg(p,2)] = PARTITION;
+ for(j = 0; j < p->argc; j++)
+ if ( vars[getArg(p,j)] ==0)
+ vars[getArg(p,j)] = PIVOT;
}
} else
if ((getModuleId(p) == sqlRef && (getFunctionId(p) ==
resultSetRef || getFunctionId(p) == putName("exportValue",11))) ||
getModuleId(p) == ioRef )
@@ -569,8 +585,22 @@ OPTbakePlans(Client cntxt, MalBlkPtr mb,
vars[getArg(p,0)] = PARTITION;
}
} else
- if ( getModuleId(p) == aggrRef )
+ if ( getModuleId(p) == algebraRef && (getFunctionId(p) ==
subsortRef || getFunctionId(p) == sortRef || getFunctionId(p)== tinterRef) ) {
status[i] = BLOCKED;
+ for(j=0; j < p->retc; j++)
+ vars[getArg(p,j)] = BLOCKED;
+ } else
+ if ( getModuleId(p) == batRef && getFunctionId(p)==appendRef
) {
+ if ( vars[getArg(p,p->retc)] == PARTITION)
+ status[i] = BLOCKED;
+ for(j=0; status[i] == BLOCKED && j < p->retc; j++)
+ vars[getArg(p,j)] = BLOCKED;
+ } else
+ if ( getModuleId(p) == aggrRef ) {
+ status[i] = BLOCKED;
+ for(j=0; j < p->retc; j++)
+ vars[getArg(p,j)] = BLOCKED;
+ }
for( j = p->retc; j < p->argc; j++)
if (vars[getArg(p,j)] == BLOCKED )
@@ -584,23 +614,29 @@ OPTbakePlans(Client cntxt, MalBlkPtr mb,
status[i]= PARTITION;
for ( j= 0; j< p->retc; j++)
- if (vars[getArg(p,j)] == 0)
+ //if (vars[getArg(p,j)] == 0)
vars[getArg(p,j)] = status[i];
if ( status[i] == PARTITION)
for( j = p->retc; j < p->argc; j++)
if (vars[getArg(p,j)] == 0)
vars[getArg(p,j)] = SUPPORTIVE;
+ else
+ if (vars[getArg(p,j)] == PIVOT){
+ status[i] = PIVOT;
+ for( k = 0; k< p->retc; k++)
+ vars[getArg(p,k)] = PIVOT;
+ }
}
#ifdef _DEBUG_OPT_CENTIPEDE_
/*
mnstr_printf(cntxt->fdout,"\n#phase 1 show partition keys\n");
for( i= 0; i< limit; i++)
if (status[i] && old[i] ) {
- mnstr_printf(cntxt->fdout,"%s ",statusname[status[i]]);
+ mnstr_printf(cntxt->fdout,"%s [%d] ",statusname[status[i]],i);
for (j=0; j< old[i]->retc; j++){
int x = old[i]->argv[j];
- mnstr_printf(cntxt->fdout,"[%d]%d ",x,vars[x]);
+ mnstr_printf(cntxt->fdout,"%d=%d ",x,vars[x]);
}
printInstruction(cntxt->fdout, mb,0,old[i],LIST_MAL_STMT);
}
@@ -611,7 +647,7 @@ OPTbakePlans(Client cntxt, MalBlkPtr mb,
we have to avoid common ancestor dependency on partitioned variables
*/
for ( i = limit -1; i >= 0 ; i--)
- if ( status[i] == 0 ){
+ if ( status[i] == 0 || status[i]== BLOCKED ){
p = old[i];
for( j = 0; j < p->argc; j++)
@@ -621,12 +657,12 @@ OPTbakePlans(Client cntxt, MalBlkPtr mb,
if ( j == p->argc ) {
/* does it produce partitioned or support variables */
for( j = 0; j < p->retc; j++)
- if ( vars[getArg(p,j)] == SUPPORTIVE ||
vars[getArg(p,j)] == PARTITION)
+ if ( vars[getArg(p,j)] == SUPPORTIVE ||
vars[getArg(p,j)] == PARTITION || vars[getArg(p,j)] == PIVOT)
break;
} else {
status[i] = BLOCKED;
for( j = 0; j < p->retc; j++)
- if ( vars[getArg(p,j)] == 0)
+ //if ( vars[getArg(p,j)] == 0)
vars[getArg(p,j)] = BLOCKED;
}
@@ -646,15 +682,15 @@ OPTbakePlans(Client cntxt, MalBlkPtr mb,
mnstr_printf(cntxt->fdout,"\n#phase 2 show partition keys\n");
for( i= 0; i< limit; i++)
if (status[i] && old[i] ) {
- mnstr_printf(cntxt->fdout,"%s ",statusname[status[i]]);
+ mnstr_printf(cntxt->fdout,"%s [%d] ",statusname[status[i]],i);
for (j=0; j< old[i]->retc; j++){
int x = old[i]->argv[j];
- mnstr_printf(cntxt->fdout,"[%d]%d ",x,vars[x]);
+ mnstr_printf(cntxt->fdout,"%d=%d ",x,vars[x]);
}
printInstruction(cntxt->fdout, mb,0,old[i],LIST_MAL_STMT);
}
#endif
- /* Phase 3: determine all variables to be exported
+ /* Phase 3: determine all variables to be exported to the cntrl and
main program
this is limited to all variables produced and consumed by a blocked
instruction
*/
ret= newInstruction(0,ASSIGNsymbol);
@@ -668,20 +704,14 @@ OPTbakePlans(Client cntxt, MalBlkPtr mb,
p = old[i];
if ( p )
for( j = p->retc; j < p->argc; j++)
- if ( (vars[getArg(p,j)] == PARTITION || vars[getArg(p,j)] ==
SUPPORTIVE) && isaBatType(getArgType(plan,p,j)) ){
- /* limit the number of returned BATs to those that are
expensive
- if ( getModuleId(p) == algebraRef || getModuleId(p) ==
batRef )
- continue;
- */
+ if ( (vars[getArg(p,j)] == PARTITION || vars[getArg(p,j)] ==
SUPPORTIVE || vars[getArg(p,j)]== PIVOT) && isaBatType(getArgType(plan,p,j)) ){
/* don't return the same variable twice */
for ( k = 0; k < ret->retc; k++)
if (getArg(ret,k) == getArg(p,j))
break;
if ( k == ret->retc) {
- int w = newTmpVariable(plan,
getArgType(plan,p,j));
- setVarUsed(plan,w); (void) w;
ret= pushReturn(plan,ret, getArg(p,j));
- planargs = pushReturn(plan,planargs , w);
+ planargs = pushReturn(plan,planargs ,
getArg(p,j));
planargs = pushArgument(plan,planargs ,
getArg(p,j));
}
}
@@ -691,6 +721,12 @@ OPTbakePlans(Client cntxt, MalBlkPtr mb,
printInstruction(cntxt->fdout, mb,0,p,LIST_MAL_STMT);
}
+#ifdef _DEBUG_OPT_CENTIPEDE_
+ mnstr_printf(cntxt->fdout,"\n#phase 3 return stmt\n");
+ printInstruction(cntxt->fdout, mb,0,ret,LIST_MAL_STMT);
+ mnstr_printf(cntxt->fdout,"\n#plane args stmt\n");
+ printInstruction(cntxt->fdout, plan,0,planargs,LIST_MAL_STMT);
+#endif
/* Phase 4: Bake a new function that produces them */
p = copyInstruction(getInstrPtr(mb, 0));
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list