Update of /cvsroot/monetdb/pathfinder/compiler/algebra/opt
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv1296/compiler/algebra/opt
Modified Files:
Tag: xquery-decomposition
opt_complex.c opt_reqval.c opt_thetajoin.c
Log Message:
propagated changes up to Thursday Jan 17 2008
from the development trunk to the xquery-decomposition branch
Index: opt_reqval.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_reqval.c,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -u -d -r1.12 -r1.12.2.1
--- opt_reqval.c 11 Jan 2008 12:49:09 -0000 1.12
+++ opt_reqval.c 17 Jan 2008 08:36:37 -0000 1.12.2.1
@@ -130,10 +130,13 @@
}
}
- /* replace rowrank operators whose real values
- are not needed by rank operators */
+ /* Replace rowrank operators whose real values
+ are not needed by rank operators.
+ Note that we do not need to check for the order
+ constraint (PFprop_req_order_col()) as this rewrite
+ does not harm it. */
if (p->kind == la_rowrank &&
- PFprop_req_distr_col (p->prop, p->sem.sort.res))
+ !PFprop_req_value_col (p->prop, p->sem.sort.res))
*p = *PFla_rank (L(p), p->sem.sort.res, p->sem.sort.sortby);
/* infer properties for children */
Index: opt_thetajoin.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_thetajoin.c,v
retrieving revision 1.14
retrieving revision 1.14.2.1
diff -u -d -r1.14 -r1.14.2.1
--- opt_thetajoin.c 11 Jan 2008 10:46:58 -0000 1.14
+++ opt_thetajoin.c 17 Jan 2008 08:36:37 -0000 1.14.2.1
@@ -584,7 +584,11 @@
else if (integrate &&
PFprop_ocol (LL(p), p->sem.binary.att2) &&
PFprop_ocol (LR(p), p->sem.binary.att1)) {
- comp = alg_comp_gt ? alg_comp_lt : comp;
+ /* switch direction of inequality predicates */
+ if (comp == alg_comp_gt)
+ comp = alg_comp_lt;
+ else if (comp == alg_comp_lt)
+ comp = alg_comp_gt;
res = p->sem.binary.res;
att1 = p->sem.binary.att2;
att2 = p->sem.binary.att1;
@@ -594,13 +598,10 @@
/* integrate the comparison as a possible new predicate
in the thetajoin operator */
if (match) {
- /* create a new thetajoin operator ... */
- *p = *(thetajoin_opt (LL(p),
- LR(p),
- L(p)->sem.thetajoin_opt.pred));
-
- /* ... and add a new predicate */
- *(pred_struct *) PFarray_add (p->sem.thetajoin_opt.pred) =
+ PFarray_t *pred = PFarray_copy (L(p)->sem.thetajoin_opt.pred);
+
+ /* add a new predicate ... */
+ *(pred_struct *) PFarray_add (pred) =
(pred_struct) {
.comp = comp,
.left = att1,
@@ -611,6 +612,10 @@
.right_vis = true,
.res_vis = true
};
+
+ /* ... and create a new thetajoin operator */
+ *p = *(thetajoin_opt (LL(p), LR(p), pred));
+
modified = true;
}
}
@@ -1286,20 +1291,35 @@
att = p->sem.unary.att;
PFarray_t *pred;
unsigned int i;
- PFalg_comp_t comp;
-
- /* pacify picky compilers: one does not like no value (gcc)
- and the other one does not like a dummy value (icc) */
- comp = alg_comp_eq;
+ PFalg_comp_t comp = alg_comp_eq;
/* make sure that column res is not used as join argument
*/
resolve_name_conflict (L(p), res);
+
+ /* copy the predicates ... */
+ pred = PFarray_copy (L(p)->sem.thetajoin_opt.pred);
+
+ /* ... and introduce a new predicate that makes
+ the result column visible (as we do not know
+ the comparison kind as well as the arguments
+ we choose dummy ones) */
+ *(pred_struct *) PFarray_add (pred) =
+ (pred_struct) {
+ .comp = comp, /* dummy */
+ .left = LEFT_AT (pred, 0), /* dummy */
+ .right = RIGHT_AT (pred, 0), /* dummy */
+ .res = res,
+ .persist = false,
+ .left_vis = LEFT_VIS_AT (pred, 0), /* dummy */
+ .right_vis = RIGHT_VIS_AT (pred, 0), /* dummy */
+ .res_vis = true
+ };
+
/* create a new thetajoin operator ... */
- *p = *(thetajoin_opt (LL(p),
- LR(p),
- L(p)->sem.thetajoin_opt.pred));
+ *p = *(thetajoin_opt (LL(p), LR(p), pred));
- /* find the result column ... */
+ /* get the current predicate list,
+ find the result column ... */
pred = p->sem.thetajoin_opt.pred;
for (i = 0; i < PFarray_last (pred); i++)
if (RES_VIS_AT (pred, i) && RES_AT (pred, i) == att)
@@ -1333,9 +1353,9 @@
break;
}
- /* ... and introduce a new predicate
- based on the already existing one */
- *(pred_struct *) PFarray_add (pred) =
+ /* ... and update the new predicate based
+ on the information of the already existing one */
+ *(pred_struct *) PFarray_top (pred) =
(pred_struct) {
.comp = comp,
.left = LEFT_AT (pred, i),
Index: opt_complex.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_complex.c,v
retrieving revision 1.37
retrieving revision 1.37.2.1
diff -u -d -r1.37 -r1.37.2.1
--- opt_complex.c 11 Jan 2008 16:47:20 -0000 1.37
+++ opt_complex.c 17 Jan 2008 08:36:36 -0000 1.37.2.1
@@ -1036,17 +1036,23 @@
case la_rownum:
/* Replace the rownumber operator by a projection
- if only its order and value distribution (keys)
- are required instead of its values. */
- if (PFprop_req_distr_col (p->prop, p->sem.sort.res) &&
+ if only its value distribution (keys) are required
+ instead of its real values. */
+ if (!PFprop_req_value_col (p->prop, p->sem.sort.res) &&
PFord_count (p->sem.sort.sortby) == 1 &&
- PFord_order_dir_at (p->sem.sort.sortby, 0) == DIR_ASC &&
PFprop_key (p->prop,
PFord_order_col_at (p->sem.sort.sortby, 0))) {
/* create projection list */
PFalg_proj_t *proj_list = PFmalloc ((L(p)->schema.count + 1)
* sizeof (*(proj_list)));
+ /* We cannot rewrite if we require the correct order
+ and the rownum operator changes it from descending
+ to ascending. */
+ if (PFord_order_dir_at (p->sem.sort.sortby, 0) == DIR_DESC &&
+ PFprop_req_order_col (p->prop, p->sem.sort.res))
+ break;
+
/* copy the child schema (as we cannot be sure that
the schema of the rownum operator is still valid) ...*/
for (unsigned int i = 0; i < L(p)->schema.count; i++)
-------------------------------------------------------------------------
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