Update of /cvsroot/monetdb/pathfinder/compiler/algebra
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv31425/compiler/algebra
Modified Files:
Tag: xquery-decomposition
algebra.c builtins.c core2alg.brg intro_rec_border.c
ordering.c physical.c planner.c
Log Message:
propagated changes of Monday Feb 11 2008 - Saturday Feb 16 2008
from the development trunk to the xquery-decomposition branch
Index: core2alg.brg
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/core2alg.brg,v
retrieving revision 1.60.2.1
retrieving revision 1.60.2.2
diff -u -d -r1.60.2.1 -r1.60.2.2
--- core2alg.brg 8 Feb 2008 22:59:13 -0000 1.60.2.1
+++ core2alg.brg 16 Feb 2008 01:02:07 -0000 1.60.2.2
@@ -51,6 +51,9 @@
#include "algebra.h"
+/* Easily access subtree-parts */
+#include "child_mnemonic.h"
+
/*
* Accessors for the burg matcher
*/
@@ -272,41 +275,6 @@
%%
-/*
- * Easily access subtree-parts.
- */
-/** starting from p, make a step left */
-#define L(p) (LEFT_CHILD(p))
-/** starting from p, make a step right */
-#define R(p) (RIGHT_CHILD(p))
-/** starting from p, make two steps left */
-#define LL(p) L(L(p))
-/** starting from p, make a step left, then a step right */
-#define LR(p) R(L(p))
-/** starting from p, make a step right, then a step left */
-#define RL(p) L(R(p))
-/** starting from p, make two steps right */
-#define RR(p) R(R(p))
-/* ... and so on ... */
-#define RRL(p) L(R(R(p)))
-#define RRRL(p) L(R(R(R(p))))
-#define RRRRL(p) L(R(R(R(R(p)))))
-#define RRRRRL(p) L(R(R(R(R(R(p))))))
-#define RRRRRR(p) R(R(R(R(R(R(p))))))
-#define LLR(p) R(L(L(p)))
-#define RRR(p) R(R(R(p)))
-#define LLL(p) L(L(L(p)))
-#define LLLL(p) L(L(L(L(p))))
-#define LLLLL(p) L(L(L(L(L(p)))))
-#define LLLLR(p) R(L(L(L(L(p)))))
-#define LLLR(p) R(L(L(L(p))))
-#define RLL(p) L(L(R(p)))
-#define RLLR(p) R(L(L(R(p))))
-#define RLLL(p) L(L(L(R(p))))
-#define RLR(p) R(L(R(p)))
-#define RRLL(p) L(L(R(R(p))))
-#define RRLR(p) R(L(R(R(p))))
-
/** Algebra equivalent of a Core tree node */
#define A(p) ((p)->alg)
@@ -1480,8 +1448,8 @@
atom = lit_bln (true);
}
else if (PFty_equality (t, PFty_untypedAtomic ())) {
- atom = lit_str ("");
algty = atom.type = aat_uA;
+ atom = lit_str ("");
}
else
PFoops (OOPS_FATAL,
Index: algebra.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/algebra.c,v
retrieving revision 1.66.2.2
retrieving revision 1.66.2.3
diff -u -d -r1.66.2.2 -r1.66.2.3
--- algebra.c 30 Jan 2008 10:58:22 -0000 1.66.2.2
+++ algebra.c 16 Feb 2008 01:02:06 -0000 1.66.2.3
@@ -160,11 +160,13 @@
*
* The simple type @c node plays a special role: Lateron, we will
* distinct attribute nodes and other nodes. In both cases we will
- * implement XML tree nodes with help of @em two columns: @em pre / @em attr
- * and @em pfrag / @em afrag. Enum value @c aat_pnode thus sets @em two bits;
- * the two sub-parts are available as @c aat_pre and @c aat_pfrag. Accordingly
- * the enum value @c aat_anode sets the bits for the sub-parts @c aat_attr
- * and @c aat_afrag. (See also @ref table_representation below.)
+ * implement XML tree nodes with help of @em two to three columns:
+ * @em pre, @em frag and possibly @em attr. Enum value @c aat_pnode
+ * thus sets @em three bits; the three sub-parts are available as
+ * @c aat_pre, @c aat_frag and @c aat_nkind. The last bit is only used
+ * to decide if we have non-attribute nodes. Accordingly the enum value
+ * @c aat_anode sets the bits for the sub-parts @c aat_pre, @c aat_attr
+ * and @c aat_frag. (See also @ref table_representation below.)
*
* @subsection algopt Optimizing Logical Algebra Trees
*
@@ -301,7 +303,7 @@
* information please refer to the @ref commandline section on the
* main page (main.c).
*
- * @section milgen Compiling Plans into Internal MIL Code Representation
+ * @section milgenOverview Compiling Plans into Internal MIL Code
Representation
*
* Generation into MIL code is again implemented based on a Burg pattern
* matcher (file @c milgen.brg). Its output is an internal representation
@@ -333,11 +335,9 @@
@endverbatim
* .
* - XML tree nodes are not implemented as a single column, but as a
- * pre/kind pair. This is adapted from Jan's "summer branch"
- * implementation and allows to re-use lots of things in the runtime
- * module.
+ * pre/attr/frag triple.
*
- * The special role, where nodes are represented as two columns, while
+ * The special role, where nodes are represented as three columns, while
* other types only occupy one column, is nicely captured by our bit
* vector encoding of algebra types (see @ref log_impl).
*
@@ -381,12 +381,15 @@
* of compilation. Future versions might directly serialize the value
* encoding used by the "algebra" MIL generator.
*
+ * For more specific information on the MIl generation please refer
+ * to the @ref milgenDetail page in milgen.brg.
+ *
* @section milprint Serializing MIL
*
* The file @c milgen.brg produces an <em>internal tree representation</em>
- * of the generated MIL program. (Reason for this is that we might do
- * rewrites to the MIL code afterwards this way, comparable to the
- * mil_opt.c optimizer in the "summer branch").
+ * of the generated MIL program. Reason for this is that we apply a dead code
+ * elimination on the MIL tree afterwards. The MIL dead code elimination in
+ * #mil_dce.c removes all variables that are not referenced.
*
* The ASCII representation parsable by MonetDB is generated in
* milprint.c. In a sense, this file implements a grammar for the
@@ -554,7 +557,7 @@
* a pair consisting of the new and old attribute name.
* Particularly useful in combination with the constructor
* function for the algebra projection operator (see
- * #PFalg_project() or its wrapper macro #project()).
+ * #PFla_project_() or its wrapper macro #project()).
*
* @param new Attribute name after the projection
* @param old ``Old'' attribute name in the argument of
@@ -683,9 +686,6 @@
: (a.val.nat_ < b.val.nat_ ? -1 : 1));
case aat_int: return a.val.int_ - b.val.int_;
case aat_uA:
- case aat_path:
- case aat_docnm:
- case aat_colnm:
case aat_str: return strcmp (a.val.str, b.val.str);
case aat_dec: return (a.val.dec_ == b.val.dec_ ? 0
: (a.val.dec_ < b.val.dec_ ? -1 : 1));
@@ -693,27 +693,11 @@
: (a.val.dbl < b.val.dbl ? -1 : 1));
case aat_bln: return a.val.bln - b.val.bln;
case aat_qname: return PFqname_eq (a.val.qname, b.val.qname);
- case aat_node:
- case aat_pnode:
- case aat_anode:
- case aat_pre:
- case aat_attr:
- case aat_pfrag:
- case aat_afrag:
- case aat_update:
- case aat_docmgmt:
- case aat_node1:
- case aat_pnode1:
- case aat_anode1:
- case aat_pre1:
- case aat_attr1:
- case aat_pfrag1:
- case aat_afrag1:
- break;
+ default:
+ PFoops (OOPS_FATAL, "error comparing literal values");
+ break;
}
- PFoops (OOPS_FATAL, "error comparing literal values");
-
assert(0); /* never reached due to "exit" in PFoops */
return 0; /* pacify picky compilers */
}
@@ -734,21 +718,12 @@
case aat_qname: return "qname";
case aat_node: return "node";
case aat_anode: return "attr";
- case aat_attr: return "attrID";
- case aat_afrag: return "afrag";
case aat_pnode: return "pnode";
- case aat_pre: return "pre";
- case aat_pfrag: return "pfrag";
- case aat_node1: return "node1";
- case aat_anode1:return "attr1";
- case aat_attr1: return "attrID1";
- case aat_afrag1:return "afrag1";
- case aat_pnode1:return "pnode1";
- case aat_pre1: return "pre1";
- case aat_pfrag1:return "pfrag1";
- case aat_path: return "path";
- case aat_docnm: return "docnm";
- case aat_colnm: return "colnm";
+ case aat_qname_id: return "qname id";
+ case aat_qname_cont: return "qname cont";
+ case aat_frag: return "frag";
+ case aat_pre: return "pre";
+ case aat_attr: return "attr";
default:
if (type & aat_update)
return "update";
Index: ordering.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/ordering.c,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -u -d -r1.9 -r1.9.2.1
--- ordering.c 11 Jan 2008 10:46:56 -0000 1.9
+++ ordering.c 16 Feb 2008 01:02:08 -0000 1.9.2.1
@@ -112,6 +112,24 @@
return (*((PFalg_order_item_t *) PFarray_at (ordering, index))).dir;
}
+void
+PFord_set_order_col_at (PFord_ordering_t ordering, unsigned int index,
+ PFalg_att_t name)
+{
+ assert (index < PFord_count (ordering));
+
+ (*((PFalg_order_item_t *) PFarray_at (ordering, index))).name = name;
+}
+
+void
+PFord_set_order_dir_at (PFord_ordering_t ordering, unsigned int index,
+ bool dir)
+{
+ assert (index < PFord_count (ordering));
+
+ (*((PFalg_order_item_t *) PFarray_at (ordering, index))).dir = dir;
+}
+
bool
PFord_implies (const PFord_ordering_t a, const PFord_ordering_t b)
{
Index: physical.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/physical.c,v
retrieving revision 1.50.2.3
retrieving revision 1.50.2.4
diff -u -d -r1.50.2.3 -r1.50.2.4
--- physical.c 8 Feb 2008 22:59:13 -0000 1.50.2.3
+++ physical.c 16 Feb 2008 01:02:08 -0000 1.50.2.4
@@ -38,10 +38,8 @@
#include "pathfinder.h"
#include <assert.h>
-/* FIXME: only for debugging */
#include <string.h>
#include <stdio.h>
-#include <math.h>
#include "physical.h"
#include "mem.h"
@@ -164,19 +162,15 @@
[...1069 lines suppressed...]
-
- /* create new function application parameter node */
- ret = wire2 (pa_fun_frag_param, argument, param_list);
-
- /* allocate memory for the result schema */
- ret->schema.count = 0;
- ret->schema.items = NULL;
-
- ret->sem.col_ref.pos = col_pos;
-
- /* costs */
- ret->cost = argument->cost + param_list->cost;
-
- return ret;
-}
-
-/**
* Construct concatenation of multiple strings
*
* @a n1 contains the sets of strings @a n2 stores the separator for each set
Index: planner.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/planner.c,v
retrieving revision 1.46.2.2
retrieving revision 1.46.2.3
diff -u -d -r1.46.2.2 -r1.46.2.3
--- planner.c 8 Feb 2008 22:59:13 -0000 1.46.2.2
+++ planner.c 16 Feb 2008 01:02:08 -0000 1.46.2.3
@@ -113,11 +113,8 @@
/* We will need a notion of ``ordering''. */
#include "ordering.h"
-/* short-hands */
-#define L(p) ((p)->child[0])
-#define R(p) ((p)->child[1])
-#define LL(p) (L(L(p)))
-#define LR(p) (R(L(p)))
+/* Easily access subtree-parts */
+#include "child_mnemonic.h"
/**
* A ``plan'' is actually a physical algebra operator tree.
@@ -207,7 +204,6 @@
PFplanlist_t *sorted = new_planlist ();
assert (n); assert (n->kind == la_serialize_seq);
- assert (L(n)); assert (L(n)->plans);
assert (R(n)); assert (R(n)->plans);
/* The serialize operator requires its input to be properly sorted. */
@@ -222,12 +218,10 @@
/* for each remaining plan, generate a Serialize operator */
for (unsigned int i = 0; i < PFarray_last (sorted); i++)
- for (unsigned int j = 0; j < PFarray_last (L(n)->plans); j++)
- add_plan (ret,
- serialize (
- *(plan_t **) PFarray_at (L(n)->plans, j),
- *(plan_t **) PFarray_at (sorted, i),
- n->sem.ser_seq.item));
+ add_plan (ret,
+ serialize (
+ *(plan_t **) PFarray_at (sorted, i),
+ n->sem.ser_seq.item));
return ret;
}
@@ -399,54 +393,6 @@
*/
add_plan (ret, leftjoin (att2, att1, b, a));
add_plan (ret, leftjoin (att1, att2, a, b));
-
-#if 0
- PFalg_att_t att_a = NULL;
- PFalg_att_t att_b = NULL;
- PFplanlist_t *sorted_a;
- PFplanlist_t *sorted_b;
-
- /* We can always apply the nested loops join */
- add_plan (ret, nljoin (att1, att2, a, b));
-
- /* test which of the two attributes is in which argument */
- for (unsigned int i = 0; i < a->schema.count; i++)
- if (a->schema.items[i].name == att1) {
- att_a = att1;
- break;
- }
- else if (a->schema.items[i].name == att2) {
- att_a = att2;
- break;
- }
-
- for (unsigned int i = 0; i < b->schema.count; i++)
- if (b->schema.items[i].name == att1) {
- att_b = att1;
- break;
- }
- else if (b->schema.items[i].name == att2) {
- att_b = att2;
- break;
- }
-
- assert (att_a && att_b);
-
- /* We can use MergeJoin after sorting both arguments on the
- * join attributes.
- */
- sorted_a = prune_plans (
- ensure_ordering (a, PFord_refine (PFordering (), att_a)));
- sorted_b = prune_plans (
- ensure_ordering (b, PFord_refine (PFordering (), att_b)));
-
- /* apply MergeJoin for all the resulting plans */
- for (unsigned int i = 0; i < PFarray_last (sorted_a); i++)
- for (unsigned int j = 0; j < PFarray_last (sorted_a); j++)
- add_plan (ret, merge_join (att_a, att_b,
- *(plan_t **) PFarray_at (sorted_a, i),
- *(plan_t **) PFarray_at (sorted_b, j)));
-#endif
}
/**
@@ -1094,15 +1040,6 @@
{
PFplanlist_t *ret = new_planlist ();
- static PFpa_op_t * (*op_atom[]) (const PFpa_op_t *, const PFalg_att_t,
- const PFalg_att_t, const PFalg_atom_t)
- = {
- [la_num_eq] = PFpa_eq_atom
- , [la_num_gt] = PFpa_gt_atom
- , [la_bool_and] = PFpa_and_atom
- , [la_bool_or] = PFpa_or_atom
- };
-
static PFpa_op_t * (*op[]) (const PFpa_op_t *, const PFalg_att_t,
const PFalg_att_t, const PFalg_att_t)
= {
@@ -1112,57 +1049,15 @@
, [la_bool_or] = PFpa_or
};
+ assert (op[n->kind]);
- switch (n->kind) {
-
- case la_num_eq:
-
- assert (op_atom[n->kind]);
-
- /* consider NumAddConst if attribute att1 is known to be constant
*/
- if (PFprop_const (L(n)->prop, n->sem.binary.att1))
- for (unsigned int i = 0;
- i < PFarray_last (L(n)->plans); i++)
- add_plan (ret,
- op_atom[n->kind] (
- *(plan_t **) PFarray_at (L(n)->plans,i),
- n->sem.binary.res,
- n->sem.binary.att2,
- PFprop_const_val (L(n)->prop,
- n->sem.binary.att1)));
-
- /* fall through */
-
- case la_num_gt:
-
- assert (op_atom[n->kind]);
-
- /* consider NumAddConst if attribute att2 is known to be constant
*/
- if (PFprop_const (L(n)->prop, n->sem.binary.att2))
- for (unsigned int i = 0;
- i < PFarray_last (L(n)->plans); i++)
- add_plan (ret,
- op_atom[n->kind] (
- *(plan_t **) PFarray_at (L(n)->plans,i),
- n->sem.binary.res,
- n->sem.binary.att1,
- PFprop_const_val (L(n)->prop,
- n->sem.binary.att2)));
-
- /* fall through */
-
- default:
-
- assert (op[n->kind]);
-
- for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++)
- add_plan (ret,
- op[n->kind] (
- *(plan_t **) PFarray_at (L(n)->plans, i),
- n->sem.binary.res,
- n->sem.binary.att1,
- n->sem.binary.att2));
- }
+ for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++)
+ add_plan (ret,
+ op[n->kind] (
+ *(plan_t **) PFarray_at (L(n)->plans, i),
+ n->sem.binary.res,
+ n->sem.binary.att1,
+ n->sem.binary.att2));
return ret;
}
@@ -1240,6 +1135,48 @@
}
/**
+ * Generate physical plan for the logical `Count' operator
+ * whose empty partitions are filled up with 0 values.
+ */
+static PFplanlist_t *
+plan_count_ext (const PFla_op_t *n)
+{
+ PFplanlist_t *ret = new_planlist ();
+
+ if (!n ||
+ n->kind != la_disjunion ||
+ L(n)->kind != la_count ||
+ !L(n)->sem.aggr.part ||
+ R(n)->kind != la_attach ||
+ RL(n)->kind != la_difference ||
+ R(RL(n))->kind != la_project ||
+ RL(RL(n))->kind != la_count ||
+ L(n) != RL(RL(n)) ||
+ R(n)->sem.attach.res != L(n)->sem.aggr.res ||
+ R(n)->sem.attach.value.type != aat_int ||
+ R(n)->sem.attach.value.val.int_ != 0 ||
+ L(RL(n))->schema.count != 1 ||
+ type_of (n->schema, L(n)->sem.aggr.part) != aat_nat)
+ return ret;
+
+ assert (LL(n)->plans && L(RL(n))->plans);
+
+ /* consider each plan in L */
+ for (unsigned int l = 0; l < PFarray_last (LL(n)->plans); l++)
+ /* and each plan in R */
+ for (unsigned int r = 0; r < PFarray_last (L(RL(n))->plans); r++)
+ add_plan (ret,
+ ecount (
+ *(plan_t **) PFarray_at (LL(n)->plans, l),
+ *(plan_t **) PFarray_at (L(RL(n))->plans, r),
+ L(n)->sem.aggr.res,
+ L(n)->sem.aggr.part,
+ L(n)->sem.aggr.part));
+
+ return ret;
+}
+
+/**
* Generate physical plan for the logical `Count' operator.
*
* Currently we only provide HashCount, which neither benefits from
@@ -1260,10 +1197,8 @@
/* consider each plan in n */
for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++)
add_plan (ret,
- hash_count (
- *(plan_t **) PFarray_at (L(n)->plans, i),
- n->sem.aggr.res, n->sem.aggr.part));
-
+ count (*(plan_t **) PFarray_at (L(n)->plans, i),
+ n->sem.aggr.res, n->sem.aggr.part));
return ret;
}
@@ -1478,38 +1413,12 @@
plan_step (const PFla_op_t *n)
{
PFplanlist_t *ret = new_planlist ();
- PFpa_op_t* (*llscj) (const PFpa_op_t *, const PFpa_op_t *, const PFty_t,
- const PFord_ordering_t, const PFord_ordering_t,
- PFalg_att_t, PFalg_att_t) = NULL;
#ifndef NDEBUG
/* ensure that input and output columns have the same name */
assert (n->sem.step.item == n->sem.step.item_res);
#endif
- switch (n->sem.step.axis) {
- case alg_anc: llscj = PFpa_llscj_anc; break;
- case alg_anc_s: llscj = PFpa_llscj_anc_self; break;
- case alg_attr: llscj = PFpa_llscj_attr; break;
- case alg_chld: llscj = PFpa_llscj_child; break;
- case alg_desc: llscj = PFpa_llscj_desc; break;
- case alg_desc_s: llscj = PFpa_llscj_desc_self; break;
- case alg_fol: llscj = PFpa_llscj_foll; break;
- case alg_fol_s: llscj = PFpa_llscj_foll_sibl; break;
- case alg_par: llscj = PFpa_llscj_parent; break;
- case alg_prec: llscj = PFpa_llscj_prec; break;
- case alg_prec_s: llscj = PFpa_llscj_prec_sibl; break;
- case alg_self: assert (0); break;
- }
-
- /*
- * Consider loop-lifted staircase join variants.
- *
- * (For top-level XPath expressions, we'd not actually need
- * loop-lifted staircase joins, but could fall back to the
- * more efficient ``standard'' staircase join.
- */
-
/*
* Loop-lifted staircase join can handle two different orderings
* for input and output: iter|item or item|iter. In the invocation
@@ -1539,30 +1448,30 @@
/* generate plans for each input and each output ordering */
for (unsigned int k = 0; k < PFarray_last (ordered); k++)
- for (unsigned int l = 0; l < PFarray_last (L(n)->plans); l++)
- /* the evaluation of the attribute axis keeps the input order
*/
- if (n->sem.step.axis == alg_attr)
+ /* the evaluation of the attribute axis keeps the input order */
+ if (n->sem.step.axis == alg_attr)
+ add_plan (
+ ret,
+ llscjoin (
+ *(plan_t **) PFarray_at (ordered, k),
+ n->sem.step.axis,
+ n->sem.step.ty,
+ in[i],
+ out[i],
+ n->sem.step.iter,
+ n->sem.step.item));
+ else
+ for (unsigned short o = 0; o < 2; o++)
add_plan (
ret,
- llscj (*(plan_t **) PFarray_at (L(n)->plans, l),
- *(plan_t **) PFarray_at (ordered, k),
- n->sem.step.ty,
- in[i],
- out[i],
- n->sem.step.iter,
- n->sem.step.item));
- else
- for (unsigned short o = 0; o < 2; o++)
- add_plan (
- ret,
- llscj (*(plan_t **) PFarray_at (L(n)->plans,
- l),
- *(plan_t **) PFarray_at (ordered, k),
- n->sem.step.ty,
- in[i],
- out[o],
- n->sem.step.iter,
- n->sem.step.item));
+ llscjoin (
+ *(plan_t **) PFarray_at (ordered, k),
+ n->sem.step.axis,
+ n->sem.step.ty,
+ in[i],
+ out[o],
+ n->sem.step.iter,
+ n->sem.step.item));
}
return ret;
@@ -1605,14 +1514,12 @@
/* for each plan, generate a doc_access operator */
for (unsigned int i = 0; i < PFarray_last (R(n)->plans); i++)
- for (unsigned int j = 0; j < PFarray_last (L(n)->plans); j++)
- add_plan (ret,
- doc_access (
- *(plan_t **) PFarray_at (L(n)->plans, j),
- *(plan_t **) PFarray_at (R(n)->plans, i),
- n->sem.doc_access.res,
- n->sem.doc_access.att,
- n->sem.doc_access.doc_col));
+ add_plan (ret,
+ doc_access (
+ *(plan_t **) PFarray_at (R(n)->plans, i),
+ n->sem.doc_access.res,
+ n->sem.doc_access.att,
+ n->sem.doc_access.doc_col));
return ret;
}
@@ -1847,15 +1754,20 @@
*(plan_t **) PFarray_at (R(n)->plans, i),
sortby (iter, pos)));
- /* for each plan, generate a constructor */
- for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++)
- for (unsigned int j = 0; j < PFarray_last (ordered_in); j++)
+ if (false /* magic flag to enable shallow content constructors */)
+ /* for each plan, generate a constructor */
+ for (unsigned int i = 0; i < PFarray_last (ordered_in); i++)
add_plan (ret,
- content (
- *(plan_t **) PFarray_at (L(n)->plans, i),
- *(plan_t **) PFarray_at (ordered_in, j),
- iter,
- n->sem.iter_pos_item.item));
+ slim_content (*(plan_t **) PFarray_at (ordered_in, i),
+ iter,
+ n->sem.iter_pos_item.item));
+ else
+ /* for each plan, generate a constructor */
+ for (unsigned int i = 0; i < PFarray_last (ordered_in); i++)
+ add_plan (ret,
+ content (*(plan_t **) PFarray_at (ordered_in, i),
+ iter,
+ n->sem.iter_pos_item.item));
return ret;
}
@@ -1869,7 +1781,6 @@
{
PFplanlist_t *ret = new_planlist ();
PFplanlist_t *sorted = new_planlist ();
- plan_t *cheapest_frag_plan = NULL;
plan_t *cheapest_sorted = NULL;
PFalg_att_t iter = n->sem.merge_adjacent.iter_in;
PFalg_att_t pos = n->sem.merge_adjacent.pos_in;
@@ -1882,18 +1793,9 @@
assert (item == n->sem.merge_adjacent.item_res);
#endif
-
assert (n); assert (n->kind == la_merge_adjacent);
- assert (L(n)); assert (L(n)->plans);
assert (R(n)); assert (R(n)->plans);
- /* find the cheapest plan for the fragments */
- for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++)
- if (!cheapest_frag_plan
- || costless (*(plan_t **) PFarray_at (L(n)->plans, i),
- cheapest_frag_plan))
- cheapest_frag_plan = *(plan_t **) PFarray_at (L(n)->plans, i);
-
/* The merge_adjacent_text_node operator requires
its inputs to be properly sorted. */
for (unsigned int i = 0; i < PFarray_last (R(n)->plans); i++)
@@ -1912,97 +1814,12 @@
the single remaining plan */
add_plan (ret,
merge_adjacent (
- cheapest_frag_plan,
cheapest_sorted,
iter, pos, item));
return ret;
}
/**
- * `roots' operators in the logical algebra just get a 1:1 mapping
- * into the physical Roots operator.
- */
-static PFplanlist_t *
-plan_roots (const PFla_op_t *n)
-{
- PFplanlist_t *ret = new_planlist ();
-
- for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++)
- add_plan (ret, roots (*(plan_t **) PFarray_at (L(n)->plans, i)));
-
- return ret;
-}
-
-/**
- * `fragment' operators in the logical algebra just get a 1:1 mapping
- * into the physical Fragment operator.
- */
-static PFplanlist_t *
-plan_fragment (const PFla_op_t *n)
-{
- PFplanlist_t *ret = new_planlist ();
-
- for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++)
- add_plan (ret,
- fragment (*(plan_t **) PFarray_at (L(n)->plans, i)));
-
- return ret;
-}
-
-/**
- * `frag_extract' operators in the logical algebra just get a 1:1 mapping
- * into the physical frag_extract operator.
- */
-static PFplanlist_t *
-plan_frag_extract (const PFla_op_t *n)
-{
- PFplanlist_t *ret = new_planlist ();
-
- for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++)
- add_plan (ret,
- frag_extract (*(plan_t **) PFarray_at (L(n)->plans, i),
- n->sem.col_ref.pos));
-
- return ret;
-}
-
-/**
- * `frag_union' operators in the logical algebra just get a 1:1 mapping
- * into the physical FragUnion operator.
- */
-static PFplanlist_t *
-plan_frag_union (const PFla_op_t *n)
-{
- PFplanlist_t *ret = new_planlist ();
-
- for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++)
- for (unsigned int j = 0; j < PFarray_last (R(n)->plans); j++)
- add_plan (ret,
- frag_union (
- *(plan_t **) PFarray_at (L(n)->plans, i),
- *(plan_t **) PFarray_at (R(n)->plans, j)));
-
- return ret;
-}
-
-/**
- * `empty_frag' operators in the logical algebra just get a 1:1 mapping
- * into the physical EmptyFrag operator.
- */
-static PFplanlist_t *
-plan_empty_frag (const PFla_op_t *n __attribute__((unused)))
-{
- PFplanlist_t *ret = new_planlist ();
-
- (void) n; /* pacify picky compilers that do not understand
- "__attribute__((unused))" */
-
- add_plan (ret, empty_frag ());
-
- return ret;
-}
-
-/**
* 'error' operator in the logical algebra just get a 1:1 mapping
* into the physical error operator (just like cond_err).
*/
@@ -2193,26 +2010,6 @@
}
/**
- * `fun_frag_param' operators in the logical algebra just get a 1:1 mapping
- * into the physical fun_frag_param operator.
- */
-static PFplanlist_t *
-plan_fun_frag_param (const PFla_op_t *n)
-{
- PFplanlist_t *ret = new_planlist ();
-
- for (unsigned int i = 0; i < PFarray_last (L(n)->plans); i++)
- for (unsigned int j = 0; j < PFarray_last (R(n)->plans); j++)
- add_plan (ret,
- fun_frag_param (
- *(plan_t **) PFarray_at (L(n)->plans, i),
- *(plan_t **) PFarray_at (R(n)->plans, j),
- n->sem.col_ref.pos));
-
- return ret;
-}
-
-/**
* Create physical equivalent for the string_join operator
* (concatenates sets of strings using a seperator for each set)
*
@@ -2746,7 +2543,6 @@
/* process the following logical algebra nodes top-down */
case la_rec_fix:
case la_fun_call:
- case la_fun_frag_param:
break;
default:
/* translate bottom-up (ensure that the fragment
@@ -2804,7 +2600,10 @@
case la_select: plans = plan_select (n); break;
case la_pos_select: plans = plan_pos_select (n); break;
- case la_disjunion: plans = plan_disjunion (n); break;
+ case la_disjunion:
+ plans = plan_disjunion (n);
+ add_plans (plans, plan_count_ext (n));
+ break;
case la_intersect: plans = plan_intersect (n); break;
case la_difference: plans = plan_difference (n); break;
case la_distinct:
@@ -2883,12 +2682,14 @@
case la_content: plans = plan_content (n); break;
case la_merge_adjacent: plans = plan_merge_texts (n); break;
-
- case la_roots: plans = plan_roots (n); break;
- case la_fragment: plans = plan_fragment (n); break;
- case la_frag_extract: plans = plan_frag_extract (n); break;
- case la_frag_union: plans = plan_frag_union (n); break;
- case la_empty_frag: plans = plan_empty_frag (n); break;
+ /* copy the plans from the children */
+ case la_roots: plans = L(n)->plans; break;
+ /* dummy plans (they are not used anyway) */
+ case la_fragment:
+ case la_frag_extract:
+ case la_frag_union:
+ case la_empty_frag:
+ plans = new_planlist (); break;
case la_error: plans = plan_error (n); break;
case la_cond_err: plans = plan_cond_err (n); break;
@@ -3005,14 +2806,8 @@
} break;
case la_fun_param: plans = plan_fun_param (n); break;
- case la_fun_frag_param:
- /* TOPDOWN */
- /* change the order of the translation to ensure that fragment
- information is translated after the value part) */
- plan_subexpression (R(n));
- plan_subexpression (L(n));
- plans = plan_fun_frag_param (n);
- break;
+ /* copy the plans from the rest of the list */
+ case la_fun_frag_param: plans = R(n)->plans; break;
case la_string_join: plans = plan_string_join (n); break;
@@ -3023,7 +2818,18 @@
}
assert (plans);
- assert (PFarray_last (plans) > 0);
+#ifndef NDEBUG
+ switch (n->kind) {
+ case la_fragment:
+ case la_frag_extract:
+ case la_frag_union:
+ case la_empty_frag:
+ break;
+ default:
+ assert (PFarray_last (plans) > 0);
+ break;
+ }
+#endif
/* Introduce some more orders (on iter columns of length 1 or 2)
in the hope to share more sort operations. */
Index: builtins.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/builtins.c,v
retrieving revision 1.71.2.2
retrieving revision 1.71.2.3
diff -u -d -r1.71.2.2 -r1.71.2.3
--- builtins.c 8 Feb 2008 22:59:13 -0000 1.71.2.2
+++ builtins.c 16 Feb 2008 01:02:06 -0000 1.71.2.3
@@ -2350,6 +2350,10 @@
* is not even the right function to use there, because the constructors
* should do their job based on _statically-known namespace declarations_,
* not in-scope declarations.
+ *
+ * Furthermore a cast from string to xs:QName is only allowed at compile
+ * time on constant strings. At runtime a cast to xs:QName is only allowed
+ * for QNames inputs.
*/
struct PFla_pair_t
PFbui_fn_resolve_qname (const PFla_op_t *loop, bool ordering,
@@ -2416,22 +2420,34 @@
struct PFla_pair_t
PFbui_fn_name (const PFla_op_t *loop, bool ordering, struct PFla_pair_t *args)
{
- (void) loop; (void) ordering;
+ (void) ordering;
- return (struct PFla_pair_t) {
- .rel = project (
- fun_1to1 (
- project (args[0].rel,
- proj (att_iter, att_iter),
- proj (att_pos, att_pos),
- proj (att_item, att_item)),
- alg_fun_fn_name,
- att_res,
- attlist(att_item)),
- proj (att_iter, att_iter),
- proj (att_pos, att_pos),
- proj (att_item, att_res)),
- .frag = PFla_empty_set() };
+ PFla_op_t *strings = project (
+ fun_1to1 (
+ project (args[0].rel,
+ proj (att_iter, att_iter),
+ proj (att_pos, att_pos),
+ proj (att_item, att_item)),
+ alg_fun_fn_name,
+ att_res,
+ attlist(att_item)),
+ proj (att_iter, att_iter),
+ proj (att_pos, att_pos),
+ proj (att_item, att_res));
+
+ PFla_op_t *res = disjunion (
+ strings,
+ attach (
+ attach (
+ difference (
+ loop,
+ project (
+ strings,
+ proj (att_iter, att_iter))),
+ att_pos, lit_nat (1)),
+ att_item, lit_str ("")));
+
+ return (struct PFla_pair_t) { .rel = res, .frag = PFla_empty_set() };
}
/* ------------------- */
@@ -2442,22 +2458,34 @@
PFbui_fn_local_name (const PFla_op_t *loop, bool ordering,
struct PFla_pair_t *args)
{
- (void) loop; (void) ordering;
+ (void) ordering;
- return (struct PFla_pair_t) {
- .rel = project (
- fun_1to1 (
- project (args[0].rel,
- proj (att_iter, att_iter),
- proj (att_pos, att_pos),
- proj (att_item, att_item)),
- alg_fun_fn_local_name,
- att_res,
- attlist(att_item)),
- proj (att_iter, att_iter),
- proj (att_pos, att_pos),
- proj (att_item, att_res)),
- .frag = args[0].frag };
+ PFla_op_t *strings = project (
+ fun_1to1 (
+ project (args[0].rel,
+ proj (att_iter, att_iter),
+ proj (att_pos, att_pos),
+ proj (att_item, att_item)),
+ alg_fun_fn_local_name,
+ att_res,
+ attlist(att_item)),
+ proj (att_iter, att_iter),
+ proj (att_pos, att_pos),
+ proj (att_item, att_res));
+
+ PFla_op_t *res = disjunion (
+ strings,
+ attach (
+ attach (
+ difference (
+ loop,
+ project (
+ strings,
+ proj (att_iter, att_iter))),
+ att_pos, lit_nat (1)),
+ att_item, lit_str ("")));
+
+ return (struct PFla_pair_t) { .rel = res, .frag = PFla_empty_set() };
}
/* --------------------- */
@@ -2468,22 +2496,34 @@
PFbui_fn_namespace_uri (const PFla_op_t *loop, bool ordering,
struct PFla_pair_t *args)
{
- (void) loop; (void) ordering;
+ (void) ordering;
- return (struct PFla_pair_t) {
- .rel = project (
- fun_1to1 (
- project (args[0].rel,
- proj (att_iter, att_iter),
- proj (att_pos, att_pos),
- proj (att_item, att_item)),
- alg_fun_fn_namespace_uri,
- att_res,
- attlist(att_item)),
- proj (att_iter, att_iter),
- proj (att_pos, att_pos),
- proj (att_item, att_res)),
- .frag = args[0].frag };
+ PFla_op_t *strings = project (
+ fun_1to1 (
+ project (args[0].rel,
+ proj (att_iter, att_iter),
+ proj (att_pos, att_pos),
+ proj (att_item, att_item)),
+ alg_fun_fn_namespace_uri,
+ att_res,
+ attlist(att_item)),
+ proj (att_iter, att_iter),
+ proj (att_pos, att_pos),
+ proj (att_item, att_res));
+
+ PFla_op_t *res = disjunion (
+ strings,
+ attach (
+ attach (
+ difference (
+ loop,
+ project (
+ strings,
+ proj (att_iter, att_iter))),
+ att_pos, lit_nat (1)),
+ att_item, lit_str ("")));
+
+ return (struct PFla_pair_t) { .rel = res, .frag = PFla_empty_set() };
}
/* --------------- */
Index: intro_rec_border.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/intro_rec_border.c,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -u -d -r1.8 -r1.8.2.1
--- intro_rec_border.c 11 Jan 2008 10:46:56 -0000 1.8
+++ intro_rec_border.c 16 Feb 2008 01:02:08 -0000 1.8.2.1
@@ -39,10 +39,8 @@
#include <assert.h>
-/* short-hands */
-#define L(p) ((p)->child[0])
-#define R(p) ((p)->child[1])
-#define LR(p) (R(L(p)))
+/* Easily access subtree-parts */
+#include "child_mnemonic.h"
#define SEEN(n) n->bit_dag
#define pfIN(n) n->bit_in
@@ -65,11 +63,6 @@
switch (n->kind)
{
- /* make sure we don't follow fragment */
- case pa_frag_union:
- case pa_empty_frag:
- return false;
-
/* ignore nested recursions and only collect the path */
case pa_rec_fix:
base_path = introduce_rec_borders_worker (L(n), bases);
@@ -123,11 +116,6 @@
introduce_rec_borders_worker (R(n), bases);
break;
- case pa_fun_frag_param:
- /* only collect the base paths */
- base_path = introduce_rec_borders_worker (R(n), bases);
- break;
-
case pa_fcns:
/* this also skips the introduction of a rec_border
operator for the content of an empty elements:
@@ -145,9 +133,7 @@
the recursion while its left child is not.
Make sure that no borders are introduced along the
fragment information edge. */
- if (base_path && L(n) && !pfIN(L(n)) &&
- L(n)->kind != pa_frag_union &&
- L(n)->kind != pa_empty_frag) {
+ if (base_path && L(n) && !pfIN(L(n))) {
L(n) = PFpa_rec_border (L(n));
L(n)->prop = L(L(n))->prop;
}
-------------------------------------------------------------------------
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