Update of /cvsroot/monetdb/pathfinder/compiler/algebra
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv3747/compiler/algebra
Modified Files:
Tag: M5XQ
physical.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/physical.c,1.94
-- 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 physical.c
Index: physical.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/physical.c,v
retrieving revision 1.89.2.3
retrieving revision 1.89.2.4
diff -u -d -r1.89.2.3 -r1.89.2.4
--- physical.c 20 May 2009 16:28:19 -0000 1.89.2.3
+++ physical.c 15 Jun 2009 12:44:10 -0000 1.89.2.4
@@ -2278,114 +2278,53 @@
}
/**
- * Count: Count function operator. Does neither benefit from
- * any existing ordering, nor does it provide/preserve any input
- * ordering.
- */
-PFpa_op_t *
-PFpa_count (const PFpa_op_t *n, PFalg_col_t res, PFalg_col_t part)
-{
- PFpa_op_t *ret = wire1 (pa_count, n);
-
- ret->sem.count.res = res;
- ret->sem.count.part = part;
- ret->sem.count.loop = col_NULL;
-
- /* allocate memory for the result schema */
- ret->schema.count = part ? 2 : 1;
- ret->schema.items
- = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items)));
-
- if (part) {
- unsigned int i;
- for (i = 0; i < n->schema.count; i++)
-
- if (n->schema.items[i].name == part) {
- ret->schema.items[0] = n->schema.items[i];
- break;
- }
-
-#ifndef NDEBUG
- if (i == n->schema.count)
- PFoops (OOPS_FATAL,
- "HashCount: unable to find partitioning column `%s'",
- PFcol_str (part));
-#endif
- }
-
- ret->schema.items[ret->schema.count - 1]
- = (PFalg_schm_item_t) { .name = res, .type = aat_int };
-
- /* ---- HashCount: orderings ---- */
- /* HashCount does not provide any orderings. */
-
- /* ---- HashCount: costs ---- */
- ret->cost = AGGR_COST + n->cost;
-
- return ret;
-}
-
-/**
* Aggr: Aggregation function operator. Does neither benefit from
* any existing ordering, nor does it provide/preserve any input
* ordering.
*/
PFpa_op_t *
-PFpa_aggr (PFpa_op_kind_t kind, const PFpa_op_t *n,
- PFalg_col_t res, PFalg_col_t col, PFalg_col_t part)
+PFpa_aggr (const PFpa_op_t *n, PFalg_col_t part,
+ unsigned int count, PFalg_aggr_t *aggr)
{
- PFpa_op_t *ret = wire1 (kind, n);
+ PFpa_op_t *ret = wire1 (pa_aggr, n);
unsigned int i;
-#ifndef NDEBUG
- bool c1 = false;
- bool c2 = false;
-#endif
-
- ret->sem.aggr.res = res;
- ret->sem.aggr.col = col;
- ret->sem.aggr.part = part;
/* set number of schema items in the result schema
- * (partitioning column plus result column)
+ * (result columns plus partitioning column)
*/
- ret->schema.count = part ? 2 : 1;
+ ret->schema.count = count + (part ? 1 : 0);
- ret->schema.items
- = PFmalloc (ret->schema.count * sizeof (*(ret->schema.items)));
+ ret->schema.items = PFmalloc (ret->schema.count *
+ sizeof (*(ret->schema.items)));
- /* verify that columns 'col' and 'part' are columns of n
- * and include them into the result schema
- */
- for (i = 0; i < n->schema.count; i++) {
- if (col == n->schema.items[i].name) {
- ret->schema.items[0] = n->schema.items[i];
- ret->schema.items[0].name = res;
-#ifndef NDEBUG
- c1 = true;
-#endif
+ /* insert semantic value (aggregates) into the result */
+ ret->sem.aggr.part = part;
+ ret->sem.aggr.count = count;
+ ret->sem.aggr.aggr = PFmalloc (count * sizeof (PFalg_aggr_t));
+
+ for (i = 0; i < count; i++) {
+ PFalg_col_t col = aggr[i].col;
+ if (col) {
+ if (!check_col (n, col))
+ PFoops (OOPS_FATAL,
+ "column `%s' referenced in aggregate not found",
+ PFcol_str (col));
+ ret->schema.items[i].type = type_of (n, col);
}
- if (part && part == n->schema.items[i].name) {
- ret->schema.items[1] = n->schema.items[i];
-#ifndef NDEBUG
- c2 = true;
-#endif
+ else {
+ ret->schema.items[i].type = aat_int;
}
+ ret->sem.aggr.aggr[i] = aggr[i];
+ ret->schema.items[i].name = aggr[i].res;
+ }
+ if (part) {
+ if (!check_col (n, part))
+ PFoops (OOPS_FATAL,
+ "column `%s' referenced in aggregate not found",
+ PFcol_str (part));
+ ret->schema.items[count].name = part;
+ ret->schema.items[count].type = type_of (n, part);
}
-
-#ifndef NDEBUG
- /* did we find column 'col'? */
- if (!c1)
- PFoops (OOPS_FATAL,
- "column `%s' referenced in aggregation function not found",
- PFcol_str (col));
-
- /* did we find column 'part'? */
- if (part && !c2)
- PFoops (OOPS_FATAL,
- "partitioning column `%s' referenced in aggregation "
- "function not found",
- PFcol_str (part));
-#endif
/* ---- Aggr: orderings ---- */
/* Aggr does not provide any orderings. */
------------------------------------------------------------------------------
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