Update of /cvsroot/monetdb/MonetDB5/src/optimizer
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10942

Modified Files:
        opt_mergetable.mx 
Log Message:
count now gives counts per bat inside the mat, ie group / derive and aggr
are done per part. Todo add the necessary joins and sums to fix the result.
(end then similar stuff for min/max,sum/avg)


Index: opt_mergetable.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_mergetable.mx,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- opt_mergetable.mx   12 Nov 2007 22:17:59 -0000      1.22
+++ opt_mergetable.mx   13 Nov 2007 09:58:18 -0000      1.23
@@ -187,6 +187,33 @@
 }
 
 static InstrPtr
+mat_group_aggr(MalBlkPtr mb, InstrPtr p, InstrPtr *mat, int m, int n, int o)
+{
+       int tp = getArgType(mb,p,0);
+       int k;
+       InstrPtr r = newInstruction(mb, ASSIGNsymbol);
+
+       setModuleId(r,matRef);
+       setFunctionId(r,newRef);
+       getArg(r,0) = getArg(p,0);
+
+       for(k=1; k<mat[m]->argc; k++) {
+               InstrPtr q = copyInstruction(p);
+               getArg(q,0) = newTmpVariable(mb, tp);
+               getArg(q,1) = getArg(mat[m],k);
+               getArg(q,2) = getArg(mat[n],k);
+               getArg(q,3) = getArg(mat[o],k);
+               pushInstruction(mb,q);
+
+               /* add result to mat */
+               r = pushArgument(mb,r,getArg(q,0));
+       }
+       freeInstruction(p);
+       pushInstruction(mb, r);
+       return r;
+}
+
+static InstrPtr
 mat_group(InstrPtr *ext, MalBlkPtr mb, InstrPtr p, InstrPtr *mat, int m, int 
n, int o)
 {
        int tp0 = getArgType(mb,p,0);
@@ -441,7 +468,7 @@
                        }       
                }
 @- 
-Now we handle group.new (and derive) statements
+Now we handle group, derive and aggregation statements. 
 @c
                if (getModuleId(p) == groupRef && 
                   ((match == 1 && getFunctionId(p) == newRef &&
@@ -458,6 +485,20 @@
                        actions++;
                        continue;
                }
+               if (match == 3 && getModuleId(p) == aggrRef && p->argc == 4 &&
+                  (getFunctionId(p)== countRef ||
+                   getFunctionId(p)== minRef ||
+                   getFunctionId(p)== maxRef ||
+                   getFunctionId(p)== sumRef) &&
+                  ((m=isMATalias(getArg(p,1),mvar,mtop)) >= 0) &&
+                  ((n=isMATalias(getArg(p,2),mvar,mtop)) >= 0) &&
+                  ((o=isMATalias(getArg(p,3),mvar,mtop)) >= 0)) {
+                       InstrPtr aggr = mat_group_aggr(mb, p, mat, m, n, o);
+
+                       mtop = mat_add(mat, mvar, mtop, aggr);
+                       actions++;
+                       continue;
+               }
 @-
 Pack MAT arguments, except one, to limit plan explosion.
 The preferred partitioned one is the first argment as it


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to