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

Modified Files:
      Tag: PF_ROX
        builtins.c core2alg.brg logical.c physical.c planner.c 
Log Message:
propagated changes of Monday May 19 2008 - Thursday May 22 2008
from the development trunk to the PF_ROX branch



U physical.c
Index: physical.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/physical.c,v
retrieving revision 1.53.2.9
retrieving revision 1.53.2.10
diff -u -d -r1.53.2.9 -r1.53.2.10
--- physical.c  14 May 2008 20:08:35 -0000      1.53.2.9
+++ physical.c  22 May 2008 08:48:29 -0000      1.53.2.10
@@ -3571,4 +3571,26 @@
     return ret;
 }
 
+/**
+ * Constructor for finding nodes based on id/idref
+ */
+PFpa_op_t *
+PFpa_findnodes (const PFpa_op_t *doc, const PFpa_op_t *n,
+                PFalg_att_t item,
+                PFalg_att_t item_doc,
+                PFalg_att_t item_res,
+                bool id)
+{
+    PFpa_op_t *ret = wire2 (pa_findnodes , doc, n);
+
+    ret->sem.findnodes.id = id;
+    ret->sem.findnodes.item = item;
+    ret->sem.findnodes.item_doc = item_doc;
+    ret->sem.findnodes.item_res = item_res;
+
+    ret->cost = DEFAULT_COST + doc->cost + n->cost;
+
+    return ret;
+}
+
 /* vim:set shiftwidth=4 expandtab: */

U core2alg.brg
Index: core2alg.brg
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/core2alg.brg,v
retrieving revision 1.60.4.7
retrieving revision 1.60.4.8
diff -u -d -r1.60.4.7 -r1.60.4.8
--- core2alg.brg        17 Apr 2008 14:30:56 -0000      1.60.4.7
+++ core2alg.brg        22 May 2008 08:48:28 -0000      1.60.4.8
@@ -3005,13 +3005,8 @@
                 att_pos, sortby (att_item));
 }
 
-/**
- * Construct a relational expression for a path step
- */
-static struct PFla_pair_t
-locstep (core2alg_ctx_t *ctx,
-         PFalg_axis_t axis, PFty_t ty,
-         struct PFla_pair_t p)
+static PFalg_step_spec_t
+locstep_spec (PFalg_axis_t axis, PFty_t ty)
 {
     PFalg_step_spec_t spec;
 
@@ -3058,6 +3053,17 @@
         spec.kind = node_kind_node;
     }
 
+    return spec;
+}
+
+/**
+ * Construct a relational expression for a path step
+ */
+static struct PFla_pair_t
+locstep (core2alg_ctx_t *ctx,
+         PFalg_axis_t axis, PFty_t ty,
+         struct PFla_pair_t p)
+{
     /*
      *                  env, loop: e => (q(e), delta)
      * ------------------------------------------------------------
@@ -3072,7 +3078,8 @@
                           project (p.rel,
                                    proj (att_iter, att_iter),
                                    proj (att_item, att_item)),
-                          spec, att_iter, att_item, att_item);
+                          locstep_spec (axis, ty),
+                          att_iter, att_item, att_item);
 
     if (ORDERING)
         return (struct  PFla_pair_t) {
@@ -3150,49 +3157,66 @@
      *
      */
     else if (PFty_subtype (ty, PFty_star (PFty_xs_integer ())))
-        itemty = project (type (e.rel, att_itemty, att_item, aat_int),
-                          proj (att_iter, att_iter),
-                          proj (att_pos, att_pos),
-                          proj (att_itemty, att_itemty));
+        itemty = type (e.rel, att_itemty, att_item, aat_int);
     else if (PFty_subtype (ty, PFty_star (PFty_xs_decimal ())))
         /* xs:integer is a subtype of xs:decimal.
          * Test for both types. The `type' operator merely adds a boolean
          * column. We OR them after testing for for both types.
          */
-        itemty =
-            project (
-                or (type (type (e.rel, att_isint, att_item, aat_int),
-                          att_isdec, att_item, aat_dec),
-                    att_itemty, att_isint, att_isdec),
-                proj (att_iter, att_iter),
-                proj (att_pos, att_pos),
-                proj (att_itemty, att_itemty));
+        itemty = or (type (type (e.rel, att_isint, att_item, aat_int),
+                           att_isdec, att_item, aat_dec),
+                     att_itemty, att_isint, att_isdec);
     else if (PFty_subtype (ty, PFty_star (PFty_xs_double ())))
-        itemty = project (type (e.rel, att_itemty, att_item, aat_dbl),
-                          proj (att_iter, att_iter),
-                          proj (att_pos, att_pos),
-                          proj (att_itemty, att_itemty));
+        itemty = type (e.rel, att_itemty, att_item, aat_dbl);
     else if (PFty_subtype (ty, PFty_star (PFty_xs_boolean ())))
-        itemty = project (type (e.rel, att_itemty, att_item, aat_bln),
-                          proj (att_iter, att_iter),
-                          proj (att_pos, att_pos),
-                          proj (att_itemty, att_itemty));
+        itemty = type (e.rel, att_itemty, att_item, aat_bln);
     else if (PFty_subtype (ty, PFty_star (PFty_xs_string ())))
-        itemty = project (type (e.rel, att_itemty, att_item, aat_str),
-                          proj (att_iter, att_iter),
-                          proj (att_pos, att_pos),
-                          proj (att_itemty, att_itemty));
+        itemty = type (e.rel, att_itemty, att_item, aat_str);
     else if (PFty_subtype (ty, PFty_star (PFty_untypedAtomic ())))
-        itemty = project (type (e.rel, att_itemty, att_item, aat_uA),
-                          proj (att_iter, att_iter),
-                          proj (att_pos, att_pos),
-                          proj (att_itemty, att_itemty));
+        itemty = type (e.rel, att_itemty, att_item, aat_uA);
+    else if (PFty_subtype (ty, PFty_star (PFty_xs_anyNode ()))) {
+        PFla_op_t *filter, *number, *in_loop;
+        
+        /* create a key for all rows */
+        number  = rowid (e.rel, att_inner);
+        /* use this key as inner loop relation */
+        in_loop = project (number, proj (att_iter1, att_inner));
+        /* evaluate for all nodes a self step that filters the correct
+           kind and name */ 
+        filter  = project (
+                      step_join (
+                          PFla_set_to_la (e.frag),
+                          type_assert_pos (
+                              select_ (
+                                  type (number, att_itemty, att_item, 
aat_node),
+                                  att_itemty),
+                              att_item, aat_node),
+                          locstep_spec (alg_self, PFty_prime (ty)), -1,
+                          att_item, att_item2),
+                      proj (att_iter1, att_inner));
+        
+        /* Attach the Boolean value true for all rows that matched the
+           self step filter and the value false for all other rows.
+           Map back the old iter values to the new Boolean item column */
+        itemty = eqjoin (number,
+                         disjunion (attach (filter,
+                                            att_itemty,
+                                            lit_bln (true)),
+                                    attach (difference (in_loop, filter),
+                                            att_itemty,
+                                            lit_bln (false))),
+                         att_inner,
+                         att_iter1);
+    }
     else
         PFoops (OOPS_FATAL,
                 "Sorry, I cannot translate the test for type `%s'",
                 PFty_str (ty));
 
-
+    itemty = project (itemty,
+                      proj (att_iter, att_iter),
+                      proj (att_itemty, att_itemty));
+        
     /*
      * Second part is the test for the occurence indicator.
      */
@@ -3217,10 +3241,7 @@
     if (PFty_subtype (ty, PFty_item ()))
         return
             disjunion (
-                seqty1 (project (itemty,
-                                 proj (att_iter, att_iter),
-                                 proj (att_item, att_itemty)),
-                        att_subty, att_item, att_iter),
+                seqty1 (itemty, att_subty, att_itemty, att_iter),
                 attach (
                     difference (
                         loop,
@@ -3241,10 +3262,7 @@
     if (PFty_subtype (ty, PFty_opt (PFty_item ())))
         return
             disjunion (
-                seqty1 (project (itemty,
-                                 proj (att_iter, att_iter),
-                                 proj (att_item, att_itemty)),
-                        att_subty, att_item, att_iter),
+                seqty1 (itemty, att_subty, att_itemty, att_iter),
                 attach (
                     difference (
                         loop,
@@ -3271,10 +3289,7 @@
     if (PFty_subtype (ty, PFty_plus (PFty_item ())))
         return
             disjunion (
-                all (project (itemty,
-                              proj (att_iter, att_iter),
-                              proj (att_item, att_itemty)),
-                     att_subty, att_item, att_iter),
+                all (itemty, att_subty, att_itemty, att_iter),
                 attach (
                     difference (
                         loop,
@@ -3295,10 +3310,7 @@
     if (PFty_subtype (ty, PFty_star (PFty_item ())))
         return
             disjunion (
-                all (project (itemty,
-                              proj (att_iter, att_iter),
-                              proj (att_item, att_itemty)),
-                     att_subty, att_item, att_iter),
+                all (itemty, att_subty, att_itemty, att_iter),
                 attach (
                     difference (
                         loop,

U planner.c
Index: planner.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/planner.c,v
retrieving revision 1.47.2.6
retrieving revision 1.47.2.7
diff -u -d -r1.47.2.6 -r1.47.2.7
--- planner.c   17 Apr 2008 14:31:04 -0000      1.47.2.6
+++ planner.c   22 May 2008 08:48:31 -0000      1.47.2.7
@@ -1165,7 +1165,8 @@
 
     assert (n);
     assert (n->kind == la_avg || n->kind == la_max
-            || n->kind == la_min || n->kind == la_sum);
+            || n->kind == la_min || n->kind == la_sum
+            || n->kind == la_seqty1 || n->kind == la_all);
     assert (L(n)); assert (L(n)->plans);
 
     /* consider each plan in n */
@@ -2673,66 +2674,86 @@
         case la_num_gt:
         case la_bool_and:
         case la_bool_or:
-                                plans = plan_binop (n);        break;
-
-        case la_bool_not:
-                                plans = plan_unary (n);        break;
-        case la_to:             plans = plan_to (n);           break;
-        case la_count:          plans = plan_count (n);        break;
-        case la_avg:            plans = plan_aggr (pa_avg, n); break;
-        case la_max:            plans = plan_aggr (pa_max, n); break;
-        case la_min:            plans = plan_aggr (pa_min, n); break;
-        case la_sum:            plans = plan_aggr (pa_sum, n); break;
+                                plans = plan_binop (n);           break;
+                                                                  
+        case la_bool_not:                                         
+                                plans = plan_unary (n);           break;
+        case la_to:             plans = plan_to (n);              break;
+        case la_count:          plans = plan_count (n);           break;
+        case la_avg:            plans = plan_aggr (pa_avg, n);    break;
+        case la_max:            plans = plan_aggr (pa_max, n);    break;
+        case la_min:            plans = plan_aggr (pa_min, n);    break;
+        case la_sum:            plans = plan_aggr (pa_sum, n);    break;
 
-        case la_rownum:         plans = plan_rownum (n);       break;
+        case la_rownum:         plans = plan_rownum (n);          break;
         case la_rowrank:
             PFinfo (OOPS_WARNING,
                     "The column generated by the rowrank operator"
                     " will not start with value 1");
             /* fall through */
-        case la_rank:           plans = plan_rank (n);         break;
-        case la_rowid:          plans = plan_rowid (n);       break;
-        case la_type:           plans = plan_type (n);         break;
-        case la_type_assert:    plans = plan_type_assert (n);  break;
-        case la_cast:           plans = plan_cast (n);         break;
-     /* case la_seqty1:         */
-     /* case la_all:            */
-
-        case la_step:           plans = plan_step (n);         break;
-        case la_doc_tbl:        plans = plan_doc_tbl (n);      break;
-        case la_doc_access:     plans = plan_doc_access (n);   break;
-
-        case la_twig:           plans = plan_twig (n);         break;
-        case la_fcns:           plans = plan_fcns (n);         break;
-        case la_docnode:        plans = plan_docnode (n);      break;
-        case la_element:        plans = plan_element (n);      break;
-        case la_attribute:      plans = plan_attribute (n);    break;
-        case la_textnode:       plans = plan_textnode (n);     break;
-        case la_comment:        plans = plan_comment (n);      break;
-        case la_processi:       plans = plan_processi (n);     break;
-        case la_content:        plans = plan_content (n);      break;
+        case la_rank:           plans = plan_rank (n);            break;
+        case la_rowid:          plans = plan_rowid (n);           break;
+        case la_type:           plans = plan_type (n);            break;
+        case la_type_assert:    plans = plan_type_assert (n);     break;
+        case la_cast:           plans = plan_cast (n);            break;
+        case la_seqty1:         plans = plan_aggr (pa_seqty1, n); break;
+        case la_all:            plans = plan_aggr (pa_all, n);    break;
+                                                                  
+        case la_step:           plans = plan_step (n);            break;
+        case la_doc_tbl:        plans = plan_doc_tbl (n);         break;
 
-        case la_merge_adjacent: plans = plan_merge_texts (n);  break;
-        /* copy the plans from the children */
-        case la_roots:          plans = L(n)->plans;           break;
-        /* dummy plans (they are not used anyway) */
-        case la_fragment:
-        case la_frag_extract:
-        case la_frag_union:
-        case la_empty_frag:
-                                plans = new_planlist ();       break;
+        /* case doc_index_join */
+        case la_doc_index_join:
+            /* need to first check the doc_join->kind to decide which
+             * physical operator to construct                         */
+            if (n->sem.doc_join.kind == la_dj_id ||
+                n->sem.doc_join.kind == la_dj_idref) {
+                /* fn:id or fn:idref */
 
-        case la_error:          plans = plan_error (n);        break;
-        case la_cond_err:       plans = plan_cond_err (n);     break;
+            } else if (n->sem.doc_join.kind == la_dj_text ||
+                n->sem.doc_join.kind == la_dj_attr) {
+                /* pf:attribute, pf:text*/
+                PFoops (OOPS_FATAL,
+                    "physical algebra equivalent for logical algebra "
+                    "node kind %u,%u not implemented, yet",
+                    n->kind, n->sem.doc_join.kind);
+            }
 
-        case la_nil:
-            plans = new_planlist ();
-            add_plan (plans, nil ());
-            break;
+        break;
 
-        case la_trace:          plans = plan_trace (n);        break;
-        case la_trace_msg:      plans = plan_trace_msg (n);    break;
-        case la_trace_map:      plans = plan_trace_map (n);    break;
+        case la_doc_access:     plans = plan_doc_access (n);      break;
+                                                                  
+        case la_twig:           plans = plan_twig (n);            break;
+        case la_fcns:           plans = plan_fcns (n);            break;
+        case la_docnode:        plans = plan_docnode (n);         break;
+        case la_element:        plans = plan_element (n);         break;
+        case la_attribute:      plans = plan_attribute (n);       break;
+        case la_textnode:       plans = plan_textnode (n);        break;
+        case la_comment:        plans = plan_comment (n);         break;
+        case la_processi:       plans = plan_processi (n);        break;
+        case la_content:        plans = plan_content (n);         break;
+                                                                  
+        case la_merge_adjacent: plans = plan_merge_texts (n);     break;
+        /* copy the plans from the children */                    
+        case la_roots:          plans = L(n)->plans;              break;
+        /* dummy plans (they are not used anyway) */              
+        case la_fragment:                                         
+        case la_frag_extract:                                     
+        case la_frag_union:                                       
+        case la_empty_frag:                                       
+                                plans = new_planlist ();          break;
+                                                                  
+        case la_error:          plans = plan_error (n);           break;
+        case la_cond_err:       plans = plan_cond_err (n);        break;
+                                                                  
+        case la_nil:                                              
+            plans = new_planlist ();                              
+            add_plan (plans, nil ());                             
+            break;                                                
+                                                                  
+        case la_trace:          plans = plan_trace (n);           break;
+        case la_trace_msg:      plans = plan_trace_msg (n);       break;
+        case la_trace_map:      plans = plan_trace_map (n);       break;
 
         case la_rec_fix:
         {
@@ -2836,11 +2857,11 @@
             fun_call_kind = old_fun_call_kind;
         } break;
 
-        case la_fun_param:      plans = plan_fun_param (n);    break;
+        case la_fun_param:      plans = plan_fun_param (n);       break;
         /* copy the plans from the rest of the list */
-        case la_fun_frag_param: plans = R(n)->plans;           break;
+        case la_fun_frag_param: plans = R(n)->plans;              break;
 
-        case la_string_join:    plans = plan_string_join (n);  break;
+        case la_string_join:    plans = plan_string_join (n);     break;
 
         default:
             PFoops (OOPS_FATAL,

U logical.c
Index: logical.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/logical.c,v
retrieving revision 1.78.2.8
retrieving revision 1.78.2.9
diff -u -d -r1.78.2.8 -r1.78.2.9
--- logical.c   14 May 2008 20:08:34 -0000      1.78.2.8
+++ logical.c   22 May 2008 08:48:29 -0000      1.78.2.9
@@ -2455,53 +2455,8 @@
 PFla_seqty1 (const PFla_op_t *n,
              PFalg_att_t res, PFalg_att_t att, PFalg_att_t part)
 {
-    unsigned int  i;
-    bool          att_found = false;
-    bool          part_found = false;
-    PFla_op_t    *ret;
-
-    assert (n);
-    assert (res); assert (att); assert (part);
-
-    /* sanity checks: value attribute must not equal partitioning attribute */
-    if (att == part)
-        PFoops (OOPS_FATAL,
-                "seqty1 operator: value attribute equals partitioning "
-                "attribute.");
-
-    /* both attributes must exist and must have appropriate type */
-    for (i = 0; i < n->schema.count; i++) {
-        if (att == n->schema.items[i].name) {
-            att_found = true;
-            if (n->schema.items[i].type != aat_bln)
-                PFoops (OOPS_FATAL,
-                        "algebra operator `seqty1' only allowed on boolean "
-                        "attributes. (attribute `%s')", PFatt_str (att));
-        }
-        if (part == n->schema.items[i].name)
-            part_found = true;
-    }
-
-    if (!att_found || !part_found)
-        PFoops (OOPS_FATAL,
-                "seqty1: value attribute or partitioning attribute not 
found.");
-
-    /* Now we can actually construct the result node */
-    ret = la_op_wire1 (la_seqty1, n);
-
-    ret->sem.aggr.res  = res;
-    ret->sem.aggr.att  = att;
-    ret->sem.aggr.part = part;
-
-    ret->schema.count = 2;
-    ret->schema.items = PFmalloc (2 * sizeof (PFalg_schema_t));
-
-    ret->schema.items[0].name = part;
-    ret->schema.items[0].type = PFprop_type_of (n, part);
-    ret->schema.items[1].name = res;
-    ret->schema.items[1].type = aat_bln;
-
-    return ret;
+    assert (PFprop_type_of (n, att) == aat_bln);
+    return PFla_aggr (la_seqty1, n, res, att, part);
 }
 
 
@@ -2519,53 +2474,8 @@
 PFla_all (const PFla_op_t *n,
           PFalg_att_t res, PFalg_att_t att, PFalg_att_t part)
 {
-    unsigned int  i;
-    bool          att_found = false;
-    bool          part_found = false;
-    PFla_op_t    *ret;
-
-    assert (n);
-    assert (res); assert (att); assert (part);
-
-    /* sanity checks: value attribute must not equal partitioning attribute */
-    if (att == part)
-        PFoops (OOPS_FATAL,
-                "all operator: value attribute equals partitioning "
-                "attribute.");
-
-    /* both attributes must exist and must have appropriate type */
-    for (i = 0; i < n->schema.count; i++) {
-        if (att == n->schema.items[i].name) {
-            att_found = true;
-            if (n->schema.items[i].type != aat_bln)
-                PFoops (OOPS_FATAL,
-                        "algebra operator `all' only allowed on boolean "
-                        "attributes. (attribute `%s')", PFatt_str (att));
-        }
-        if (part  == n->schema.items[i].name)
-            part_found = true;
-    }
-
-    if (!att_found || !part_found)
-        PFoops (OOPS_FATAL,
-                "all: value attribute or partitioning attribute not found.");
-
-    /* Now we can actually construct the result node */
-    ret = la_op_wire1 (la_all, n);
-
-    ret->sem.aggr.res  = res;
-    ret->sem.aggr.att  = att;
-    ret->sem.aggr.part = part;
-
-    ret->schema.count = 2;
-    ret->schema.items = PFmalloc (2 * sizeof (PFalg_schema_t));
-
-    ret->schema.items[0].name = part;
-    ret->schema.items[0].type = PFprop_type_of (n, part);
-    ret->schema.items[1].name = res;
-    ret->schema.items[1].type = aat_bln;
-
-    return ret;
+    assert (PFprop_type_of (n, att) == aat_bln);
+    return PFla_aggr (la_all, n, res, att, part);
 }
 
 

U builtins.c
Index: builtins.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/builtins.c,v
retrieving revision 1.75.2.7
retrieving revision 1.75.2.8
diff -u -d -r1.75.2.7 -r1.75.2.8
--- builtins.c  14 May 2008 20:08:32 -0000      1.75.2.7
+++ builtins.c  22 May 2008 08:48:28 -0000      1.75.2.8
@@ -5561,6 +5561,7 @@
                        eqjoin (args[0].rel,
                                project (rev,
                                         proj (att_iter1, att_iter),
+                                        proj (att_pos1, att_pos),
                                         proj (att_item1, att_item)),
                                att_iter,
                                att_iter1),
@@ -5568,7 +5569,7 @@
                        att_res,
                        attlist (att_item, att_item1)),
                    proj (att_iter, att_iter),
-                   proj (att_pos, att_pos),
+                   proj (att_pos, att_pos1),
                    proj (att_item, att_res)),
         .frag = args[0].frag };
 }
@@ -5655,6 +5656,7 @@
                        eqjoin (args[0].rel,
                                project (rev,
                                         proj (att_iter1, att_iter),
+                                        proj (att_pos1, att_pos),
                                         proj (att_item1, att_item)),
                                att_iter,
                                att_iter1),
@@ -5662,7 +5664,7 @@
                        att_res,
                        attlist (att_item, att_item1)),
                    proj (att_iter, att_iter),
-                   proj (att_pos, att_pos),
+                   proj (att_pos, att_pos1),
                    proj (att_item, att_res)),
         .frag = args[0].frag };
 }


-------------------------------------------------------------------------
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