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

Modified Files:
      Tag: XQuery_0-24
        xml2lalg.c 
Log Message:
-- Re-implemented the join pushdown optimization phase
   (due to incorrect rewrites).

   o The special equi-join operator working on unique column
     names now incorporates for each operand a projection.

     Based on this projection we can now always maintain the
     correct schema and push the join even through renaming
     projections.

     The old variant did in some cases 'forget' from which
     operand of an equi-join columns with the same name stem
     from.

   o The new equi-join pushdown phase is a lot more effective
     than the old one and thus generates very wide relations
     (where a large number of columns can be pruned afterwards).

     Placing a projection pushdown phase (icols optimization)
     afterwards allows us to map the resulting plans back to
     bit-encoded column names without running out of column
     bits.


U xml2lalg.c
Index: xml2lalg.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/xmlimport/xml2lalg.c,v
retrieving revision 1.20
retrieving revision 1.20.2.1
diff -u -d -r1.20 -r1.20.2.1
--- xml2lalg.c  10 Apr 2008 13:38:46 -0000      1.20
+++ xml2lalg.c  28 May 2008 11:37:37 -0000      1.20.2.1
@@ -2131,15 +2131,99 @@
              <content>
                <column name="COLNAME" new="false" keep="BOOL" position="1"/>
                <column name="COLNAME" new="false" keep="BOOL" position="2"/>
+              (<column name="COLNAME" old_name="COLNAME" new="true"
+                       function="left"/>
+             | <column name="COLNAME" new="false" function"left"/>)*
+              (<column name="COLNAME" old_name="COLNAME" new="true"
+                       function="right"/>
+             | <column name="COLNAME" new="false" function"right"/>)*
              </content>
             */
 
+            PFarray_t *lproj = PFarray (sizeof (PFalg_proj_t), 10),
+                      *rproj = PFarray (sizeof (PFalg_proj_t), 10);
+            PFalg_att_t att1 = PFLA_ATT("/content/column"
+                                        "[EMAIL PROTECTED]'false' and 
@position='1']"
+                                        "/@name"),
+                        att2 = PFLA_ATT("/content/column"
+                                        "[EMAIL PROTECTED]'false' and 
@position='2']"
+                                        "/@name"),
+                        res  = PFLA_ATT("/content/column"
+                                        "[EMAIL PROTECTED]'false' and 
@kee='true']"
+                                        "/@name");
+            xmlXPathObjectPtr columnNames_xml;
+            int columnCount;
+
+            *(PFalg_proj_t *) PFarray_add (lproj) = proj (res, att1);
+            *(PFalg_proj_t *) PFarray_add (rproj) = proj (res, att2);
+            
+            /* fetch the left column elements from xml */
+            columnNames_xml =  XPATH("/content/[EMAIL PROTECTED]'left']");
+
+            /* how many projection columns do we have? */
+            columnCount = PFxml2la_xpath_getNodeCount(columnNames_xml);
+
+            /* fetch and relate the projections from xml 
+            to the corresponding projection array */ 
+            for (int c = 0; c < columnCount; c++)
+            {
+                xmlNodePtr projection_xml = 
+                    PFxml2la_xpath_getNthNode(columnNames_xml, c);
+
+                char* newName = 
PFxml2la_xpath_getAttributeValueFromElementNode(
+                    projection_xml, "name");
+                char* oldName = 
PFxml2la_xpath_getAttributeValueFromElementNode(
+                    projection_xml, "old_name");
+                if (oldName == NULL)
+                {
+                    oldName = newName;
+                }
+
+                *(PFalg_proj_t *) PFarray_add (lproj)
+                    = proj (ctx->convert2PFLA_attributeName(newName),
+                            ctx->convert2PFLA_attributeName(oldName));
+            }
+
+            if(columnNames_xml)
+                xmlXPathFreeObject(columnNames_xml);
+
+            
+            /* do the same for the right side */
+
+            
+            /* fetch the right column elements from xml */
+            columnNames_xml =  XPATH("/content/[EMAIL PROTECTED]'right']");
+
+            /* how many projection columns do we have? */
+            columnCount = PFxml2la_xpath_getNodeCount(columnNames_xml);
+
+            /* fetch and relate the projections from xml 
+            to the corresponding projection array */ 
+            for (int c = 0; c < columnCount; c++)
+            {
+                xmlNodePtr projection_xml = 
+                    PFxml2la_xpath_getNthNode(columnNames_xml, c);
+
+                char* newName = 
PFxml2la_xpath_getAttributeValueFromElementNode(
+                    projection_xml, "name");
+                char* oldName = 
PFxml2la_xpath_getAttributeValueFromElementNode(
+                    projection_xml, "old_name");
+                if (oldName == NULL)
+                {
+                    oldName = newName;
+                }
+
+                *(PFalg_proj_t *) PFarray_add (rproj)
+                    = proj (ctx->convert2PFLA_attributeName(newName),
+                            ctx->convert2PFLA_attributeName(oldName));
+            }
+
+            if(columnNames_xml)
+                xmlXPathFreeObject(columnNames_xml);
+
             newAlgNode = PFla_eqjoin_clone            
              (
-             CHILDNODE(0), CHILDNODE(1),
-             PFLA_ATT("/content/[EMAIL PROTECTED]'false' and 
@position='1']/@name"),
-             PFLA_ATT("/content/[EMAIL PROTECTED]'false' and 
@position='2']/@name"),
-             PFLA_ATT("/content/[EMAIL PROTECTED]'false' and 
@keep='true']/@name")
+             CHILDNODE(0), CHILDNODE(1), lproj, rproj
              );
         }  
         break;


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to