Update of /cvsroot/monetdb/pathfinder/compiler/algebra/opt
In directory
sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv21826/compiler/algebra/opt
Modified Files:
Tag: PF_ROX
opt_complex.c opt_const.c opt_icol.c opt_join_pd.c opt_set.c
Log Message:
propagated changes of Thursday Jun 05 2008 - Friday Jun 06 2008
from the development trunk to the PF_ROX branch
U opt_icol.c
Index: opt_icol.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_icol.c,v
retrieving revision 1.20.4.4
retrieving revision 1.20.4.5
diff -u -d -r1.20.4.4 -r1.20.4.5
--- opt_icol.c 30 May 2008 12:39:07 -0000 1.20.4.4
+++ opt_icol.c 6 Jun 2008 14:25:35 -0000 1.20.4.5
@@ -384,7 +384,6 @@
break;
case la_element:
- case la_textnode:
case la_comment:
*p = *PFla_project (
LLL(p),
@@ -410,9 +409,14 @@
LL(p)->sem.iter_pos_item.iter));
break;
- default:
- assert (0);
+ case la_textnode:
+ /* As a textnode based on an empty string
+ has to result in an empty sequence we
+ are not allowed to throw away the textnode
+ constructor. */
break;
+ default:
+ assert(0);
}
else if (L(p)->kind == la_doc_tbl &&
!PFprop_icol (L(p)->prop, L(p)->sem.doc_tbl.res)) {
@@ -424,10 +428,12 @@
case la_frag_union:
if (L(p)->kind == la_fragment &&
LL(p)->kind == la_twig &&
+ LLL(p)->kind != la_textnode && /* retain textnodes */
!PFprop_icol (LL(p)->prop, LL(p)->sem.iter_item.item))
*p = *PFla_dummy (R(p));
else if (R(p)->kind == la_fragment &&
RL(p)->kind == la_twig &&
+ RLL(p)->kind != la_textnode && /* retain textnodes */
!PFprop_icol (RL(p)->prop, RL(p)->sem.iter_item.item))
*p = *PFla_dummy (L(p));
else if (L(p)->kind == la_fragment &&
U opt_complex.c
Index: opt_complex.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_complex.c,v
retrieving revision 1.39.2.5
retrieving revision 1.39.2.6
diff -u -d -r1.39.2.5 -r1.39.2.6
--- opt_complex.c 31 May 2008 11:45:13 -0000 1.39.2.5
+++ opt_complex.c 6 Jun 2008 14:25:34 -0000 1.39.2.6
@@ -635,6 +635,7 @@
break;
}
+#if 0 /* disable join -> semijoin rewrites */
/* introduce semi-join operator if possible */
if (!left_arg_req &&
(PFprop_key_left (p->prop, p->sem.eqjoin.att1) ||
@@ -750,6 +751,7 @@
*p = *PFla_project_ (semijoin, count, proj);
break;
}
+#endif
} break;
case la_semijoin:
U opt_join_pd.c
Index: opt_join_pd.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_join_pd.c,v
retrieving revision 1.37.4.5
retrieving revision 1.37.4.6
diff -u -d -r1.37.4.5 -r1.37.4.6
--- opt_join_pd.c 30 May 2008 12:39:10 -0000 1.37.4.5
+++ opt_join_pd.c 6 Jun 2008 14:25:35 -0000 1.37.4.6
@@ -1384,6 +1384,50 @@
}
/**
+ * mark_left_subdag marks all operators in the DAG
+ * underneath p as being LEFT children of the join.
+ */
+static void
+mark_left_subdag (PFla_op_t *p)
+{
+ assert (p);
+
+ if (LEFT(p))
+ return;
+
+ if (p->kind == la_frag_union ||
+ p->kind == la_empty_frag)
+ return;
+
+ for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++)
+ mark_left_subdag (p->child[i]);
+
+ LEFT(p) = true;
+}
+
+/**
+ * mark_right_subdag marks all operators in the DAG
+ * underneath p as being RIGHT children of the join.
+ */
+static void
+mark_right_subdag (PFla_op_t *p)
+{
+ assert (p);
+
+ if (RIGHT(p))
+ return;
+
+ if (p->kind == la_frag_union ||
+ p->kind == la_empty_frag)
+ return;
+
+ for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++)
+ mark_right_subdag (p->child[i]);
+
+ RIGHT(p) = true;
+}
+
+/**
* mark_left_path follows a path based on an initial
* column name and marks all operators on the path as
* being LEFT children of the join.
@@ -1411,9 +1455,22 @@
LEFT(p) = true;
return;
}
+ else if (p->kind == la_disjunion ||
+ p->kind == la_intersect ||
+ p->kind == la_difference) {
+ /* the name column is split into multiple columns
+ so we fall back to the primitive variant */
+ mark_left_subdag (p);
+ return;
+ }
att = map_name (p, att);
- if (!att) return;
+ if (!att) {
+ /* we could not follow the names and
+ have to fall back to the primitive variant */
+ mark_left_subdag (p);
+ return;
+ }
for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++)
for (unsigned int j = 0; j < p->child[i]->schema.count; j++)
@@ -1453,10 +1510,23 @@
LEFT(p) = true;
return;
}
+ else if (p->kind == la_disjunion ||
+ p->kind == la_intersect ||
+ p->kind == la_difference) {
+ /* the name column is split into multiple columns
+ so we fall back to the primitive variant */
+ mark_right_subdag (p);
+ return;
+ }
att = map_name (p, att);
- if (!att) return;
+ if (!att) {
+ /* we could not follow the names and
+ have to fall back to the primitive variant */
+ mark_right_subdag (p);
+ return;
+ }
for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++)
for (unsigned int j = 0; j < p->child[i]->schema.count; j++)
@@ -1469,50 +1539,6 @@
}
/**
- * mark_left_subdag marks all operators in the DAG
- * underneath p as being LEFT children of the join.
- */
-static void
-mark_left_subdag (PFla_op_t *p)
-{
- assert (p);
-
- if (LEFT(p))
- return;
-
- if (p->kind == la_frag_union ||
- p->kind == la_empty_frag)
- return;
-
- for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++)
- mark_left_subdag (p->child[i]);
-
- LEFT(p) = true;
-}
-
-/**
- * mark_right_subdag marks all operators in the DAG
- * underneath p as being RIGHT children of the join.
- */
-static void
-mark_right_subdag (PFla_op_t *p)
-{
- assert (p);
-
- if (RIGHT(p))
- return;
-
- if (p->kind == la_frag_union ||
- p->kind == la_empty_frag)
- return;
-
- for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++)
- mark_right_subdag (p->child[i]);
-
- RIGHT(p) = true;
-}
-
-/**
* remove_marks reset both LEFT and RIGHT marks.
* The processing traverses the subDAG until a node
* without mark is reached.
U opt_set.c
Index: opt_set.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_set.c,v
retrieving revision 1.8.4.1
retrieving revision 1.8.4.2
diff -u -d -r1.8.4.1 -r1.8.4.2
--- opt_set.c 18 Feb 2008 16:57:19 -0000 1.8.4.1
+++ opt_set.c 6 Jun 2008 14:25:36 -0000 1.8.4.2
@@ -142,6 +142,7 @@
p->sem.step.item);
break;
+#if 0 /* disable step_join -> step rewrite */
case la_step_join:
if (PFprop_set (p->prop) &&
PFprop_icols_count (p->prop) == 2 &&
@@ -174,6 +175,7 @@
p->sem.step.item_res);
}
break;
+#endif
case la_guide_step:
if (PFprop_set (p->prop) &&
U opt_const.c
Index: opt_const.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_const.c,v
retrieving revision 1.28.4.3
retrieving revision 1.28.4.4
diff -u -d -r1.28.4.3 -r1.28.4.4
--- opt_const.c 22 May 2008 08:48:31 -0000 1.28.4.3
+++ opt_const.c 6 Jun 2008 14:25:35 -0000 1.28.4.4
@@ -455,37 +455,45 @@
and replace it by an unpartitioned count */
if (p->schema.count == 1 &&
L(p)->kind == la_project &&
- L(L(p))->kind == la_count &&
- PFprop_const (L(L(p))->prop, L(L(p))->sem.aggr.part) &&
+ LL(p)->kind == la_count &&
+ PFprop_const (LL(p)->prop, LL(p)->sem.aggr.part) &&
+ L(p)->sem.proj.items[0].old == LL(p)->sem.aggr.res &&
R(p)->kind == la_project &&
- L(R(p))->kind == la_attach &&
- L(R(p))->sem.attach.value.type == aat_int &&
- L(R(p))->sem.attach.value.val.int_ == 0 &&
- L(L(R(p)))->kind == la_difference &&
- R(L(L(R(p))))->kind == la_project &&
- R(L(L(R(p))))->sem.proj.items[0].new ==
- L(L(p))->sem.aggr.part &&
- L(R(L(L(R(p))))) == L(L(p))) {
+ RL(p)->kind == la_attach &&
+ R(p)->sem.proj.items[0].old == RL(p)->sem.attach.res &&
+ RL(p)->sem.attach.value.type == aat_int &&
+ RL(p)->sem.attach.value.val.int_ == 0 &&
+ RLL(p)->kind == la_difference &&
+ RLLR(p)->kind == la_project &&
+ RLLR(p)->sem.proj.items[0].old ==
+ LL(p)->sem.aggr.part &&
+ L(RLLR(p)) == LL(p)) {
/* check that the values in the loop are constant
and provide the same value */
- assert (PFprop_const (L(L(L(R(p))))->prop,
- L(L(p))->sem.aggr.part));
+ assert (PFprop_const (RLLL(p)->prop,
+ LL(p)->sem.aggr.part));
assert (
PFalg_atom_comparable (
- PFprop_const_val (L(L(L(R(p))))->prop,
- L(L(p))->sem.aggr.part),
- PFprop_const_val (L(L(p))->prop,
- L(L(p))->sem.aggr.part)) &&
+ PFprop_const_val (RLLL(p)->prop,
+ RLLR(p)->sem.proj.items[0].new),
+ PFprop_const_val (LL(p)->prop,
+ LL(p)->sem.aggr.part)) &&
!PFalg_atom_cmp (
- PFprop_const_val (L(L(L(R(p))))->prop,
- L(L(p))->sem.aggr.part),
- PFprop_const_val (L(L(p))->prop,
- L(L(p))->sem.aggr.part)));
+ PFprop_const_val (RLLL(p)->prop,
+ RLLR(p)->sem.proj.items[0].new),
+ PFprop_const_val (LL(p)->prop,
+ LL(p)->sem.aggr.part)));
- *p = *PFla_count (L(L(L(p))),
- p->schema.items[0].name,
- att_NULL);
+ /* To avoid creating more results than allowed (1 instead
+ of 0) we have to make sure that we take the cardinality
+ of the loop relation into account. */
+ *p = *project (cross (RLLL(p), /* loop */
+ PFla_count (LLL(p),
+ R(p)->sem.proj.items[0].old,
+ att_NULL)),
+ proj (R(p)->sem.proj.items[0].new,
+ R(p)->sem.proj.items[0].old));
break;
}
break;
@@ -659,6 +667,11 @@
/* some optimization opportunities for
aggregate operators arise if 'att' is constant */
if (PFprop_const_left (p->prop, p->sem.aggr.att)) {
+
+#if 0 /* We are not allowed to create an unpartitioned aggregate
+ as an empty loop relation might result in a single line
+ result otherwise. */
+
/* if partitioning column is constant as well
replace aggregate by a new literal table
with one row containing 'att' and 'part' */
@@ -677,6 +690,7 @@
constant we can replace the aggregate by a
distinct operator (value in 'att' stays the same). */
else if (p->sem.aggr.part)
+#endif
*p = *PFla_distinct (
PFla_project (
L(p),
@@ -684,6 +698,7 @@
p->sem.aggr.att),
PFalg_proj (p->sem.aggr.part,
p->sem.aggr.part)));
+#if 0
/* replace aggregate by a new literal table
containining a single record with the result of
aggregate operator. */
@@ -693,6 +708,7 @@
PFprop_const_val_left (
p->prop,
p->sem.aggr.att)));
+#endif
}
break;
@@ -704,6 +720,10 @@
p->sem.aggr.att));
}
+#if 0 /* We are not allowed to create an unpartitioned aggregate
+ as an empty loop relation might result in a single line
+ result otherwise. */
+
/* if partitiong attribute is constant remove it
and attach it after the operator */
if (p->sem.aggr.part &&
@@ -739,6 +759,7 @@
*p = *ret;
SEEN(p) = true;
}
+#endif
break;
case la_rownum:
@@ -814,17 +835,24 @@
PFprop_const_left (p->prop, p->sem.aggr.att)) {
PFla_op_t *op, *ret;
+#if 0 /* We are not allowed to create an unpartitioned aggregate
+ as an empty loop relation might result in a single line
+ result otherwise. */
+
if (PFprop_const_left (p->prop, p->sem.aggr.part)) {
op = lit_tbl (attlist (p->sem.aggr.part),
tuple (PFprop_const_val_left (
p->prop,
p->sem.aggr.part)));
} else {
+#endif
op = distinct (
project (L(p),
proj (p->sem.aggr.part,
p->sem.aggr.part)));
+#if 0
}
+#endif
ret = add_attach (op, p->sem.aggr.att,
PFprop_const_val_left (
@@ -833,6 +861,10 @@
*p = *ret;
SEEN(p) = true;
}
+#if 0 /* We are not allowed to create an unpartitioned aggregate
+ as an empty loop relation might result in a single line
+ result otherwise. */
+
else if (PFprop_const_left (p->prop, p->sem.aggr.att)) {
PFla_op_t *ret = lit_tbl (attlist (p->sem.aggr.att),
tuple (PFprop_const_val_left (
@@ -842,6 +874,7 @@
SEEN(p) = true;
}
/* fall through */
+#endif
case la_seqty1:
/* introduce attach if necessary */
if (PFprop_const_left (p->prop, p->sem.aggr.att)) {
@@ -850,6 +883,10 @@
p->sem.aggr.att));
}
+#if 0 /* We are not allowed to create an unpartitioned aggregate
+ as an empty loop relation might result in a single line
+ result otherwise. */
+
/* if partitiong attribute is constant remove it
and attach it after the operator */
if (p->sem.aggr.part &&
@@ -872,6 +909,7 @@
*p = *ret;
SEEN(p) = true;
}
+#endif
break;
case la_cond_err:
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins