Update of /cvsroot/monetdb/MonetDB5/src/optimizer
In directory sc8-pr-cvs16:/tmp/cvs-serv8534
Modified Files:
opt_partitions.mx opt_prelude.mx
Log Message:
The partitioned BATs may be input to calculations. In this case
we need to ensure that an iterator produces correctly aligned
portions.
Two more complex partitioned queries are handled.
Index: opt_prelude.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_prelude.mx,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- opt_prelude.mx 14 May 2007 21:13:50 -0000 1.25
+++ opt_prelude.mx 20 May 2007 07:51:30 -0000 1.26
@@ -102,6 +102,7 @@
opt_export str sortRef;
opt_export str sortHRef;
opt_export str sortTailRef;
+opt_export str sortReverseTailRef;
opt_export str sortHTRef;
opt_export str sortTHRef;
opt_export str sqlRef;
@@ -203,6 +204,7 @@
str sortRef;
str sortHRef;
str sortTailRef;
+str sortReverseTailRef;
str sortHTRef;
str sortTHRef;
str sqlRef;
@@ -298,6 +300,7 @@
setWriteModeRef= putName("setWriteMode",12);
sortRef = putName("sort",4);
sortTailRef = putName("sortTail",8);
+ sortReverseTailRef = putName("sortReverseTail",15);
sortHTRef = putName("sortHT",6);
sortTHRef = putName("sortTH",6);
sqlRef = putName("sql",3);
Index: opt_partitions.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_partitions.mx,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- opt_partitions.mx 17 May 2007 19:17:32 -0000 1.18
+++ opt_partitions.mx 20 May 2007 07:51:29 -0000 1.19
@@ -177,7 +177,9 @@
lastsegment=0;
} else
if( !isFragmentGroup(p) ){
- if( lastsegment==0 || getModuleId(p)== aggrRef)
+ if( lastsegment==0 ||
+ getModuleId(p)== batcalcRef ||
+ getModuleId(p)== aggrRef)
lastsegment= ++grp;
for(j=0; j<p->retc; j++){
setArgProperty(mb,
p,j,"segment","=",TYPE_int,&grp);
@@ -295,20 +297,81 @@
}
anchor=NULL;
}
-
[EMAIL PROTECTED]
+Blocking operations, such as sorting, aggregation, and
+the aligned bat calculations require more care.
[EMAIL PROTECTED]
+ /* remap specific instructions to list versions */
+ if( getModuleId(p)==aggrRef &&
+ getFunctionId(p)== countRef &&
+ alias[getArg(p,1)]!= getArg(p,1) ){
+ getModuleId(p)= bpmRef;
+ pushInstruction(mb,p);
+ if( alias[getArg(p,1)])
+ getArg(p,1)= alias[getArg(p,1)];
+ continue;
+ }
+ if( getFunctionId(p) == sortTailRef ||
+ getFunctionId(p) ==sortReverseTailRef ||
+ getModuleId(p) == aggrRef){
+ q = newStmt(mb,"bpm","glue");
+ pushArgument(mb,q,alias[getArg(p,1)]);
+ p->argv[1]= getArg(q,0);
+ alias[getArg(p,0)]= getArg(p,0);
+ pushInstruction(mb,p);
+ continue;
+ }
[EMAIL PROTECTED]
+Batcalc operations all work on the assumption that the
+heads are sorted on the heads(oid). If the operands come from
+different partitions sequences, we have to take special
+care in the iterator.
[EMAIL PROTECTED]
+ if( getModuleId(p)== batcalcRef){
+ InstrPtr qa;
+ int tpe = getArgType(mb,p,0);
+ listanchor[0]= q = newStmt(mb,"bpm","new");
+
pushArgument(mb,listanchor[0],newTypeVariable(mb,getHeadType(tpe)));
+
pushArgument(mb,listanchor[0],newTypeVariable(mb,getTailType(tpe)));
+
+ q = newStmt(mb,"bpm","newIterator");
+ q->barrier= BARRIERsymbol;
+ for(j=p->retc+1; j<p->argc; j++)
+ pushReturn(mb,q,newTmpVariable(mb, TYPE_any));
+ for(j=p->retc; j<p->argc; j++)
+ pushArgument(mb,q, alias[getArg(p,j)]);
+
+ alias[getArg(p,0)]= getArg(listanchor[0],0);
+ for(j=p->retc; j<p->argc; j++)
+ getArg(p,j)= getArg(q,j- p->retc);
+ pushInstruction(mb,p);
+
+ qa = newStmt(mb,"bpm","addPartition");
+ pushArgument(mb,qa,getArg(listanchor[0],0));
+ pushArgument(mb,qa,getArg(p,0));
+
+ qa = newStmt(mb, bpmRef, "hasMoreElements");
+ qa->barrier= REDOsymbol;
+ getArg(qa,0)= getArg(q,0);
+ for(j=1;j<q->retc; j++)
+ pushReturn(mb,qa,getArg(q,j));
+ for(j=q->retc;j<q->argc; j++)
+ pushArgument(mb,qa,getArg(q,j));
+
+ qa= newInstruction(mb, EXITsymbol);
+ qa->barrier= EXITsymbol;
+ getArg(qa,0)= getArg(q,0);
+ for(j=1;j<q->retc; j++)
+ pushReturn(mb,qa,getArg(q,j));
+ pushInstruction(mb,qa);
+ continue;
+ }
[EMAIL PROTECTED]
+In the last segment we have to glue things together.
[EMAIL PROTECTED]
if( seg && *seg==last){
- /* remap specific instructions to list versions */
- if( getModuleId(p)==aggrRef &&
- alias[getArg(p,1)]!= getArg(p,1) ){
- getModuleId(p)= bpmRef;
- pushInstruction(mb,p);
- if( alias[getArg(p,1)])
- getArg(p,1)= alias[getArg(p,1)];
- continue;
- }
for(j= p->retc; j<p->argc; j++)
- if( (alias[getArg(p,j)] && alias[getArg(p,j)]!=
getArg(p,j)) ||
- strncmp(getFunctionId(p),"sort",4)==0){
+ if( (alias[getArg(p,j)] && alias[getArg(p,j)]!=
getArg(p,j)) ){
q = newStmt(mb,"bpm","glue");
q->argv[0]= getArg(p,j);
pushArgument(mb,q,alias[getArg(p,j)]);
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins