Update of /cvsroot/monetdb/pathfinder/compiler/debug
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv29987/debug

Modified Files:
        logdebug.c physdebug.c 
Log Message:
-- Re-organized our set of numbering operators. We have now 4 different
   operators with consistent semantics that cope with sorting and numbering:

     - la_rownum behaves exactly like SQLs ROW_NUMBER. It is used to generate
       position values.

     - la_rowrank behaves exactly like SQLs DENSE_RANK. It is used to generate
       the group by semantics of our functional source language. Up til now
       we only need the unpartitioned variant. (In MIL it is implemented
       using the sort extend.)

     - la_rank -- beside one exception -- behaves like la_rowrank. It is also
       implemented in our SQL compilation with a DENSE_RANK operation. la_rank's
       important difference to la_rowrank is that its resulting values are used
       solely for ordering. No operation should ever look at the generated 
values.
       While this difference is uninteresting in the resulting code it 
simplifies
       the algebraic optimizer a lot. Instead of repeatedly inferring a property
       that checks for column usage we can optimize based on the operator kind.

     - la_rowid generates unrepeatable unique numbers (as 'ROW_NUMBER() OVER ()'
       does in SQL or 'mark()' does in MIL). It is used to generate a new key
       column for mapping joins.

   In comparison to the old version we introduced a new operator la_rowrank,
   changed the semantic of la_rank from ROW_NUMBER to DENSE_RANK, and renamed
   the formular la_number operator into la_rowid.

   To implement positions in our Core to Algebra translation consistently we
   now use only la_rownum (to generate real position values),
   la_rank (to represent intermediate position order), and constant values
   (to represent unordered sequences).

-- Introduced new SQL operator DENSE_RANK.

-- Splitted up the physical pa_number operator into the 3 operators:
   pa_mark, pa_rank, and pa_mark_grp. The first and the last operator correspond
   to the respective MIL primitives. The result column of pa_rank is generated
   by the extend column of a CTrefine operation.

-- Added check for environment variable PF_DEBUG_PRINT_FRAG to disable the
   fragment printing in the AT&T dot output of the logical algebra.



Index: logdebug.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/debug/logdebug.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- logdebug.c  26 Nov 2007 08:47:35 -0000      1.79
+++ logdebug.c  6 Dec 2007 08:42:34 -0000       1.80
@@ -78,9 +78,10 @@
     , [la_min]              = "MIN"
     , [la_sum]              = "SUM"
     , [la_count]            = "COUNT"
-    , [la_rownum]           = "ROW#"
+    , [la_rownum]           = "ROWNUM"
+    , [la_rowrank]          = "ROWRANK"
     , [la_rank]             = "RANK"
-    , [la_number]           = "NUMBER"
+    , [la_rowid]            = "ROWID"
     , [la_type]             = "TYPE"
     , [la_type_assert]      = "type assertion"
     , [la_cast]             = "CAST"
@@ -155,8 +156,9 @@
     , [la_sum]              = "sum"
     , [la_count]            = "count"
     , [la_rownum]           = "rownum"
+    , [la_rowrank]          = "rowrank"
     , [la_rank]             = "rank"
-    , [la_number]           = "number"
+    , [la_rowid]            = "rowid"
     , [la_type]             = "type"
     , [la_type_assert]      = "type assertion"
     , [la_cast]             = "cast"
@@ -309,7 +311,7 @@
  * @param n The current node to print (function is recursive)
  */
 static void
-la_dot (PFarray_t *dot, PFla_op_t *n)
+la_dot (PFarray_t *dot, PFla_op_t *n, bool print_frag_info)
 {
     unsigned int c;
     assert(n->node_id);
@@ -346,8 +348,9 @@
         , [la_sum]             = "#A0A0A0"
         , [la_count]           = "#A0A0A0"
         , [la_rownum]          = "#FF0000"
+        , [la_rowrank]         = "#FF0000"
         , [la_rank]            = "#FF3333"
-        , [la_number]          = "#FF9999"
+        , [la_rowid]           = "#FF9999"
         , [la_type]            = "#C0C0C0"
         , [la_type_assert]     = "#C0C0C0"
         , [la_cast]            = "#C0C0C0"
@@ -631,64 +634,41 @@
             break;
 
         case la_rownum:
+        case la_rowrank:
+        case la_rank:
             PFarray_printf (dot, "%s (%s:<", a_id[n->kind],
-                            PFatt_str (n->sem.rownum.res));
+                            PFatt_str (n->sem.sort.res));
 
-            if (PFord_count (n->sem.rownum.sortby))
+            if (PFord_count (n->sem.sort.sortby))
                 PFarray_printf (dot, "%s%s", 
                                 PFatt_str (
                                     PFord_order_col_at (
-                                        n->sem.rownum.sortby, 0)),
+                                        n->sem.sort.sortby, 0)),
                                 PFord_order_dir_at (
-                                    n->sem.rownum.sortby, 0) == DIR_ASC
+                                    n->sem.sort.sortby, 0) == DIR_ASC
                                 ? "" : " (desc)");
 
-            for (c = 1; c < PFord_count (n->sem.rownum.sortby); c++)
+            for (c = 1; c < PFord_count (n->sem.sort.sortby); c++)
                 PFarray_printf (dot, ", %s%s", 
                                 PFatt_str (
                                     PFord_order_col_at (
-                                        n->sem.rownum.sortby, c)),
+                                        n->sem.sort.sortby, c)),
                                 PFord_order_dir_at (
-                                    n->sem.rownum.sortby, c) == DIR_ASC
+                                    n->sem.sort.sortby, c) == DIR_ASC
                                 ? "" : " (desc)");
 
             PFarray_printf (dot, ">");
 
-            if (n->sem.rownum.part != att_NULL)
+            if (n->sem.sort.part != att_NULL)
                 PFarray_printf (dot, "/%s", 
-                                PFatt_str (n->sem.rownum.part));
+                                PFatt_str (n->sem.sort.part));
 
             PFarray_printf (dot, ")");
             break;
 
-        case la_rank:
-            PFarray_printf (dot, "%s (%s:<", a_id[n->kind],
-                            PFatt_str (n->sem.rank.res));
-
-            if (PFord_count (n->sem.rank.sortby))
-                PFarray_printf (dot, "%s%s", 
-                                PFatt_str (
-                                    PFord_order_col_at (
-                                        n->sem.rank.sortby, 0)),
-                                PFord_order_dir_at (
-                                    n->sem.rank.sortby, 0) == DIR_ASC
-                                ? "" : " (desc)");
-
-            for (c = 1; c < PFord_count (n->sem.rank.sortby); c++)
-                PFarray_printf (dot, ", %s%s", 
-                                PFatt_str (
-                                    PFord_order_col_at (
-                                        n->sem.rank.sortby, c)),
-                                PFord_order_dir_at (
-                                    n->sem.rank.sortby, c) == DIR_ASC
-                                ? "" : " (desc)");
-
-            PFarray_printf (dot, ">)");
-            break;
-
-        case la_number:
+        case la_rowid:
             PFarray_printf (dot, "%s (%s)", a_id[n->kind],
-                            PFatt_str (n->sem.number.res));
+                            PFatt_str (n->sem.rowid.res));
             break;
 
         case la_type:
@@ -1152,6 +1132,13 @@
     PFarray_printf (dot, "\", color=\"%s\" ];\n", color[n->kind]);
 
     for (c = 0; c < PFLA_OP_MAXCHILD && n->child[c]; c++) {      
+        /* Avoid printing the fragment info to make the graphs
+           more readable. */
+        if (print_frag_info &&
+            (n->child[c]->kind == la_frag_union ||
+             n->child[c]->kind == la_empty_frag ||
+             (n->kind == la_fcns && c == 1 && n->child[c]->kind == la_nil)))
+            continue;
         PFarray_printf (dot, "node%i -> node%i;\n",
                         n->node_id, n->child[c]->node_id);
     }
@@ -1198,8 +1185,15 @@
     n->bit_dag = true;
 
     for (c = 0; c < PFLA_OP_MAXCHILD && n->child[c]; c++) {
+        /* Avoid printing the fragment info to make the graphs
+           more readable. */
+        if (print_frag_info &&
+            (n->child[c]->kind == la_frag_union ||
+             n->child[c]->kind == la_empty_frag ||
+             (n->kind == la_fcns && c == 1 && n->child[c]->kind == la_nil)))
+            continue;
         if (!n->child[c]->bit_dag)
-            la_dot (dot, n->child[c]);
+            la_dot (dot, n->child[c], print_frag_info);
     }
 }
 
@@ -1702,61 +1696,41 @@
             break;
 
         case la_rownum:
+        case la_rowrank:
+        case la_rank:
             PFarray_printf (xml, 
                             "    <content>\n" 
                             "      <column name=\"%s\" new=\"true\"/>\n",
-                            PFatt_str (n->sem.rownum.res));
+                            PFatt_str (n->sem.sort.res));
 
-            for (c = 0; c < PFord_count (n->sem.rownum.sortby); c++)
+            for (c = 0; c < PFord_count (n->sem.sort.sortby); c++)
                 PFarray_printf (xml, 
                                 "      <column name=\"%s\" function=\"sort\""
                                         " position=\"%u\" direction=\"%s\""
                                         " new=\"false\"/>\n",
                                 PFatt_str (
                                     PFord_order_col_at (
-                                        n->sem.rownum.sortby, c)),
+                                        n->sem.sort.sortby, c)),
                                 c+1,
                                 PFord_order_dir_at (
-                                    n->sem.rownum.sortby, c) == DIR_ASC
+                                    n->sem.sort.sortby, c) == DIR_ASC
                                 ? "ascending" : "descending");
 
-            if (n->sem.rownum.part != att_NULL)
+            if (n->sem.sort.part != att_NULL)
                 PFarray_printf (xml,
                                 "      <column name=\"%s\" 
function=\"partition\""
                                         " new=\"false\"/>\n",
-                                PFatt_str (n->sem.rownum.part));
-
-            PFarray_printf (xml, "    </content>\n");
-            break;
-
-        case la_rank:
-            PFarray_printf (xml, 
-                            "    <content>\n" 
-                            "      <column name=\"%s\" new=\"true\"/>\n",
-                            PFatt_str (n->sem.rank.res));
-
-            for (c = 0; c < PFord_count (n->sem.rank.sortby); c++)
-                PFarray_printf (xml, 
-                                "      <column name=\"%s\" function=\"sort\""
-                                        " position=\"%u\" direction=\"%s\""
-                                        " new=\"false\"/>\n",
-                                PFatt_str (
-                                    PFord_order_col_at (
-                                        n->sem.rank.sortby, c)),
-                                c+1,
-                                PFord_order_dir_at (
-                                    n->sem.rank.sortby, c) == DIR_ASC
-                                ? "ascending" : "descending");
+                                PFatt_str (n->sem.sort.part));
 
             PFarray_printf (xml, "    </content>\n");
             break;
 
-        case la_number:
+        case la_rowid:
             PFarray_printf (xml, 
                             "    <content>\n" 
                             "      <column name=\"%s\" new=\"true\"/>\n"
                             "    </content>\n",
-                            PFatt_str (n->sem.number.res));
+                            PFatt_str (n->sem.rowid.res));
             break;
 
         case la_type:
@@ -2135,7 +2109,7 @@
                              "edge [dir=back];\n");
 
         create_node_id (root);
-        la_dot (dot, root);
+        la_dot (dot, root, getenv("PF_DEBUG_PRINT_FRAG") != NULL);
         PFla_dag_reset (root);
         reset_node_id (root);
 
@@ -2173,8 +2147,6 @@
         /* initialize array to hold dot output */
         PFarray_t *xml = PFarray (sizeof (char));
 
-
-        
         PFarray_printf (xml, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
         PFarray_printf (xml, "<logical_query_plan unique_names=\"%s\">\n",
                         (PFalg_is_unq_name(root->schema.items[0].name) ? 
"true" : "false"));

Index: physdebug.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/debug/physdebug.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- physdebug.c 4 Oct 2007 10:40:47 -0000       1.43
+++ physdebug.c 6 Dec 2007 08:42:35 -0000       1.44
@@ -88,7 +88,9 @@
     , [pa_max]             = "MIN"
     , [pa_sum]             = "SUM"
     , [pa_hash_count]      = "HASH_COUNT"
-    , [pa_number]          = "NUMBER"            /* \"#FF0000\" */
+    , [pa_mark]            = "mark"
+    , [pa_rank]            = "rank"
+    , [pa_mark_grp]        = "mark_grp"
     , [pa_type]            = "TYPE"
     , [pa_type_assert]     = "type assertion"
     , [pa_cast]            = "CAST"
@@ -170,7 +172,9 @@
     , [pa_max]             = "min"
     , [pa_sum]             = "sum"
     , [pa_hash_count]      = "hash_count"
-    , [pa_number]          = "number"
+    , [pa_mark]            = "mark"
+    , [pa_rank]            = "rank"
+    , [pa_mark_grp]        = "mark_grp"
     , [pa_type]            = "type"
     , [pa_type_assert]     = "type assertion"
     , [pa_cast]            = "cast"
@@ -366,7 +370,9 @@
         , [pa_min]             = "\"#A0A0A0\""
         , [pa_sum]             = "\"#A0A0A0\""
         , [pa_hash_count]      = "\"#A0A0A0\""
-        , [pa_number]          = "\"#FFBBBB\""
+        , [pa_mark]            = "\"#FFBBBB\""
+        , [pa_rank]            = "\"#FFBBBB\""
+        , [pa_mark_grp]        = "\"#FFBBBB\""
         , [pa_type]            = "\"#C0C0C0\""
         , [pa_type_assert]     = "\"#C0C0C0\""
         , [pa_cast]            = "\"#C0C0C0\""
@@ -613,16 +619,22 @@
                                 PFatt_str (n->sem.aggr.part));
             break;
 
-        case pa_number:
+        case pa_mark:
+        case pa_mark_grp:
             PFarray_printf (dot, "%s (%s", a_id[n->kind],
-                            PFatt_str (n->sem.number.attname));
-            if (n->sem.number.part != att_NULL)
+                            PFatt_str (n->sem.mark.res));
+            if (n->sem.mark.part != att_NULL)
                 PFarray_printf (dot, "/%s", 
-                                PFatt_str (n->sem.number.part));
+                                PFatt_str (n->sem.mark.part));
 
             PFarray_printf (dot, ")");
             break;
 
+        case pa_rank:
+            PFarray_printf (dot, "%s (%s)", a_id[n->kind],
+                            PFatt_str (n->sem.rank.res));
+            break;
+            
         case pa_type:
             PFarray_printf (dot, "%s (%s:<%s>), type: %s", a_id[n->kind],
                             PFatt_str (n->sem.type.res),
@@ -1268,27 +1280,39 @@
             PFarray_printf (xml, "    </content>\n");
             break;
 
-        case pa_number:
+        case pa_mark:
+        case pa_mark_grp:
             PFarray_printf (xml, 
                             "    <content>\n" 
                             "      <column name=\"%s\" new=\"true\">\n"
                             "        <annotation>new number column"
                                     "</annotation>\n"
                             "      </column>\n",
-                            PFatt_str (n->sem.number.attname));
+                            PFatt_str (n->sem.mark.res));
 
-            if (n->sem.number.part != att_NULL)
+            if (n->sem.mark.part != att_NULL)
                 PFarray_printf (xml,
                                 "      <column name=\"%s\" 
function=\"partition\""
                                         " new=\"false\">\n"
                                 "        <annotation>partitioning argument"
                                         "</annotation>\n"
                                 "      </column>\n",
-                                PFatt_str (n->sem.number.part));
+                                PFatt_str (n->sem.mark.part));
 
             PFarray_printf (xml, "    </content>\n");
             break;
 
+        case pa_rank:
+            PFarray_printf (xml, 
+                            "    <content>\n" 
+                            "      <column name=\"%s\" new=\"true\">\n"
+                            "        <annotation>new rank column"
+                                    "</annotation>\n"
+                            "      </column>\n"
+                            "    </content>\n",
+                            PFatt_str (n->sem.rank.res));
+            break;
+
         case pa_type:
             PFarray_printf (xml, 
                             "    <content>\n" 


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to