Update of /cvsroot/monetdb/pathfinder/compiler/algebra/opt
In directory
sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv22863/compiler/algebra/opt
Modified Files:
Tag: M5XQ
opt_join_graph.c
Log Message:
propagated changes of Thursday Mar 18 2010
from the XQFT branch to the M5XQ branch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2010/03/18 - sjoerd: compiler/algebra/opt/opt_join_graph.c,1.29.10.2
propagated changes of Wednesday Mar 17 2010 - Thursday Mar 18 2010
from the development trunk to the XQFT branch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2010/03/17 - tsheyar: compiler/algebra/opt/opt_join_graph.c,1.31
-- Make join-graph rewrite (moving distinct operators to the plan top) more
generic.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2010/03/17 - tsheyar: compiler/algebra/opt/opt_join_graph.c,1.32
-- Introduced a new column-name-origin property that enhances the column
names
in the DOT generated algebra plans. If a column stems from a ref_tbl or a
path step we now keep the original name throughout the plan.
(Use pf-option -fN to print the mapping of original names.)
-- Make property usage a little bit more defensive. Instead of !PFprop_icol
a new function PFprop_not_icol is introduced that copes correctly with
missing property information.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Index: opt_join_graph.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/opt/opt_join_graph.c,v
retrieving revision 1.26.4.2
retrieving revision 1.26.4.3
diff -u -d -r1.26.4.2 -r1.26.4.3
--- opt_join_graph.c 7 Jan 2010 16:56:52 -0000 1.26.4.2
+++ opt_join_graph.c 18 Mar 2010 11:45:18 -0000 1.26.4.3
@@ -163,7 +163,7 @@
elsewhere. */
for (j = 0; j < clsize (collist); j++)
if (clat (collist, j) == p->sem.rowid.res ||
- !PFprop_icol (p->prop, clat (collist, j)))
+ PFprop_not_icol (p->prop, clat (collist, j)))
break;
if (j == clsize (collist)) {
PFord_ordering_t sortby = PFordering ();
@@ -467,6 +467,42 @@
}
}
+/* Bottom-up rewrite that introduces additional distinct operators on top
+ of rank and equi-join operators if their schema contains a key. */
+static void
+opt_distinct (PFla_op_t *p)
+{
+ assert (p);
+
+ /* rewrite each node only once */
+ if (SEEN(p))
+ return;
+ else
+ SEEN(p) = true;
+
+ /* apply join-graph specific optimization for children */
+ for (unsigned int i = 0; i < PFLA_OP_MAXCHILD && p->child[i]; i++)
+ opt_distinct (p->child[i]);
+
+ /* rewrite children */
+ if (L(p) &&
+ (L(p)->kind == la_rank ||
+ L(p)->kind == la_eqjoin) &&
+ !PFprop_set (L(p)->prop) &&
+ (PFprop_keys_count (L(p)->prop) ||
+ PFprop_ckey (L(p)->prop, L(p)->schema)))
+ L(p) = PFla_distinct (L(p));
+
+ if (R(p) &&
+ (R(p)->kind == la_rank ||
+ R(p)->kind == la_eqjoin) &&
+ !PFprop_set (R(p)->prop) &&
+ (PFprop_keys_count (R(p)->prop) ||
+ PFprop_ckey (R(p)->prop, R(p)->schema)))
+ R(p) = PFla_distinct (R(p));
+}
+
+
/**
* Invoke algebra optimization.
*
@@ -478,48 +514,19 @@
PFla_op_t *
PFalgopt_join_graph (PFla_op_t *root, PFguide_list_t *guide_list)
{
- /* PHASE 1: Seed a distinct operator on top of the query plan
+ /* PHASE 1: Seed distinct operators on top of the query plan
if possible to remove all other distinct operators. */
- /* Infer key property first */
- PFprop_infer_key (root);
-
- /* Place a distinct operator on top if the query represents a join
- graph whose sort criterion is also the output (check for keyness
- of column item only). Here we apply this rewrite first to remove all
- distinct operators in the following phase and to remove the distinct
- operator by key property analysis at the end (if it is not needed). */
- if (root->kind == la_serialize_seq) {
- PFla_op_t *p = root;
- PFalg_col_t item = p->sem.ser_seq.item;
-
- /* introduce a new distinct operator on top of the plan if the
- input already forms a key, ... */
- if (PFprop_key (p->prop, item) &&
- /* ... the query is a join-graph query, ... */
- !(PFprop_type_of (p, item) & ~aat_node) &&
- /* ... and a distinct operator does not occur in the near
- surrounding. */
- R(p)->kind != la_distinct &&
- !(R(p)->kind == la_project && RL(p)->kind == la_distinct)) {
- /* once again check for the join graph
- this time ensuring that the result does
- not produce new nodes */
- PFla_op_t *frag = LR(p);
- while (frag->kind == la_frag_union) {
- assert (R(frag)->kind == la_fragment);
- if (RL(frag)->kind != la_doc_tbl)
- break;
- frag = L(frag);
- }
- if (frag->kind != la_frag_union) {
- assert (frag->kind == la_empty_frag);
+ /* Infer all key information we can get */
+ PFprop_infer_composite_key (root);
+ PFprop_infer_key_and_fd (root);
+ /* Infer set property to avoid the excessive
+ introduction of distinct operators */
+ PFprop_infer_set (root);
- /* introduce distinct */
- R(p) = PFla_distinct (R(p));
- }
- }
- }
+ /* introduce additional distinct operators on top of the plan */
+ opt_distinct (root);
+ PFla_dag_reset (root);
/* PHASE 2: optimize based on top-down set property */
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins