Update of /cvsroot/monetdb/pathfinder/compiler/algebra/opt
In directory
sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23023/compiler/algebra/opt
Modified Files:
Tag: PF_ROX
opt_algebra_cse.c opt_complex.c opt_general.brg opt_icol.c
opt_join_graph.c opt_join_pd.c opt_mvd.c opt_thetajoin.c
Log Message:
propagated changes of Wednesday Jan 30 2008 - Saturday Feb 09 2008
from the development trunk to the PF_ROX branch
Index: opt_algebra_cse.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_algebra_cse.c,v
retrieving revision 1.11
retrieving revision 1.11.4.1
diff -u -d -r1.11 -r1.11.4.1
--- opt_algebra_cse.c 11 Jan 2008 10:46:57 -0000 1.11
+++ opt_algebra_cse.c 9 Feb 2008 08:40:18 -0000 1.11.4.1
@@ -27,7 +27,7 @@
* 2000-2005 University of Konstanz and (C) 2005-2008 Technische
* Universitaet Muenchen, respectively. All Rights Reserved.
*
- * $Id
+ * $Id$
*/
/* always include pathfinder.h first! */
@@ -40,6 +40,7 @@
#include "algebra.h"
#include "logical.h"
[...4162 lines suppressed...]
{
+ /* initialize maps */
cse_map = PFarray (sizeof (ori_cse_map_t));
- eff_map = PFarray (sizeof (ori_eff_map_t));
+ actatt_map = PFarray (sizeof (ori_actatt_map_t));
ori_map = PFarray (sizeof (cse_ori_map_t));
-
+
+ /* initialize subexpression array */
subexps = PFarray (sizeof (PFarray_t *));
PFla_op_t *res = NULL;
/* first remove the dummies */
res = remove_dummies (n);
+
+ /* eliminate subexpressions */
PFla_dag_reset (res);
res = la_cse (res);
PFla_dag_reset (res);
Index: opt_join_pd.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_join_pd.c,v
retrieving revision 1.37
retrieving revision 1.37.4.1
diff -u -d -r1.37 -r1.37.4.1
--- opt_join_pd.c 11 Jan 2008 10:46:58 -0000 1.37
+++ opt_join_pd.c 9 Feb 2008 08:40:23 -0000 1.37.4.1
@@ -313,7 +313,6 @@
case la_all:
case la_step:
case la_guide_step:
- case la_doc_tbl:
case la_twig:
case la_fcns:
case la_docnode:
@@ -419,6 +418,10 @@
if ((modified = GEN(lp->sem.doc_join.item_res))) LP = R(lp);
break;
+ case la_doc_tbl:
+ if ((modified = GEN(lp->sem.doc_tbl.res))) LP = L(lp);
+ break;
+
case la_doc_access:
if ((modified = GEN(lp->sem.doc_access.res))) LP = R(lp);
break;
@@ -444,7 +447,6 @@
case la_intersect:
case la_difference:
case la_distinct:
- case la_to:
case la_avg:
case la_max:
case la_min:
@@ -454,7 +456,6 @@
case la_all:
case la_step:
case la_guide_step:
- case la_doc_tbl:
case la_twig:
case la_fcns:
case la_docnode:
@@ -1384,6 +1385,9 @@
case la_bool_not:
next_join = modify_unary_op (p, lp, rp, PFla_not);
break;
+ case la_to:
+ next_join = modify_binary_op (p, lp, rp, PFla_to);
+ break;
case la_rownum:
if (!PFprop_key (rp->prop, ratt) ||
@@ -1680,6 +1684,18 @@
}
break;
+ case la_doc_tbl:
+ if (!is_join_att (p, lp->sem.doc_tbl.res)) {
+ *p = *(doc_tbl (eqjoin_unq (L(lp), rp, latt, ratt,
+ p->sem.eqjoin_unq.res),
+ lp->sem.doc_tbl.res,
+ is_join_att(p, lp->sem.doc_tbl.att)
+ ? p->sem.eqjoin_unq.res
+ : lp->sem.doc_tbl.att));
+ next_join = L(p);
+ }
+ break;
+
case la_doc_access:
if (!is_join_att (p, lp->sem.doc_access.res)) {
*p = *(doc_access (L(lp),
@@ -1694,7 +1710,29 @@
}
break;
- case la_error: /* don't rewrite errors */
+ case la_error:
+ if (!PFprop_key (rp->prop, ratt) ||
+ !PFprop_subdom (rp->prop,
+ PFprop_dom (lp->prop, latt),
+ PFprop_dom (rp->prop, ratt)))
+ /* Ensure that the values of the left join argument
+ are a subset of the values of the right join argument
+ and that the right join argument is keyed. These
+ two tests make sure that we have exactly one match per
+ tuple in the left relation and thus the result of the
+ error operator stays stable. */
+ break;
+
+ if (!is_join_att (p, lp->sem.err.att)) {
+ *p = *(PFla_error_ (eqjoin_unq (L(lp), rp, latt, ratt,
+ p->sem.eqjoin_unq.res),
+ lp->sem.err.att,
+ PFprop_type_of (lp, lp->sem.err.att)));
+ next_join = L(p);
+ break;
+ }
+ break;
+
case la_cond_err:
/* this breaks proxy generation - thus don't
rewrite conditional errors */
@@ -1838,7 +1876,6 @@
case la_all:
case la_step:
case la_guide_step:
- case la_doc_tbl:
case la_twig:
case la_fcns:
case la_docnode:
@@ -1925,6 +1962,9 @@
case la_doc_index_join:
if (att == p->sem.doc_join.item_res) return att_NULL;
break;
+ case la_doc_tbl:
+ if (att == p->sem.doc_tbl.res) return att_NULL;
+ break;
case la_doc_access:
if (att == p->sem.doc_access.res) return att_NULL;
break;
Index: opt_icol.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_icol.c,v
retrieving revision 1.20
retrieving revision 1.20.4.1
diff -u -d -r1.20 -r1.20.4.1
--- opt_icol.c 11 Jan 2008 10:46:58 -0000 1.20
+++ opt_icol.c 9 Feb 2008 08:40:23 -0000 1.20.4.1
@@ -386,6 +386,7 @@
if (L(p)->kind == la_twig &&
!PFprop_icol (p->prop, L(p)->sem.iter_item.item))
switch (LL(p)->kind) {
+
case la_docnode:
*p = *PFla_project (
LLL(p),
@@ -425,6 +426,11 @@
assert (0);
break;
}
+ else if (L(p)->kind == la_doc_tbl &&
+ !PFprop_icol (L(p)->prop, L(p)->sem.doc_tbl.res)) {
+ *p = *PFla_dummy (LL(p));
+ break;
+ }
break;
case la_frag_union:
@@ -436,6 +442,14 @@
RL(p)->kind == la_twig &&
!PFprop_icol (RL(p)->prop, RL(p)->sem.iter_item.item))
*p = *PFla_dummy (L(p));
+ else if (L(p)->kind == la_fragment &&
+ LL(p)->kind == la_doc_tbl &&
+ !PFprop_icol (LL(p)->prop, LL(p)->sem.doc_tbl.res))
+ *p = *PFla_dummy (R(p));
+ else if (R(p)->kind == la_fragment &&
+ RL(p)->kind == la_doc_tbl &&
+ !PFprop_icol (RL(p)->prop, RL(p)->sem.doc_tbl.res))
+ *p = *PFla_dummy (L(p));
break;
case la_rec_arg:
Index: opt_general.brg
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_general.brg,v
retrieving revision 1.45
retrieving revision 1.45.4.1
diff -u -d -r1.45 -r1.45.4.1
--- opt_general.brg 11 Jan 2008 10:46:57 -0000 1.45
+++ opt_general.brg 9 Feb 2008 08:40:22 -0000 1.45.4.1
@@ -325,8 +325,9 @@
EmptyRel: roots_ (twig (nil)) = 188 (0);
EmptyRel: roots_ (merge_adjacent (Frag,
EmptyRel)) = 189 (0);
-EmptyRel: cond_err (EmptyRel, Rel) = 190 (0);
-EmptyRel: fun_call (EmptyRel, Param) = 191 (0);
+EmptyRel: error (EmptyRel) = 190 (0);
+EmptyRel: cond_err (EmptyRel, Rel) = 191 (0);
+EmptyRel: fun_call (EmptyRel, Param) = 192 (0);
EmptyRel: string_join (EmptyRel, Rel) = 201 (0);
EmptyRel: dummy (EmptyRel) = 202 (0);
Index: opt_complex.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_complex.c,v
retrieving revision 1.39
retrieving revision 1.39.2.1
diff -u -d -r1.39 -r1.39.2.1
--- opt_complex.c 22 Jan 2008 15:28:48 -0000 1.39
+++ opt_complex.c 9 Feb 2008 08:40:18 -0000 1.39.2.1
@@ -539,25 +539,6 @@
L(p)->sem.proj.items[0]);
break;
}
- /* prune unnecessary attach-project operators */
- if (L(p)->kind == la_project &&
- L(p)->schema.count == 1 &&
- LL(p)->kind == la_roots &&
- LLL(p)->kind == la_doc_tbl &&
- p->sem.attach.res == LLL(p)->sem.doc_tbl.iter &&
- PFprop_const (LLL(p)->prop, LLL(p)->sem.doc_tbl.iter) &&
- PFalg_atom_comparable (
- p->sem.attach.value,
- PFprop_const_val (LLL(p)->prop,
- LLL(p)->sem.doc_tbl.iter)) &&
- !PFalg_atom_cmp (
- p->sem.attach.value,
- PFprop_const_val (LLL(p)->prop,
- LLL(p)->sem.doc_tbl.iter)) &&
- L(p)->sem.proj.items[0].new == LLL(p)->sem.doc_tbl.item_res) {
- *p = *PFla_dummy (LL(p));
- break;
- }
break;
@@ -1203,6 +1184,22 @@
}
break;
+ case la_cast:
+ if (!PFprop_req_value_col (p->prop, p->sem.type.res) &&
+ !PFprop_req_bijective_col (p->prop, p->sem.type.res) &&
+ p->sem.type.ty == aat_int &&
+ PFprop_type_of (p, p->sem.type.att) == aat_nat) {
+ PFalg_proj_t *proj = PFmalloc (p->schema.count *
+ sizeof (PFalg_proj_t));
+ for (unsigned int i = 0; i < L(p)->schema.count; i++)
+ proj[i] = PFalg_proj (L(p)->schema.items[i].name,
+ L(p)->schema.items[i].name);
+ proj[L(p)->schema.count] = PFalg_proj (p->sem.type.res,
+ p->sem.type.att);
+ *p = *PFla_project_ (L(p), p->schema.count, proj);
+ }
+ break;
+
case la_step:
if (p->sem.step.level < 0)
p->sem.step.level = PFprop_level (p->prop,
Index: opt_thetajoin.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_thetajoin.c,v
retrieving revision 1.16
retrieving revision 1.16.2.1
diff -u -d -r1.16 -r1.16.2.1
--- opt_thetajoin.c 16 Jan 2008 12:24:54 -0000 1.16
+++ opt_thetajoin.c 9 Feb 2008 08:40:26 -0000 1.16.2.1
@@ -1373,6 +1373,37 @@
break;
case la_to:
+ if (is_tj (L(p))) {
+ bool switch_left = PFprop_ocol (LL(p), p->sem.binary.att1) &&
+ PFprop_ocol (LL(p), p->sem.binary.att2);
+ bool switch_right = PFprop_ocol (LR(p), p->sem.binary.att1) &&
+ PFprop_ocol (LR(p), p->sem.binary.att2);
+
+ if (switch_left) {
+ resolve_name_conflict (L(p), p->sem.binary.res);
+ *p = *(thetajoin_opt (
+ to (LL(p),
+ p->sem.binary.res,
+ p->sem.binary.att1,
+ p->sem.binary.att2),
+ LR(p),
+ L(p)->sem.thetajoin_opt.pred));
+ modified = true;
+ }
+ else if (switch_right) {
+ resolve_name_conflict (L(p), p->sem.binary.res);
+ *p = *(thetajoin_opt (
+ LL(p),
+ to (LR(p),
+ p->sem.binary.res,
+ p->sem.binary.att1,
+ p->sem.binary.att2),
+ L(p)->sem.thetajoin_opt.pred));
+ modified = true;
+ }
+ }
+ break;
+
case la_avg:
case la_max:
case la_min:
@@ -1830,6 +1861,8 @@
break;
case la_doc_tbl:
+ /* should not appear as roots already
+ translates the doc_tbl operator. */
break;
case la_doc_access:
@@ -1873,6 +1906,39 @@
}
break;
+ case la_roots:
+ /* modify the only pattern starting in roots
+ that is no constructor: roots-doc_tbl */
+ if (L(p)->kind == la_doc_tbl &&
+ is_tj (LL(p))) {
+ if (PFprop_ocol (L(LL(p)), p->sem.doc_tbl.att)) {
+ resolve_name_conflict (LL(p), p->sem.doc_tbl.res);
+ PFarray_t *pred = LL(p)->sem.thetajoin_opt.pred;
+ PFla_op_t *other_side = R(LL(p));
+ /* overwrite doc_tbl node to update
+ both roots and frag operators */
+ *(L(p)) = *(doc_tbl (L(LL(p)),
+ L(p)->sem.doc_tbl.res,
+ L(p)->sem.doc_tbl.att));
+ /* push roots + doc_tbl through the thetajoin */
+ *p = *(thetajoin_opt (roots (L(p)), other_side, pred));
+ }
+ else {
+ resolve_name_conflict (LL(p), p->sem.doc_tbl.res);
+ PFarray_t *pred = LL(p)->sem.thetajoin_opt.pred;
+ PFla_op_t *other_side = L(LL(p));
+ /* overwrite doc_tbl node to update
+ both roots and frag operators */
+ *(L(p)) = *(doc_tbl (R(LL(p)),
+ L(p)->sem.doc_tbl.res,
+ L(p)->sem.doc_tbl.att));
+ /* push roots + doc_tbl through the thetajoin */
+ *p = *(thetajoin_opt (other_side, roots (L(p)), pred));
+ }
+ modified = true;
+ }
+ break;
+
case la_twig:
case la_fcns:
case la_docnode:
@@ -1883,7 +1949,6 @@
case la_processi:
case la_content:
case la_merge_adjacent:
- case la_roots:
/* constructors introduce like the unpartitioned
rowid or rownum operators a dependency. */
break;
@@ -1896,6 +1961,7 @@
case la_error: /* don't rewrite errors */
break;
+
case la_cond_err:
/* We push the error operator into the left input
as we do not know whether it relates to the left or
Index: opt_mvd.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_mvd.c,v
retrieving revision 1.32
retrieving revision 1.32.4.1
diff -u -d -r1.32 -r1.32.4.1
--- opt_mvd.c 11 Jan 2008 10:46:58 -0000 1.32
+++ opt_mvd.c 9 Feb 2008 08:40:25 -0000 1.32.4.1
@@ -853,33 +853,25 @@
case la_to:
if (is_cross (L(p))) {
- if (att_present (LL(p), p->sem.to.att1) &&
- att_present (LL(p), p->sem.to.att2)) {
- *p = *(cross_can (
- LR(p),
- project (to (attach (LL(p),
- p->sem.to.part,
- lit_nat(1)),
- p->sem.to.res,
- p->sem.to.att1,
- p->sem.to.att2,
- p->sem.to.part),
- proj (p->sem.to.res,
- p->sem.to.res))));
+ bool switch_left = att_present (LL(p), p->sem.binary.att1) &&
+ att_present (LL(p), p->sem.binary.att2);
+ bool switch_right = att_present (LR(p), p->sem.binary.att1) &&
+ att_present (LR(p), p->sem.binary.att2);
+
+ if (switch_left) {
+ *p = *(cross_can (to (LL(p),
+ p->sem.binary.res,
+ p->sem.binary.att1,
+ p->sem.binary.att2),
+ LR(p)));
modified = true;
- } else if (att_present (LR(p), p->sem.to.att1) &&
- att_present (LR(p), p->sem.to.att2)) {
- *p = *(cross_can (
- LL(p),
- project (to (attach (LR(p),
- p->sem.to.part,
- lit_nat(1)),
- p->sem.to.res,
- p->sem.to.att1,
- p->sem.to.att2,
- p->sem.to.part),
- proj (p->sem.to.res,
- p->sem.to.res))));
+ }
+ else if (switch_right) {
+ *p = *(cross_can (LL(p),
+ to (LR(p),
+ p->sem.binary.res,
+ p->sem.binary.att1,
+ p->sem.binary.att2)));
modified = true;
}
}
@@ -1516,68 +1508,43 @@
that is no constructor: roots-doc_tbl */
if (L(p)->kind == la_doc_tbl) {
if (is_cross (LL(p))) {
- if (att_present (LL(L(p)), L(p)->sem.doc_tbl.item)) {
- /* save iter relation */
- PFla_op_t *iter_rel = LR(L(p));
+ if (att_present (L(LL(p)), L(p)->sem.doc_tbl.att)) {
+ PFla_op_t *other_side = R(LL(p));
/* overwrite doc_tbl node to update
both roots and frag operators */
- *(L(p)) = *(doc_tbl (attach (LL(L(p)),
- L(p)->sem.doc_tbl.iter,
- lit_nat (1)),
- L(p)->sem.doc_tbl.iter,
- L(p)->sem.doc_tbl.item,
- L(p)->sem.doc_tbl.item_res));
+ *(L(p)) = *(doc_tbl (L(LL(p)),
+ L(p)->sem.doc_tbl.res,
+ L(p)->sem.doc_tbl.att));
/* push roots + doc_tbl through the cross product */
- *p = *(cross_can (
- iter_rel,
- project (roots (L(p)),
- proj (L(p)->sem.doc_tbl.item_res,
- L(p)->sem.doc_tbl.item_res))));
+ *p = *(cross_can (other_side, roots (L(p))));
}
else {
- /* save iter relation */
- PFla_op_t *iter_rel = LL(L(p));
+ PFla_op_t *other_side = L(LL(p));
/* overwrite doc_tbl node to update
both roots and frag operators */
- *(L(p)) = *(doc_tbl (attach (LR(L(p)),
- L(p)->sem.doc_tbl.iter,
- lit_nat (1)),
- L(p)->sem.doc_tbl.iter,
- L(p)->sem.doc_tbl.item,
- L(p)->sem.doc_tbl.item_res));
+ *(L(p)) = *(doc_tbl (R(LL(p)),
+ L(p)->sem.doc_tbl.res,
+ L(p)->sem.doc_tbl.att));
/* push roots + doc_tbl through the cross product */
- *p = *(cross_can (
- iter_rel,
- project (roots (L(p)),
- proj (L(p)->sem.doc_tbl.item_res,
- L(p)->sem.doc_tbl.item_res))));
+ *p = *(cross_can (other_side, roots (L(p))));
}
modified = true;
}
else if (LL(p)->kind == la_attach &&
- LL(p)->sem.attach.res == L(p)->sem.doc_tbl.item) {
- /* save iter relation */
- PFla_op_t *iter_rel = LL(L(p));
+ LL(p)->sem.attach.res == L(p)->sem.doc_tbl.att) {
+ /* save input relation */
+ PFla_op_t *input = L(LL(p));
/* create base table and overwrite doc_tbl
node to update both roots and frag operators */
*(L(p)) = *(doc_tbl (lit_tbl (
- attlist (L(p)->sem.doc_tbl.iter,
- L(p)->sem.doc_tbl.item),
- tuple (lit_nat (1),
- LL(p)->sem.attach.value)),
- L(p)->sem.doc_tbl.iter,
- L(p)->sem.doc_tbl.item,
- L(p)->sem.doc_tbl.item_res));
+ attlist (L(p)->sem.doc_tbl.att),
+ tuple (LL(p)->sem.attach.value)),
+ L(p)->sem.doc_tbl.res,
+ L(p)->sem.doc_tbl.att));
- /* Apply the cross product with the possibly
- huge iter relation. */
- *p = *(cross_can (
- iter_rel,
- project (
- roots (L(p)),
- proj (L(p)->sem.doc_tbl.item_res,
- L(p)->sem.doc_tbl.item_res))));
+ /* push roots + doc_tbl through the cross product */
+ *p = *(cross_can (input, roots (L(p))));
modified = true;
}
}
@@ -1589,8 +1556,9 @@
case la_empty_frag:
break;
- case la_error: /* don't rewrite errors */
+ case la_error: /* don't rewrite runtime errors */
break;
+
case la_cond_err:
if (is_cross (L(p))) {
*p = *(cross_can (cond_err (LL(p), R(p),
Index: opt_join_graph.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_join_graph.c,v
retrieving revision 1.9
retrieving revision 1.9.4.1
diff -u -d -r1.9 -r1.9.4.1
--- opt_join_graph.c 11 Jan 2008 10:46:58 -0000 1.9
+++ opt_join_graph.c 9 Feb 2008 08:40:23 -0000 1.9.4.1
@@ -481,7 +481,6 @@
/* Infer key, icols, set, and composite key
properties first */
PFprop_infer_composite_key (root);
- /* PFprop_infer_key (root); */
PFprop_infer_icol (root);
PFprop_infer_set (root);
PFprop_infer_guide (root, guide_tree);
-------------------------------------------------------------------------
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