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

Modified Files:
        algebra.c algebra_cse.c builtins.c logical.c physical.c 
        planner.c 
Log Message:
- Implement pf:product(), pf:log() and pf:sqrt() for the algebra version.
  There is one remaining problem pf:product(()) returns 0 instead of 1.



U algebra.c
Index: algebra.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/algebra.c,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -d -r1.103 -r1.104
--- algebra.c   9 Mar 2009 14:48:12 -0000       1.103
+++ algebra.c   10 Mar 2009 12:20:37 -0000      1.104
@@ -1151,6 +1151,8 @@
         case alg_fun_fn_ceiling:          return "fn:ceiling";
         case alg_fun_fn_floor:            return "fn:floor";
         case alg_fun_fn_round:            return "fn:round";
+        case alg_fun_pf_sqrt:             return "pf:sqrt";
+        case alg_fun_pf_log:              return "pf:log";
         case alg_fun_fn_concat:           return "fn:concat";
         case alg_fun_fn_substring:        return "fn:substring";
         case alg_fun_fn_substring_dbl:    return "fn:substring3";

U physical.c
Index: physical.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/physical.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -d -r1.87 -r1.88
--- physical.c  9 Feb 2009 08:29:57 -0000       1.87
+++ physical.c  10 Mar 2009 12:20:39 -0000      1.88
@@ -1586,6 +1586,8 @@
         case alg_fun_fn_abs:
         case alg_fun_fn_ceiling:
         case alg_fun_fn_floor:
+        case alg_fun_pf_log:
+        case alg_fun_pf_sqrt:
         case alg_fun_fn_round:
             assert (clsize (refs) == 1);
 

U planner.c
Index: planner.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/planner.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- planner.c   6 Feb 2009 13:00:57 -0000       1.80
+++ planner.c   10 Mar 2009 12:20:39 -0000      1.81
@@ -1425,7 +1425,7 @@
 
     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_prod
             || n->kind == la_seqty1 || n->kind == la_all);
     assert (L(n)); assert (L(n)->plans);
 
@@ -3458,6 +3458,7 @@
         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_prod:           plans = plan_aggr (pa_prod, n);   break;
 
         case la_rownum:         plans = plan_rownum (n);          break;
         case la_rowrank:

U algebra_cse.c
Index: algebra_cse.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/algebra_cse.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- algebra_cse.c       8 Jan 2009 16:54:09 -0000       1.80
+++ algebra_cse.c       10 Mar 2009 12:20:38 -0000      1.81
@@ -325,6 +325,7 @@
         case la_max:
         case la_min:
         case la_sum:
+        case la_prod:
         case la_count:
         case la_seqty1:
         case la_all:

U logical.c
Index: logical.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/logical.c,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -d -r1.122 -r1.123
--- logical.c   9 Feb 2009 08:29:52 -0000       1.122
+++ logical.c   10 Mar 2009 12:20:39 -0000      1.123
@@ -1406,6 +1406,8 @@
         case alg_fun_fn_abs:
         case alg_fun_fn_ceiling:
         case alg_fun_fn_floor:
+        case alg_fun_pf_log:
+        case alg_fun_pf_sqrt:
         case alg_fun_fn_round:
             assert (clsize (refs) == 1);
             /* make sure the column is of numeric type */
@@ -4363,6 +4365,7 @@
         case la_max:
         case la_min:
         case la_sum:
+        case la_prod:
             return PFla_aggr (n->kind, left,
                               n->sem.aggr.res,
                               n->sem.aggr.col,

U builtins.c
Index: builtins.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/builtins.c,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -d -r1.117 -r1.118
--- builtins.c  17 Feb 2009 00:53:52 -0000      1.117
+++ builtins.c  10 Mar 2009 12:20:38 -0000      1.118
@@ -1775,6 +1775,66 @@
                            loop, ordering, side_effects, args);
 }
 
+struct PFla_pair_t
+PFbui_pf_sqrt_int (const PFla_op_t *loop,
+                      bool ordering,
+                      PFla_op_t **side_effects,
+                      struct PFla_pair_t *args)
+{
+    return numeric_fun_op (aat_int, alg_fun_pf_sqrt,
+                           loop, ordering, side_effects, args);
+}
+
+struct PFla_pair_t
+PFbui_pf_sqrt_dec (const PFla_op_t *loop,
+                      bool ordering,
+                      PFla_op_t **side_effects,
+                      struct PFla_pair_t *args)
+{
+    return numeric_fun_op (aat_dec, alg_fun_pf_sqrt,
+                           loop, ordering, side_effects, args);
+}
+
+struct PFla_pair_t
+PFbui_pf_sqrt_dbl (const PFla_op_t *loop,
+                      bool ordering,
+                      PFla_op_t **side_effects,
+                      struct PFla_pair_t *args)
+{
+    return numeric_fun_op (aat_dbl, alg_fun_pf_sqrt,
+                           loop, ordering, side_effects, args);
+}
+
+struct PFla_pair_t
+PFbui_pf_log_int (const PFla_op_t *loop,
+                      bool ordering,
+                      PFla_op_t **side_effects,
+                      struct PFla_pair_t *args)
+{
+    return numeric_fun_op (aat_int, alg_fun_pf_log,
+                           loop, ordering, side_effects, args);
+}
+
+struct PFla_pair_t
+PFbui_pf_log_dec (const PFla_op_t *loop,
+                      bool ordering,
+                      PFla_op_t **side_effects,
+                      struct PFla_pair_t *args)
+{
+    return numeric_fun_op (aat_dec, alg_fun_pf_log,
+                           loop, ordering, side_effects, args);
+}
+
+struct PFla_pair_t
+PFbui_pf_log_dbl (const PFla_op_t *loop,
+                      bool ordering,
+                      PFla_op_t **side_effects,
+                      struct PFla_pair_t *args)
+{
+    return numeric_fun_op (aat_dbl, alg_fun_pf_log,
+                           loop, ordering, side_effects, args);
+}
+
 /* ----------------------- */
 /* 7. FUNCTIONS ON STRINGS */
 /* ----------------------- */
@@ -5178,6 +5238,34 @@
         .frag = PFla_empty_set () };
 }
 
+static struct PFla_pair_t
+fn_prod (PFalg_simple_type_t t,
+        const PFla_op_t *loop,
+        bool ordering,
+        PFla_op_t **side_effects,
+        struct PFla_pair_t *args)
+{
+    (void) ordering; (void) side_effects;
+
+    PFla_op_t *prod = aggr (la_prod,
+                           project (cast(args[0].rel, col_cast, col_item, t),
+                                   proj (col_iter, col_iter),
+                                   proj (col_item, col_cast)),
+                           col_item, col_item, col_iter);
+
+    return (struct PFla_pair_t) {
+        .rel = attach (
+                disjunion (
+                    prod,
+                    attach (
+                        difference (
+                            loop,
+                            project (prod, proj (col_iter, col_iter))),
+                        col_item, lit_int (0))),
+                col_pos, lit_nat (1)),
+        .frag = PFla_empty_set () };
+}
+
 /**
  * Build up operator tree for built-in function 'fn:sum (integer*)'.
  */
@@ -5215,6 +5303,18 @@
 }
 
 /**
+ * Build up operator tree for built-in function 'pf:prod (double*)'.
+ */
+struct PFla_pair_t
+PFbui_fn_prod_dbl (const PFla_op_t *loop,
+                  bool ordering,
+                  PFla_op_t **side_effects,
+                  struct PFla_pair_t *args)
+{
+    return fn_prod(aat_dbl, loop, ordering, side_effects, args);
+}
+
+/**
  * Build up operator tree for built-in function 'fn:sum ($arg, $zero)'.
  *
  *  env,loop: e1 => (q1,delta1)             env,loop: e2 => (q2,delta2)


------------------------------------------------------------------------------
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to