Update of /cvsroot/monetdb/pathfinder/compiler/algebra/opt
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv4008/compiler/algebra/opt
Modified Files:
Tag: M5XQ
opt_icol.c
Log Message:
propagated changes of Friday Jun 12 2009 - Monday Jun 15 2009
from the development trunk to the M5XQ branch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/06/12 - tsheyar: compiler/algebra/opt/opt_icol.c,1.34
-- Replaced aggregate operators count, min, max, avg, sum, prod, seqty1,
and all in the algebra by a single aggregate operator ``aggr''
that can handle multiple aggregates. The aggregate entries
are of kind count, min, max, avg, sum, prod, seqty1, all, and dist.
-- Added new aggregate kind ``dist'' that allows to represent group by
columns that functionally depend on the partitioning criterion
in the result of the grouping aggregate.
-- Added rewrite that merges aggregates.
-- Added rewrite that removes superfluous aggregates.
-- Added rewrite that pushes a rank operator through an aggregate.
-- Extended the XML import to cope with the old
as well as the new representation of aggregates.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
U opt_icol.c
Index: opt_icol.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_icol.c,v
retrieving revision 1.32.2.1
retrieving revision 1.32.2.2
diff -u -d -r1.32.2.1 -r1.32.2.2
--- opt_icol.c 7 May 2009 14:43:16 -0000 1.32.2.1
+++ opt_icol.c 15 Jun 2009 12:45:00 -0000 1.32.2.2
@@ -300,34 +300,35 @@
}
break;
- case la_avg:
- case la_max:
- case la_min:
- case la_sum:
- case la_prod:
- case la_count:
- case la_seqty1:
- case la_all:
+ case la_aggr:
+ {
+ unsigned int count = 0;
+ PFalg_aggr_t *aggr = PFmalloc (p->sem.aggr.count *
+ sizeof (PFalg_aggr_t));
+
+ for (unsigned int i = 0; i < p->sem.aggr.count; i++)
+ if (PFprop_icol (p->prop, p->sem.aggr.aggr[i].res))
+ aggr[count++] = p->sem.aggr.aggr[i];
+
/* replace aggregate function if result column is not required */
- if (!PFprop_icol (p->prop, p->sem.aggr.res)) {
- PFla_op_t *ret;
+ if (!count) {
/* as an aggregate is required we either
(a) evaluate a distinct on the partition (if present) or
(b) create a one tuple literal table with a bogus value
(as it is never referenced) */
- if (p->sem.aggr.part) {
- PFalg_proj_t *proj = PFmalloc (sizeof (PFalg_proj_t));
- proj[0] = PFalg_proj (p->sem.aggr.part, p->sem.aggr.part);
- ret = PFla_distinct (PFla_project_ (L(p), 1, proj));
- } else {
- ret = PFla_lit_tbl (collist (p->sem.aggr.res),
- PFalg_tuple (PFalg_lit_nat (42)));
- }
- *p = *ret;
- SEEN(p) = true;
- break;
+ if (p->sem.aggr.part)
+ *p = *distinct (project (L(p), proj (p->sem.aggr.part,
+ p->sem.aggr.part)));
+ else
+ *p = *lit_tbl (collist (p->sem.aggr.aggr[0].res),
+ tuple (lit_nat (42)));
}
- break;
+ else if (count < p->sem.aggr.count) {
+ p->sem.aggr.count = count;
+ p->sem.aggr.aggr = aggr;
+ }
+ SEEN(p) = true;
+ } break;
case la_rownum:
case la_rowrank:
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins