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

Modified Files:
        prop_card.c prop_composite_key.c prop_const.c prop_dom.c 
        prop_dom_nat.c prop_guide.c prop_icol.c prop_key.c 
        prop_level.c prop_ocol.c prop_ori_names.c prop_rec_delta.c 
        prop_reqval.c prop_set.c prop_trace_names.c prop_unq_names.c 
Log Message:
-- Implemented generic function application facility (for the logical algebra).

   Generic functions can now be implemented in the logical algebra using
   the following 4 operators:

   o la_fun_call:
     The head of a function call whose left child is the loop relation and the
     right child a function parameter list. The operator is prepared for a set
     of different kinds (e.g., xrpc and tijah), stores the function name and a
     pointer to an arbitrary context (for XRPC this is a reference to the core
     apply node).

   o la_fun_param:
     An item of the function parameter list refering to an algebra expression
     (left child) and to the rest of the function parameter list (right child).
     Its schema stores the names of all input columns. The order of columns
     in the schema is important!

   o la_fun_frag_param:
     An item of the function parameter list refering to a fragment (left child)
     and to the rest of the function parameter list (right child). It has a
     further position argument that indicates to which column of the next
     la_fun_param operator in the right child the fragment information refers
     to. This operator is only used if a column contains node references.

   o la_frag_extract:
     If a function call returns nodes a frag_extract operator sits on top of
     the la_fun_call operator to fix the fragment information needed by our
     compilation scheme. Similar to the la_fun_frag_param operator it stores
     the schema position of the item column it refers to.



Index: prop_unq_names.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_unq_names.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- prop_unq_names.c    10 Dec 2007 15:10:03 -0000      1.25
+++ prop_unq_names.c    13 Dec 2007 13:08:17 -0000      1.26
@@ -543,8 +543,10 @@
             break;
 
         case la_fragment:
+        case la_frag_extract:
         case la_frag_union:
         case la_empty_frag:
+        case la_fun_frag_param:
             break;
 
         case la_error:
@@ -579,6 +581,16 @@
             /* properties are already assigned */
             break;
 
+        case la_fun_call:
+            /* create new unique names for all attributes */
+            for (unsigned int i = 0; i < n->schema.count; i++)
+                new_name_pair (np_list, n->schema.items[i].name, id++);
+            break;
+
+        case la_fun_param:
+            bulk_add_name_pairs (np_list, L(n));
+            break;
+
         case la_proxy:
         case la_proxy_base:
             bulk_add_name_pairs (np_list, L(n));

Index: prop_ocol.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_ocol.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- prop_ocol.c 10 Dec 2007 15:10:01 -0000      1.40
+++ prop_ocol.c 13 Dec 2007 13:08:17 -0000      1.41
@@ -881,8 +881,10 @@
 
         /* operators without schema */
         case la_fragment:
+        case la_frag_extract:
         case la_frag_union:
         case la_empty_frag:
+        case la_fun_frag_param:
             /* keep empty schema */
             break;
 
@@ -951,6 +953,37 @@
         case la_rec_base:
             break;
 
+        /* only a rewrite can change the ocol property
+           - thus update schema (property) during rewrite */
+        case la_fun_call:
+            break;
+
+        case la_fun_param:
+        {
+            unsigned int  i, j;
+
+            /* see if both operands have same number of attributes */
+            if (ocols_count (L(n)) != ocols_count (n))
+                PFoops (OOPS_FATAL,
+                        "Schema of the arguments of function application "
+                        "argument to not match");
+
+            /* see if we find each attribute in all of the input relations */
+            for (i = 0; i < ocols_count (L(n)); i++) {
+                for (j = 0; j < ocols_count (n); j++)
+                    if (ocol_at (L(n), i).name == ocol_at (n, j).name) {
+                        break;
+                    }
+
+                if (j == ocols_count (n))
+                    PFoops (OOPS_FATAL,
+                            "Schema of the arguments of function application "
+                            "argument to not match");
+            }
+
+            /* keep the schema of its inputs */
+        } break;
+
         case la_proxy:
         case la_proxy_base:
             ocols (n) = copy_ocols (ocols (L(n)), ocols_count (L(n)));

Index: prop_const.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_const.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- prop_const.c        10 Dec 2007 15:10:01 -0000      1.32
+++ prop_const.c        13 Dec 2007 13:08:17 -0000      1.33
@@ -682,6 +682,19 @@
             /* infer no properties of the seed */
             break;
 
+        case la_fun_call:
+            if (n->sem.fun_call.kind == alg_fun_call_xrpc &&
+                PFprop_const (L(n)->prop, n->sem.fun_call.iter))
+                PFprop_mark_const (
+                        n->prop,
+                        n->schema.items[0].name,
+                        PFprop_const_val (L(n)->prop, n->sem.fun_call.iter));
+            break;
+                
+        case la_fun_param:
+            copy (n->prop->constants, L(n)->prop->constants);
+            break;
+
         case la_proxy:
         case la_proxy_base:
             copy (n->prop->constants, L(n)->prop->constants);
@@ -729,9 +742,11 @@
         case la_merge_adjacent:
         case la_roots:
         case la_fragment:
+        case la_frag_extract:
         case la_frag_union:
         case la_empty_frag:
         case la_trace:
+        case la_fun_frag_param:
         case la_dummy:
             break;
 

Index: prop_reqval.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_reqval.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- prop_reqval.c       10 Dec 2007 15:10:02 -0000      1.30
+++ prop_reqval.c       13 Dec 2007 13:08:17 -0000      1.31
@@ -309,6 +309,7 @@
         case la_comment:
         case la_processi:
         case la_fragment:
+        case la_frag_extract:
             rv.name = 0;
             rv.val = 0;
             prop_infer_reqvals (L(n), rv);
@@ -415,9 +416,20 @@
             rv.val = 0;
             prop_infer_reqvals (L(n), rv);
             prop_infer_reqvals (R(n), rv);
+            break;
 
         case la_rec_base:
             break;
+            
+        case la_fun_call:
+        case la_fun_param:
+        case la_fun_frag_param:
+            /* infer no required values */
+            rv.name = 0;
+            rv.val = 0;
+            prop_infer_reqvals (L(n), rv);
+            prop_infer_reqvals (R(n), rv);
+            break;
 
         case la_cross_mvd:
             PFoops (OOPS_FATAL,

Index: prop_set.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_set.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- prop_set.c  10 Dec 2007 15:10:02 -0000      1.17
+++ prop_set.c  13 Dec 2007 13:08:17 -0000      1.18
@@ -196,10 +196,11 @@
             break;
 
         case la_frag_union:
-            r_set = n->prop->set;
+            r_set = false;
         case la_fragment:
+        case la_frag_extract:
         case la_empty_frag:
-            l_set = n->prop->set;
+            l_set = false;
             break;
 
         case la_cond_err:
@@ -236,6 +237,14 @@
         case la_rec_base:
             break;
 
+        /* ignore this property for the function application */
+        case la_fun_call:
+        case la_fun_param:
+        case la_fun_frag_param:
+            l_set = false;
+            r_set = false;
+            break;
+
         case la_dummy:
             l_set = n->prop->set;
             break;

Index: prop_icol.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_icol.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- prop_icol.c 10 Dec 2007 15:10:01 -0000      1.27
+++ prop_icol.c 13 Dec 2007 13:08:17 -0000      1.28
@@ -447,9 +447,7 @@
 
             n->prop->l_icols = diff (n->prop->l_icols, n->sem.sort.res);
 
-            for (unsigned int i = 0;
-                 i < PFord_count (n->sem.sort.sortby);
-                 i++)
+            for (unsigned int i = 0; i < PFord_count (n->sem.sort.sortby); i++)
                 n->prop->l_icols = union_ (n->prop->l_icols,
                                            PFord_order_col_at (
                                                n->sem.sort.sortby, i));
@@ -680,7 +678,9 @@
         case la_frag_union:
             n->prop->r_icols = 0;
         case la_fragment:
+        case la_frag_extract:
         case la_empty_frag:
+        case la_fun_frag_param:
             /* infer empty list for fragments */
             n->prop->l_icols = 0;
             break;
@@ -766,6 +766,16 @@
         case la_rec_base:
             break;
 
+        case la_fun_call:
+            n->prop->l_icols = n->sem.fun_call.iter;
+            break;
+            
+        case la_fun_param:
+            for (unsigned int i = 0; i < n->schema.count; i++)
+                n->prop->l_icols = union_ (n->prop->l_icols,
+                                           n->schema.items[i].name);
+            break;
+            
         case la_proxy:
         case la_proxy_base:
             /* infer incoming icols for input relation */

Index: prop_rec_delta.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_rec_delta.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- prop_rec_delta.c    10 Dec 2007 15:10:02 -0000      1.16
+++ prop_rec_delta.c    13 Dec 2007 13:08:17 -0000      1.17
@@ -85,8 +85,10 @@
         case la_empty_tbl:
         case la_ref_tbl:
         case la_fragment:
+        case la_frag_extract:
         case la_frag_union:
         case la_empty_frag:
+        case la_fun_frag_param:
             /* do not propagate or introduce any column information */
             break;
 
@@ -375,6 +377,12 @@
                 ITER(n) = POS(n) = att_NULL;
         }   break;
 
+        case la_fun_call:
+        case la_fun_param:
+            /* don't know what to do -- avoid the delta evaluation */
+            return true;
+            break;
+
         case la_string_join:
             /* we may not allow an aggregate on the input sequence */
             if (ITER(L(n)) & n->sem.string_join.iter)

Index: prop_level.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_level.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- prop_level.c        10 Dec 2007 15:10:01 -0000      1.9
+++ prop_level.c        13 Dec 2007 13:08:17 -0000      1.10
@@ -202,6 +202,7 @@
         case la_content:
         case la_merge_adjacent:
         case la_fragment:
+        case la_frag_extract:
         case la_frag_union:
         case la_empty_frag:
         case la_nil:
@@ -209,6 +210,9 @@
         case la_rec_param:
         case la_rec_arg:
         case la_rec_base:
+        case la_fun_call:
+        case la_fun_param:
+        case la_fun_frag_param:
         case la_string_join:
             n->prop->level_mapping = NULL;
             break;

Index: prop_dom_nat.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_dom_nat.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- prop_dom_nat.c      10 Dec 2007 15:10:01 -0000      1.12
+++ prop_dom_nat.c      13 Dec 2007 13:08:17 -0000      1.13
@@ -847,8 +847,10 @@
             break;
 
         case la_fragment:
+        case la_frag_extract:
         case la_frag_union:
         case la_empty_frag:
+        case la_fun_frag_param:
             break;
 
         case la_error:
@@ -883,6 +885,36 @@
                     add_dom (n->prop, n->schema.items[i].name, id++);
             break;
 
+        case la_fun_call:
+        {
+            unsigned int i = 0;
+            if (n->sem.fun_call.occ_ind == alg_occ_exactly_one &&
+                n->sem.fun_call.kind == alg_fun_call_xrpc &&
+                n->schema.items[0].type == aat_nat) {
+                add_dom (n->prop,
+                         n->schema.items[0].name,
+                         PFprop_dom (L(n)->prop, n->sem.fun_call.iter));
+                i++;
+            } else if (n->sem.fun_call.occ_ind == alg_occ_zero_or_one &&
+                       n->sem.fun_call.kind == alg_fun_call_xrpc &&
+                       n->schema.items[0].type == aat_nat) {
+                add_subdom (n->prop,
+                            PFprop_dom (L(n)->prop, n->sem.fun_call.iter),
+                            id);
+                add_dom (n->prop, n->schema.items[0].name, id++);
+                i++;
+            }
+                
+            /* create new domains for all (remaining) attributes */
+            for (; i < n->schema.count; i++)
+                if (n->schema.items[i].type == aat_nat)
+                    add_dom (n->prop, n->schema.items[i].name, id++);
+        }   break;
+                
+        case la_fun_param:
+            bulk_add_dom (n->prop, L(n));
+            break;
+
         case la_proxy:
         case la_proxy_base:
             bulk_add_dom (n->prop, L(n));

Index: prop_trace_names.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_trace_names.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- prop_trace_names.c  13 Dec 2007 09:20:32 -0000      1.12
+++ prop_trace_names.c  13 Dec 2007 13:08:17 -0000      1.13
@@ -390,6 +390,7 @@
             break;
 
         case la_fragment:
+        case la_frag_extract:
         case la_frag_union:
         case la_empty_frag:
             /* do not infer name pairs to the children */
@@ -422,6 +423,13 @@
                     "handle recursion operator.");
             break;
             
+        case la_fun_call:
+        case la_fun_param:
+        case la_fun_frag_param:
+            /* empty the name pair list */
+            PFarray_last (np_list) = 0;
+            break;
+
         case la_string_join:
             assert (n->sem.string_join.iter == n->sem.string_join.iter_res &&
                     n->sem.string_join.iter_sep == 
n->sem.string_join.iter_res);

Index: prop_key.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_key.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- prop_key.c  10 Dec 2007 15:10:01 -0000      1.34
+++ prop_key.c  13 Dec 2007 13:08:17 -0000      1.35
@@ -344,8 +344,10 @@
         case la_content:
         case la_merge_adjacent:
         case la_fragment:
+        case la_frag_extract:
         case la_frag_union:
         case la_empty_frag:
+        case la_fun_frag_param:
             /* no keys */
             break;
 
@@ -697,6 +699,17 @@
             /* infer no properties of the seed */
             break;
 
+        case la_fun_call:
+            if (n->sem.fun_call.occ_ind == alg_occ_exactly_one &&
+                n->sem.fun_call.kind == alg_fun_call_xrpc &&
+                key_worker (L(n)->prop->keys, n->sem.fun_call.iter))
+                union_ (n->prop->keys, n->schema.items[0].name);
+            break;
+                
+        case la_fun_param:
+            copy (n->prop->keys, L(n)->prop->keys);
+            break;
+
         case la_proxy:
         case la_proxy_base:
             copy (n->prop->keys, L(n)->prop->keys);

Index: prop_guide.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_guide.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- prop_guide.c        10 Dec 2007 15:10:01 -0000      1.17
+++ prop_guide.c        13 Dec 2007 13:08:17 -0000      1.18
@@ -1043,12 +1043,16 @@
         case la_content:
         case la_merge_adjacent:
         case la_fragment:
+        case la_frag_extract:
         case la_frag_union:
         case la_empty_frag:
         case la_rec_fix:
         case la_rec_param:
         case la_rec_arg:
         case la_rec_base:
+        case la_fun_call:
+        case la_fun_param:
+        case la_fun_frag_param:
         case la_cross_mvd:
         case la_eqjoin_unq:
         case la_string_join:

Index: prop_ori_names.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_ori_names.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- prop_ori_names.c    10 Dec 2007 15:10:02 -0000      1.24
+++ prop_ori_names.c    13 Dec 2007 13:08:17 -0000      1.25
@@ -623,8 +623,10 @@
         } break;
 
         case la_fragment:
+        case la_frag_extract:
         case la_frag_union:
         case la_empty_frag:
+        case la_fun_frag_param:
             /* do not infer name pairs to the children */
             break;
 
@@ -667,6 +669,13 @@
         case la_rec_base:
             break;
 
+        case la_fun_call:
+            break;
+
+        case la_fun_param:
+            n->prop->l_name_pairs = PFarray_copy (np_list);
+            break;
+
         case la_proxy:
         case la_proxy_base:
             n->prop->l_name_pairs = PFarray_copy (np_list);

Index: prop_card.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_card.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- prop_card.c 10 Dec 2007 15:10:01 -0000      1.29
+++ prop_card.c 13 Dec 2007 13:08:17 -0000      1.30
@@ -96,6 +96,7 @@
         case la_comment:
         case la_processi:
         case la_roots:
+        case la_fun_param:
         case la_proxy:
         case la_proxy_base:
         case la_dummy:
@@ -135,8 +136,10 @@
         case la_fcns:
         case la_merge_adjacent:
         case la_fragment:
+        case la_frag_extract:
         case la_frag_union:
         case la_empty_frag:
+        case la_fun_frag_param:
         case la_string_join:
             /* can't say something specific about cardinality */
             n->prop->card = 0;
@@ -218,6 +221,12 @@
             /* infer no properties of the seed */
             n->prop->card = 0;
             break;
+
+        case la_fun_call:
+            if (n->sem.fun_call.occ_ind == alg_occ_exactly_one)
+                n->prop->card = L(n)->prop->card;
+            else
+                n->prop->card = 0;
     }
 }
 

Index: prop_composite_key.c
===================================================================
RCS file: 
/cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_composite_key.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- prop_composite_key.c        10 Dec 2007 15:10:01 -0000      1.9
+++ prop_composite_key.c        13 Dec 2007 13:08:17 -0000      1.10
@@ -243,8 +243,10 @@
         case la_content:
         case la_merge_adjacent:
         case la_fragment:
+        case la_frag_extract:
         case la_frag_union:
         case la_empty_frag:
+        case la_fun_frag_param:
             /* no composite keys */
             break;
 
@@ -728,6 +730,17 @@
             /* infer no properties of the seed */
             break;
 
+        case la_fun_call:
+            if (n->sem.fun_call.occ_ind == alg_occ_exactly_one &&
+                n->sem.fun_call.kind == alg_fun_call_xrpc &&
+                key_worker (L(n)->prop->ckeys, n->sem.fun_call.iter))
+                union_ (n->prop->ckeys, n->schema.items[0].name);
+            break;
+                
+        case la_fun_param:
+            copy (n->prop->ckeys, L(n)->prop->ckeys);
+            break;
+
         case la_proxy:
         case la_proxy_base:
             copy (n->prop->ckeys, L(n)->prop->ckeys);

Index: prop_dom.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_dom.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- prop_dom.c  10 Dec 2007 15:10:01 -0000      1.44
+++ prop_dom.c  13 Dec 2007 13:08:17 -0000      1.45
@@ -1128,8 +1128,10 @@
             break;
 
         case la_fragment:
+        case la_frag_extract:
         case la_frag_union:
         case la_empty_frag:
+        case la_fun_frag_param:
             break;
 
         case la_error:
@@ -1163,6 +1165,33 @@
                 add_dom (n->prop, n->schema.items[i].name, id++);
             break;
 
+        case la_fun_call:
+        {
+            unsigned int i = 0;
+            if (n->sem.fun_call.occ_ind == alg_occ_exactly_one &&
+                n->sem.fun_call.kind == alg_fun_call_xrpc) {
+                add_dom (n->prop,
+                         n->schema.items[0].name,
+                         PFprop_dom (L(n)->prop, n->sem.fun_call.iter));
+                i++;
+            } else if (n->sem.fun_call.occ_ind == alg_occ_zero_or_one &&
+                       n->sem.fun_call.kind == alg_fun_call_xrpc) {
+                add_subdom (n->prop,
+                            PFprop_dom (L(n)->prop, n->sem.fun_call.iter),
+                            id);
+                add_dom (n->prop, n->schema.items[0].name, id++);
+                i++;
+            }
+                
+            /* create new domains for all (remaining) attributes */
+            for (; i < n->schema.count; i++)
+                add_dom (n->prop, n->schema.items[i].name, id++);
+        }   break;
+                
+        case la_fun_param:
+            bulk_add_dom (n->prop, L(n));
+            break;
+
         case la_proxy:
         case la_proxy_base:
             bulk_add_dom (n->prop, L(n));


-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to