Changeset: c36d8154d87f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c36d8154d87f
Modified Files:
pathfinder/compiler/algebra-m5sql/lalg2msa.c
pathfinder/compiler/algebra-m5sql/msa.c
pathfinder/compiler/algebra-m5sql/msaprint.c
pathfinder/compiler/algebra/alg_dag.c
pathfinder/compiler/include/msaprint.h
Branch: default
Log Message:
New DAG traversal functions fully implemented, added traversal infering the
reference counters.
Because of DAG traversal is done now in msaprint.c, alg_dag.c was changed back
to its initial functionality.
diffs (truncated from 1136 to 300 lines):
diff -r 3ddce7b7e6db -r c36d8154d87f
pathfinder/compiler/algebra-m5sql/lalg2msa.c
--- a/pathfinder/compiler/algebra-m5sql/lalg2msa.c Mon May 10 21:34:13
2010 +0200
+++ b/pathfinder/compiler/algebra-m5sql/lalg2msa.c Sun May 16 18:26:50
2010 +0200
@@ -854,9 +854,7 @@
memcpy(expr_cpy, expr, sizeof(PFmsa_expr_t));
eladd(partlist) = expr_cpy;
- } else
- /* otherwise, append col_NULL as partitioning column */
- eladd(partlist) = PFmsa_expr_column(col_NULL, aat_uA);
+ }
for (i = 0; i < PFord_count (n->sem.sort.sortby); i++) {
curr_col = PFord_order_col_at (n->sem.sort.sortby, i);
@@ -930,11 +928,8 @@
expr->sem.num_gen.sort_cols = elcopy(exprlist);
- /* copy dummy partitioning column (col_NULL) into part_cols */
+ /* copy empty list into part_cols */
exprlist = el(1);
-
- eladd(exprlist) = PFmsa_expr_column(col_NULL, aat_uA);
-
expr->sem.num_gen.part_cols = elcopy(exprlist);
eladd(prj_list) = expr;
@@ -959,14 +954,12 @@
/* rowid does not have partitioning or sort columns -> fill in
dummy values*/
- /* copy dummy partitioning column (col_NULL) into part_cols */
+ /* copy empty list into part_cols */
exprlist = el(1);
- eladd(exprlist) = PFmsa_expr_column(col_NULL, aat_uA);
expr->sem.num_gen.part_cols = elcopy(exprlist);
- /* copy dummy sort column (col_NULL) into sort_cols */
+ /* copy empty list into sort_cols */
exprlist = el(1);
- eladd(exprlist) = PFmsa_expr_column(col_NULL, aat_uA);
expr->sem.num_gen.sort_cols = elcopy(exprlist);
eladd(prj_list) = expr;
diff -r 3ddce7b7e6db -r c36d8154d87f pathfinder/compiler/algebra-m5sql/msa.c
--- a/pathfinder/compiler/algebra-m5sql/msa.c Mon May 10 21:34:13 2010 +0200
+++ b/pathfinder/compiler/algebra-m5sql/msa.c Sun May 16 18:26:50 2010 +0200
@@ -285,9 +285,7 @@
}
else if (elsize(child_list) > PFMSA_EXPR_MAXCHILD)
{
- /* special cases */
-
- /* but for now, only show an error message */
+ /* show an error message */
PFoops (OOPS_FATAL,
"MSA expression function: expression cannot have more "
"than %i children", PFMSA_EXPR_MAXCHILD);
@@ -328,7 +326,7 @@
}
else if (elsize(child_list) > PFMSA_EXPR_MAXCHILD)
{
- /* special cases */
+ /* FIXME: special cases (expressions with more that 2 children) */
/* but for now, only show an error message */
PFoops (OOPS_FATAL,
diff -r 3ddce7b7e6db -r c36d8154d87f
pathfinder/compiler/algebra-m5sql/msaprint.c
--- a/pathfinder/compiler/algebra-m5sql/msaprint.c Mon May 10 21:34:13
2010 +0200
+++ b/pathfinder/compiler/algebra-m5sql/msaprint.c Sun May 16 18:26:50
2010 +0200
@@ -49,7 +49,6 @@
#include "msa_mnemonic.h"
-
/** Node names to print out for all the SQL algebra operator nodes. */
static char *dot_op_id[] = {
[msa_op_serialize_rel] = "REL SERIALIZE"
@@ -192,6 +191,8 @@
return ret;
}
+/* --------------- Print operators and expressions --------------- */
+
/**
* Print SQL algebra expression in AT&T dot notation.
* @param dot Array into which we print
@@ -202,7 +203,7 @@
{
unsigned int c;
assert(n->node_id);
- printf("/* refctr here! %i */\n", n->refctr);
+
/* open up label */
PFarray_printf (dot, "expr_%i [label=\"%s\\n", n->node_id,
dot_expr_id[n->kind]);
@@ -228,15 +229,16 @@
PFarray_printf(dot, "%s\\n",
dot_expr_num_gen_id[n->sem.num_gen.kind]);
/* print partitioning columns */
+
if (n->sem.num_gen.kind == msa_num_gen_rownum)
{
PFarray_printf(dot, "part cols: <");
- for (c = 0; c < elsize(n->sem.num_gen.part_cols) - 1; c++) {
+ for (c = 0; c < elsize(n->sem.num_gen.part_cols); c++) {
expr = elat(n->sem.num_gen.part_cols, c);
PFarray_printf(dot, "%s, ", PFcol_str(expr->col));
}
- expr = elat(n->sem.num_gen.part_cols, c);
- PFarray_printf(dot, "%s>\\n", PFcol_str(expr->col));
+ PFarray_printf(dot, ">\\n");
+
}
PFarray_printf(dot, "%s", PFcol_str(n->col));
@@ -302,7 +304,7 @@
{
unsigned int c, i, j;
assert(n->node_id);
- printf("/* refctr here! %i */\n", n->refctr);
+
/* open up label */
PFarray_printf (dot,
"node_%i [label=\"{ <op%i> %s\\n",
@@ -452,7 +454,7 @@
case msa_op_table:
{
- PFarray_printf(dot, "%s\\n", n->sem.table.name);
+ PFarray_printf(dot, "| { table name: | %s}", n->sem.table.name);
/* print original names of table */
PFarray_printf(dot, "| { cols: ");
for (i = 0; i < elsize(n->sem.table.expr_list); i++) {
@@ -579,222 +581,329 @@
}
}
+/* --------------- DAG traversal functions --------------- */
+
/* stub declaration */
+static unsigned int traverse_expr_list (PFmsa_exprlist_t *list, unsigned int
node_id,
+ unsigned int (*f) (PFmsa_expr_t *,
unsigned int));
+
+/* Functions to perform the work */
+
+/* helper function that prepares the
+ DAG bit reset for expression nodes */
static unsigned int
-create_expr_id_in_list(PFmsa_exprlist_t *list, unsigned int i);
+prepare_reset_expr(PFmsa_expr_t *n, unsigned int node_id)
+{
+ assert (n);
+
+ /* no node_id used while preparing reset of bit_dag */
+ (void) node_id;
+
+ if (n->bit_reset)
+ return 0;
+ else
+ n->bit_reset = true;
+
+ return 0;
+}
+/* helper function that prepares the
+ DAG bit reset for expression nodes */
static unsigned int
-create_expr_id_worker(PFmsa_expr_t *n, unsigned int i)
+prepare_reset_op(PFmsa_op_t *n, unsigned int node_id)
+{
+ assert (n);
+
+ /* no node_id used while preparing reset of bit_dag */
+ (void) node_id;
+
+ if (n->bit_reset)
+ return 0;
+ else
+ n->bit_reset = true;
+
+ return 0;
+}
+
+/* helper function to reset the DAG bit in expressions */
+static unsigned int
+reset_expr (PFmsa_expr_t *n, unsigned int node_id)
+{
+ assert (n);
+
+ /* no node_id used while resetting bit_dag */
+ (void) node_id;
+
+ if (!n->bit_reset)
+ return 0;
+
+ n->bit_reset = false;
+ n->bit_dag = false;
+ return 0;
+}
+
+/* helper function to reset the DAG bit in operators */
+static unsigned int
+reset_op (PFmsa_op_t *n, unsigned int node_id)
+{
+ assert (n);
+
+ /* no node_id used while resetting bit_dag */
+ (void) node_id;
+
+ if (!n->bit_reset)
+ return 0;;
+
+ n->bit_reset = false;
+ n->bit_dag = false;
+ return 0;
+}
+
+/* helper function that sets the
+ node id for expression nodes */
+static unsigned int
+create_node_id_expr (PFmsa_expr_t *n, unsigned int node_id)
{
if (n->bit_dag)
- return i;
+ return node_id;
else
n->bit_dag = true;
- n->node_id = i++;
+ /* set node id */
+ n->node_id = node_id++;
- /* If expression has expression list, set node id for expressions as well
*/
+ return node_id;
+}
+
+/* helper function that sets the
+ node id for operators nodes */
+static unsigned int
+create_node_id_op (PFmsa_op_t *n, unsigned int node_id)
+{
+ if (n->bit_dag)
+ return node_id;
+ else
+ n->bit_dag = true;
+
+ /* set node id */
+ n->node_id = node_id++;
+
+ return node_id;
+}
+
+/* helper function that resets the
+ node id for expression nodes */
+static unsigned int
+reset_node_id_expr(PFmsa_expr_t *n, unsigned int node_id)
+{
+ assert (n);
+
+ /* no node_id used while preparing reset of bit_dag */
+ (void) node_id;
+
+ /* reset node id */
+ n->node_id = 0;
+
+ return 0;
+}
+
+/* helper function that resets the
+ node id for operator nodes */
+static unsigned int
+reset_node_id_op(PFmsa_op_t *n, unsigned int node_id)
+{
+ assert (n);
+
+ /* no node_id used while preparing reset of bit_dag */
+ (void) node_id;
+
+ /* reset node id */
+ n->node_id = 0;
+
+ return 0;
+}
+
+/* helper function that infers the
+ reference counter for expression nodes */
+static unsigned int
+infer_refctr_expr(PFmsa_expr_t *n, unsigned int node_id)
+{
+ assert (n);
+
+ /* no node_id used while preparing reset of bit_dag */
+ (void) node_id;
+
+ /* count number of incoming edges */
+ n->refctr++;
+
+ /* only descend once */
+ if (n->bit_dag)
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list