Update of /cvsroot/monetdb/pathfinder/compiler/algebra/prop
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv29987/algebra/prop
Modified Files:
prop_card.c prop_composite_key.c prop_const.c prop_dom.c
prop_dom_nat.c prop_guide.c prop_icol.c prop_key.c
prop_level.c prop_ocol.c prop_ori_names.c prop_rec_delta.c
prop_reqval.c prop_set.c prop_trace_names.c prop_unq_names.c
Log Message:
-- Re-organized our set of numbering operators. We have now 4 different
operators with consistent semantics that cope with sorting and numbering:
- la_rownum behaves exactly like SQLs ROW_NUMBER. It is used to generate
position values.
- la_rowrank behaves exactly like SQLs DENSE_RANK. It is used to generate
the group by semantics of our functional source language. Up til now
we only need the unpartitioned variant. (In MIL it is implemented
using the sort extend.)
- la_rank -- beside one exception -- behaves like la_rowrank. It is also
implemented in our SQL compilation with a DENSE_RANK operation. la_rank's
important difference to la_rowrank is that its resulting values are used
solely for ordering. No operation should ever look at the generated
values.
While this difference is uninteresting in the resulting code it
simplifies
the algebraic optimizer a lot. Instead of repeatedly inferring a property
that checks for column usage we can optimize based on the operator kind.
- la_rowid generates unrepeatable unique numbers (as 'ROW_NUMBER() OVER ()'
does in SQL or 'mark()' does in MIL). It is used to generate a new key
column for mapping joins.
In comparison to the old version we introduced a new operator la_rowrank,
changed the semantic of la_rank from ROW_NUMBER to DENSE_RANK, and renamed
the formular la_number operator into la_rowid.
To implement positions in our Core to Algebra translation consistently we
now use only la_rownum (to generate real position values),
la_rank (to represent intermediate position order), and constant values
(to represent unordered sequences).
-- Introduced new SQL operator DENSE_RANK.
-- Splitted up the physical pa_number operator into the 3 operators:
pa_mark, pa_rank, and pa_mark_grp. The first and the last operator correspond
to the respective MIL primitives. The result column of pa_rank is generated
by the extend column of a CTrefine operation.
-- Added check for environment variable PF_DEBUG_PRINT_FRAG to disable the
fragment printing in the AT&T dot output of the logical algebra.
Index: prop_unq_names.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_unq_names.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- prop_unq_names.c 7 Nov 2007 22:00:42 -0000 1.23
+++ prop_unq_names.c 6 Dec 2007 08:42:33 -0000 1.24
@@ -421,18 +421,15 @@
break;
case la_rownum:
- bulk_add_name_pairs (np_list, L(n));
- new_name_pair (np_list, n->sem.rownum.res, id++);
- break;
-
+ case la_rowrank:
case la_rank:
bulk_add_name_pairs (np_list, L(n));
- new_name_pair (np_list, n->sem.rank.res, id++);
+ new_name_pair (np_list, n->sem.sort.res, id++);
break;
- case la_number:
+ case la_rowid:
bulk_add_name_pairs (np_list, L(n));
- new_name_pair (np_list, n->sem.number.res, id++);
+ new_name_pair (np_list, n->sem.rowid.res, id++);
break;
case la_type:
Index: prop_ocol.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_ocol.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- prop_ocol.c 20 Nov 2007 16:57:25 -0000 1.38
+++ prop_ocol.c 6 Dec 2007 08:42:32 -0000 1.39
@@ -614,22 +614,17 @@
break;
case la_rownum:
- ocols (n) = copy_ocols (ocols (L(n)), ocols_count (L(n)) + 1);
- ocol_at (n, ocols_count (n)).name = n->sem.rownum.res;
- ocol_at (n, ocols_count (n)).type = aat_nat;
- ocols_count (n)++;
- break;
-
+ case la_rowrank:
case la_rank:
ocols (n) = copy_ocols (ocols (L(n)), ocols_count (L(n)) + 1);
- ocol_at (n, ocols_count (n)).name = n->sem.rank.res;
+ ocol_at (n, ocols_count (n)).name = n->sem.sort.res;
ocol_at (n, ocols_count (n)).type = aat_nat;
ocols_count (n)++;
break;
- case la_number:
+ case la_rowid:
ocols (n) = copy_ocols (ocols (L(n)), ocols_count (L(n)) + 1);
- ocol_at (n, ocols_count (n)).name = n->sem.number.res;
+ ocol_at (n, ocols_count (n)).name = n->sem.rowid.res;
ocol_at (n, ocols_count (n)).type = aat_nat;
ocols_count (n)++;
break;
Index: prop_const.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_const.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- prop_const.c 7 Nov 2007 22:00:43 -0000 1.30
+++ prop_const.c 6 Dec 2007 08:42:29 -0000 1.31
@@ -257,8 +257,9 @@
case la_bool_or:
case la_bool_not:
case la_rownum:
+ case la_rowrank:
case la_rank:
- case la_number:
+ case la_rowid:
case la_type:
case la_type_assert:
case la_cast:
@@ -708,8 +709,9 @@
Leave it out as it isn't a common case */
case la_fun_1to1:
case la_rownum:
+ case la_rowrank:
case la_rank:
- case la_number:
+ case la_rowid:
case la_type_assert:
case la_step_join:
case la_guide_step_join:
Index: prop_reqval.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_reqval.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- prop_reqval.c 7 Nov 2007 22:00:43 -0000 1.28
+++ prop_reqval.c 6 Dec 2007 08:42:33 -0000 1.29
@@ -219,9 +219,10 @@
case la_pos_select:
case la_distinct:
- case la_rownum: /* in rownum, rank, and number */
- case la_rank: /* type of res is != boolean and */
- case la_number: /* therefore never needs to be removed */
+ case la_rownum: /* for rownum, rowrank, rank, and rowid */
+ case la_rowrank: /* type of res is != boolean and */
+ case la_rank: /* therefore never needs to be removed */
+ case la_rowid:
case la_type_assert:
case la_roots:
case la_proxy:
Index: prop_set.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_set.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- prop_set.c 7 Nov 2007 22:00:43 -0000 1.15
+++ prop_set.c 6 Dec 2007 08:42:33 -0000 1.16
@@ -104,8 +104,7 @@
case la_sum:
case la_count:
case la_rownum:
- case la_rank:
- case la_number:
+ case la_rowid:
case la_twig:
case la_docnode:
case la_attribute:
@@ -129,6 +128,8 @@
case la_bool_and:
case la_bool_or:
case la_bool_not:
+ case la_rowrank:
+ case la_rank:
case la_type:
case la_cast:
case la_type_assert:
Index: prop_icol.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_icol.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- prop_icol.c 7 Nov 2007 22:00:43 -0000 1.25
+++ prop_icol.c 6 Dec 2007 08:42:31 -0000 1.26
@@ -436,52 +436,32 @@
break;
case la_rownum:
+ case la_rowrank:
+ case la_rank:
n->prop->l_icols = n->prop->icols;
/* do not infer input columns if operator is not required */
- if (!(n->prop->icols & n->sem.rownum.res))
+ if (!(n->prop->icols & n->sem.sort.res))
break;
- n->prop->l_icols = diff (n->prop->l_icols, n->sem.rownum.res);
+ n->prop->l_icols = diff (n->prop->l_icols, n->sem.sort.res);
for (unsigned int i = 0;
- i < PFord_count (n->sem.rownum.sortby);
+ i < PFord_count (n->sem.sort.sortby);
i++)
n->prop->l_icols = union_ (n->prop->l_icols,
PFord_order_col_at (
- n->sem.rownum.sortby, i));
+ n->sem.sort.sortby, i));
/* only infer part if available */
- if (n->sem.rownum.part != att_NULL)
- n->prop->l_icols = union_ (n->prop->l_icols,
- n->sem.rownum.part);
- break;
-
- case la_rank:
- n->prop->l_icols = n->prop->icols;
-
- /* do not infer input columns if operator is not required */
- if (!(n->prop->icols & n->sem.rank.res))
- break;
-
- n->prop->l_icols = diff (n->prop->l_icols, n->sem.rank.res);
-
- for (unsigned int i = 0;
- i < PFord_count (n->sem.rank.sortby);
- i++)
+ if (n->sem.sort.part != att_NULL)
n->prop->l_icols = union_ (n->prop->l_icols,
- PFord_order_col_at (
- n->sem.rank.sortby, i));
+ n->sem.sort.part);
break;
- case la_number:
+ case la_rowid:
n->prop->l_icols = n->prop->icols;
-
- /* do not infer input columns if operator is not required */
- if (!(n->prop->icols & n->sem.number.res))
- break;
-
- n->prop->l_icols = diff (n->prop->l_icols, n->sem.number.res);
+ n->prop->l_icols = diff (n->prop->l_icols, n->sem.rowid.res);
break;
case la_type:
Index: prop_rec_delta.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_rec_delta.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- prop_rec_delta.c 7 Nov 2007 22:00:43 -0000 1.14
+++ prop_rec_delta.c 6 Dec 2007 08:42:33 -0000 1.15
@@ -254,16 +254,7 @@
break;
case la_rownum:
- ITER (n) = ITER (L(n));
- POS (n) = POS (L(n));
- INNER(n) = INNER(L(n));
-
- /* a numbering partitioned by ITER indicates a new sequence
- order -- we thus add new position column */
- if (n->sem.rownum.part && ITER(n) & n->sem.rownum.part)
- POS(n) |= n->sem.rownum.res;
- break;
-
+ case la_rowrank:
case la_rank:
ITER (n) = ITER (L(n));
POS (n) = POS (L(n));
@@ -272,10 +263,10 @@
/* a numbering indicates a new sequence
order -- we thus add new position column */
if (ITER(n))
- POS(n) |= n->sem.rank.res;
+ POS(n) |= n->sem.sort.res;
break;
- case la_number:
+ case la_rowid:
ITER (n) = ITER (L(n));
POS (n) = POS (L(n));
INNER(n) = INNER(L(n));
@@ -286,7 +277,7 @@
use the cardinality to generate new nodes */
if ((ITER(L(n)) & att_iter ||
INNER(L(n)) & att_iter) &&
- n->sem.number.res == att_inner)
+ n->sem.rowid.res == att_inner)
INNER(n) |= att_inner;
break;
Index: prop_level.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_level.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- prop_level.c 7 Nov 2007 22:00:43 -0000 1.7
+++ prop_level.c 6 Dec 2007 08:42:31 -0000 1.8
@@ -162,8 +162,9 @@
case la_bool_or:
case la_bool_not:
case la_rownum:
+ case la_rowrank:
case la_rank:
- case la_number:
+ case la_rowid:
case la_type:
case la_type_assert:
case la_cast:
Index: prop_dom_nat.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_dom_nat.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- prop_dom_nat.c 7 Nov 2007 22:00:43 -0000 1.10
+++ prop_dom_nat.c 6 Dec 2007 08:42:30 -0000 1.11
@@ -702,18 +702,15 @@
break;
case la_rownum:
- bulk_add_dom (n->prop, L(n));
- add_dom (n->prop, n->sem.rownum.res, id++);
- break;
-
+ case la_rowrank:
case la_rank:
bulk_add_dom (n->prop, L(n));
- add_dom (n->prop, n->sem.rank.res, id++);
+ add_dom (n->prop, n->sem.sort.res, id++);
break;
- case la_number:
+ case la_rowid:
bulk_add_dom (n->prop, L(n));
- add_dom (n->prop, n->sem.number.res, id++);
+ add_dom (n->prop, n->sem.rowid.res, id++);
break;
case la_step:
Index: prop_trace_names.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_trace_names.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- prop_trace_names.c 7 Nov 2007 22:00:42 -0000 1.9
+++ prop_trace_names.c 6 Dec 2007 08:42:33 -0000 1.10
@@ -223,15 +223,13 @@
break;
case la_rownum:
- diff_np (np_list, n->sem.rownum.res);
- break;
-
+ case la_rowrank:
case la_rank:
- diff_np (np_list, n->sem.rank.res);
+ diff_np (np_list, n->sem.sort.res);
break;
- case la_number:
- diff_np (np_list, n->sem.number.res);
+ case la_rowid:
+ diff_np (np_list, n->sem.rowid.res);
break;
case la_type:
Index: prop_key.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_key.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- prop_key.c 7 Nov 2007 22:00:43 -0000 1.31
+++ prop_key.c 6 Dec 2007 08:42:31 -0000 1.32
@@ -499,20 +499,33 @@
/* if the cardinality is equal to one
the result is key itself */
- if (PFprop_card (n->prop) == 1 || !n->sem.rownum.part)
- union_ (n->prop->keys, n->sem.rownum.res);
+ if (PFprop_card (n->prop) == 1 || !n->sem.sort.part)
+ union_ (n->prop->keys, n->sem.sort.res);
break;
+ case la_rowrank:
case la_rank:
+ {
+ PFalg_att_t cols = 0;
+ unsigned int i;
+
/* key columns are propagated */
copy (n->prop->keys, L(n)->prop->keys);
- union_ (n->prop->keys, n->sem.rank.res);
- break;
- case la_number:
+ for (i = 0; i < PFord_count (n->sem.sort.sortby); i++)
+ cols |= PFord_order_col_at (n->sem.sort.sortby, i);
+
+ for (i = 0; i < PFarray_last (L(n)->prop->keys); i++)
+ if (cols & *(PFalg_att_t *) PFarray_at (L(n)->prop->keys, i)) {
+ union_ (n->prop->keys, n->sem.sort.res);
+ break;
+ }
+ } break;
+
+ case la_rowid:
/* key columns are propagated */
copy (n->prop->keys, L(n)->prop->keys);
- union_ (n->prop->keys, n->sem.number.res);
+ union_ (n->prop->keys, n->sem.rowid.res);
break;
case la_type:
Index: prop_guide.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_guide.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- prop_guide.c 7 Nov 2007 22:00:43 -0000 1.15
+++ prop_guide.c 6 Dec 2007 08:42:30 -0000 1.16
@@ -1002,8 +1002,9 @@
case la_bool_or:
case la_bool_not:
case la_rownum:
+ case la_rowrank:
case la_rank:
- case la_number:
+ case la_rowid:
case la_type:
case la_type_assert:
case la_cast:
Index: prop_ori_names.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_ori_names.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- prop_ori_names.c 7 Nov 2007 22:00:43 -0000 1.22
+++ prop_ori_names.c 6 Dec 2007 08:42:32 -0000 1.23
@@ -437,15 +437,13 @@
break;
case la_rownum:
- diff_np (n->prop->l_name_pairs, np_list, n->sem.rownum.res);
- break;
-
+ case la_rowrank:
case la_rank:
- diff_np (n->prop->l_name_pairs, np_list, n->sem.rank.res);
+ diff_np (n->prop->l_name_pairs, np_list, n->sem.sort.res);
break;
- case la_number:
- diff_np (n->prop->l_name_pairs, np_list, n->sem.number.res);
+ case la_rowid:
+ diff_np (n->prop->l_name_pairs, np_list, n->sem.rowid.res);
break;
case la_type:
Index: prop_card.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_card.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- prop_card.c 7 Nov 2007 22:00:42 -0000 1.27
+++ prop_card.c 6 Dec 2007 08:42:28 -0000 1.28
@@ -81,8 +81,9 @@
case la_bool_or:
case la_bool_not:
case la_rownum:
+ case la_rowrank:
case la_rank:
- case la_number:
+ case la_rowid:
case la_type:
case la_type_assert:
case la_cast:
Index: prop_composite_key.c
===================================================================
RCS file:
/cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_composite_key.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- prop_composite_key.c 7 Nov 2007 22:00:43 -0000 1.7
+++ prop_composite_key.c 6 Dec 2007 08:42:29 -0000 1.8
@@ -549,20 +549,47 @@
/* if the cardinality is equal to one
the result is key itself */
- if (PFprop_card (n->prop) == 1 || !n->sem.rownum.part)
- union_ (n->prop->ckeys, n->sem.rownum.res);
+ if (PFprop_card (n->prop) == 1 || !n->sem.sort.part)
+ union_ (n->prop->ckeys, n->sem.sort.res);
+ if (n->sem.sort.part)
+ union_ (n->prop->ckeys, n->sem.sort.res | n->sem.sort.part);
break;
+ case la_rowrank:
case la_rank:
- /* composite key columns are propagated */
- copy (n->prop->ckeys, L(n)->prop->ckeys);
- union_ (n->prop->ckeys, n->sem.rank.res);
- break;
+ {
+ PFarray_t *ckeys = L(n)->prop->ckeys;
+ PFalg_att_t ckey, att;
+ PFalg_att_t cols = 0;
+ unsigned int i;
- case la_number:
+ copy (n->prop->ckeys, ckeys);
+
+ for (i = 0; i < PFord_count (n->sem.sort.sortby); i++) {
+ att = PFord_order_col_at (n->sem.sort.sortby, i);
+ /* check normal keys ... */
+ if (PFprop_key (L(n)->prop, att))
+ break;
+ cols |= att;
+ }
+ if (i < PFord_count (n->sem.sort.sortby)) {
+ union_ (n->prop->ckeys, n->sem.sort.res);
+ break;
+ }
+ /* ... and composed keys */
+ for (i = 0; i < PFarray_last (ckeys); i++) {
+ ckey = *(PFalg_att_t *) PFarray_at (ckeys, i);
+ if ((cols & ckey) == ckey) {
+ union_ (n->prop->ckeys, n->sem.sort.res);
+ break;
+ }
+ }
+ } break;
+
+ case la_rowid:
/* composite key columns are propagated */
copy (n->prop->ckeys, L(n)->prop->ckeys);
- union_ (n->prop->ckeys, n->sem.number.res);
+ union_ (n->prop->ckeys, n->sem.rowid.res);
break;
case la_type:
Index: prop_dom.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/prop/prop_dom.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- prop_dom.c 28 Nov 2007 17:05:52 -0000 1.42
+++ prop_dom.c 6 Dec 2007 08:42:29 -0000 1.43
@@ -935,18 +935,15 @@
break;
case la_rownum:
- bulk_add_dom (n->prop, L(n));
- add_dom (n->prop, n->sem.rownum.res, id++);
- break;
-
+ case la_rowrank:
case la_rank:
bulk_add_dom (n->prop, L(n));
- add_dom (n->prop, n->sem.rank.res, id++);
+ add_dom (n->prop, n->sem.sort.res, id++);
break;
- case la_number:
+ case la_rowid:
bulk_add_dom (n->prop, L(n));
- add_dom (n->prop, n->sem.number.res, id++);
+ add_dom (n->prop, n->sem.rowid.res, id++);
break;
case la_type:
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins