Update of /cvsroot/monetdb/pathfinder/compiler/algebra/opt
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv11627

Modified Files:
        opt_monetxq.c 
Log Message:
added second phase that adds projections after certain operations

this is needed to reduce timeouts with monetDB after running the opt_projection 
optimizaion (Y) that 'removes' projections 


U opt_monetxq.c
Index: opt_monetxq.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_monetxq.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- opt_monetxq.c       9 Mar 2009 15:01:54 -0000       1.4
+++ opt_monetxq.c       15 Apr 2009 10:49:02 -0000      1.5
@@ -224,6 +224,68 @@
     }
 }
 
+static void 
+opt_monetprojections (PFla_op_t *p)
+{
+    assert(p);
+    
+     /* infer properties for children */
+    for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++)
+        opt_monetprojections (p->child[i]);
+
+    
+     /* action code */
+    switch (p->kind) {
+    
+        /*
+         *         |
+         *      project_(icols)
+         *         |
+         *         p
+         *         |
+         */
+        case la_pos_select:
+        case la_select:
+        case la_eqjoin:
+        case la_thetajoin:
+        case la_guide_step_join:
+        case la_step_join:
+        case la_roots:
+        case la_cross:
+        case la_rownum:
+        case la_rowrank:
+        case la_rank:
+        case la_rowid:
+        case la_fun_1to1:
+        case la_num_gt:
+        case la_num_eq:
+        case la_bool_and:
+        case la_bool_not:
+        case la_bool_or:
+        case la_type: 
+        if (PFprop_icols_count(p->prop)) {
+            /* look up required columns (icols) */
+            PFalg_collist_t *icols = PFprop_icols_to_collist (p->prop);
+            PFalg_proj_t    *proj = PFmalloc (clsize (icols) *
+                                                sizeof (PFalg_proj_t));
+                                                
+            /* fill the projection list of the lower projection (proj1) */
+            for (unsigned int i = 0; i < clsize (icols); i++)
+                proj[i] = PFalg_proj (clat (icols, i), clat (icols, i));
+        
+            /* Place a pi_(icols) operator on top of the operator. */
+            *p = *PFla_project_ (
+                        PFla_op_duplicate (p, L(p), R(p)),
+                        clsize (icols),
+                        proj);
+            break;
+        }
+        
+        default:
+            break;
+    }
+}
+
 /**
  * MonetDB/XQuery specific optimizations:
  *  - Introduce additional distinct operators.
@@ -245,6 +307,15 @@
        of unreferenced columns (rule eqjoin). The icols optimization
        will ensure that these columns are 'really' never used. */
     root = PFalgopt_icol (root);
+    
+    /* start second transversal rewrite */
+    opt_monetprojections (root);
+    
+    /* In addition optimize the resulting DAG using the icols property
+       to remove inconsistencies introduced by changing the types
+       of unreferenced columns (rule eqjoin). The icols optimization
+       will ensure that these columns are 'really' never used. */
+    root = PFalgopt_icol (root);
 
     return root;
 }


------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to