Update of /cvsroot/monetdb/MonetDB5/src/optimizer
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv26865
Modified Files:
opt_prelude.mx opt_remap.mx
Log Message:
remap avg into sum/cnt
Index: opt_prelude.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_prelude.mx,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- opt_prelude.mx 14 Nov 2007 10:18:27 -0000 1.30
+++ opt_prelude.mx 14 Nov 2007 12:24:28 -0000 1.31
@@ -43,10 +43,12 @@
opt_export str constraintsRef;
opt_export str countRef;
opt_export str crossRef;
+opt_export str dblRef;
opt_export str deleteRef;
opt_export str depositRef;
opt_export str deriveRef;
opt_export str differenceRef;
+opt_export str divRef;
opt_export str disconnectRef;
opt_export str evalRef;
opt_export str expandRef;
@@ -152,10 +154,12 @@
str constraintsRef;
str countRef;
str crossRef;
+str dblRef;
str deleteRef;
str depositRef;
str deriveRef;
str differenceRef;
+str divRef;
str disconnectRef;
str evalRef;
str expandRef;
@@ -256,10 +260,12 @@
constraintsRef = putName("constraints",11);
countRef = putName("count",5);
crossRef = putName("cross",5);
+ dblRef = putName("dbl",3);
deleteRef = putName("delete",6);
depositRef = putName("deposit",7);
deriveRef = putName("derive",6);
differenceRef= putName("difference",10);
+ divRef = putName("/",1);
disconnectRef= putName("disconnect",10);
evalRef = putName("eval",4);
expandRef = putName("expand",6);
Index: opt_remap.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_remap.mx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- opt_remap.mx 31 Oct 2007 10:36:27 -0000 1.14
+++ opt_remap.mx 14 Nov 2007 12:24:29 -0000 1.15
@@ -194,8 +194,46 @@
} else {
pushInstruction(mb, p);
}
- } else
+ } else if (p->argc == 4 &&
+ getModuleId(p) == aggrRef &&
+ getFunctionId(p) == avgRef) {
+ /* group aggr.avg -> aggr.sum/aggr.count */
+ InstrPtr sum = copyInstruction(p), avg, t;
+ InstrPtr cnt = copyInstruction(p);
+ setFunctionId(sum, sumRef);
+ setFunctionId(cnt, countRef);
+ getArg(sum,0) = newTmpVariable(mb, getArgType(mb, p,
1));
+ getArg(cnt,0) = newTmpVariable(mb,
newBatType(TYPE_oid,TYPE_int));
+ pushInstruction(mb, sum);
+ pushInstruction(mb, cnt);
+
+ t = newInstruction(mb, ASSIGNsymbol);
+ setModuleId(t, batcalcRef);
+ setFunctionId(t, dblRef);
+ getArg(t,0) = newTmpVariable(mb, getArgType(mb, p, 0));
+ t = pushArgument(mb, t, getDestVar(sum));
+ pushInstruction(mb, t);
+ sum = t;
+
+ t = newInstruction(mb, ASSIGNsymbol);
+ setModuleId(t, batcalcRef);
+ setFunctionId(t, dblRef);
+ getArg(t,0) = newTmpVariable(mb, getArgType(mb, p, 0));
+ t = pushArgument(mb, t, getDestVar(cnt));
+ pushInstruction(mb, t);
+ cnt = t;
+
+ avg = newInstruction(mb, ASSIGNsymbol);
+ setModuleId(avg, batcalcRef);
+ setFunctionId(avg, divRef);
+ getArg(avg, 0) = getArg(p, 0);
+ avg = pushArgument(mb, avg, getDestVar(sum));
+ avg = pushArgument(mb, avg, getDestVar(cnt));
+ freeInstruction(p);
+ pushInstruction(mb, avg);
+ } else {
pushInstruction(mb, p);
+ }
}
for(; i<slimit; i++)
if( old[i])
-------------------------------------------------------------------------
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