Update of /cvsroot/monetdb/pathfinder/runtime
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv7215/runtime
Modified Files:
Tag: M5XQ
pf_support.mx
Log Message:
propagated changes of Wednesday Oct 14 2009 - Thursday Oct 15 2009
from the development trunk to the M5XQ branch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/10/14 - stmane: runtime/pf_support.mx,1.337
For Henning & PFtijah:
made merged_union() (and thus multi_merged_union())
also recognize and handle reverse-sortedness,
i.e., in case the leading columns of all tables
are reverse-sorted, the result wil be reverse-sorted;
in case the leading columns of all tables
are sorted, the result will be sorted.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2009/10/15 - stmane: runtime/pf_support.mx,1.338
(hopefully) fixing my yesterday's checkin of reverse-sortedt merged_union():
make sure we properly treat (cast) GDK_SORTED_REV as (bit).
(Thanks to Henning for testing!)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Index: pf_support.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/pf_support.mx,v
retrieving revision 1.333.2.3
retrieving revision 1.333.2.4
diff -u -d -r1.333.2.3 -r1.333.2.4
--- pf_support.mx 20 Jun 2009 09:49:12 -0000 1.333.2.3
+++ pf_support.mx 15 Oct 2009 14:02:58 -0000 1.333.2.4
@@ -140,7 +140,7 @@
"PARAMETERS:
Even number of BAT[oid,any] with dense heads and pairs of equal tail type;
all odd BATs must be head-aligned and all even BATs must be head-aligned;
-first two BATs must be sorted on tail values.
+first two BATs must be (reverse-)sorted on tail values.
DESCRIPTION:
Merges pairs of bats according to the order as defined by the first pair's
tails."
@(
@@ -157,7 +157,7 @@
BAT[void,BAT t[void,BAT c[VoID,any]]]:
a void-headed BAT of n void-headed BATs t such that each BAT t represents a
relational table t of m columns c, each represented by a dense-headed BAT c;
-the first column of each table must be sorted.
+the first column of each table must be (reverse-)sorted.
DESCRIPTION:
Merges the n relational tables t according to the value-order as defined by the
first columns of all tables."
@@ -6216,7 +6216,7 @@
oid hsqb[ntabs];
BUN Bcnt[ntabs], inc[2];
int t, c, var, fix, non_empty[ntabs+1];
- bit concat01 = FALSE, concat10 = FALSE, void_fix = FALSE;
+ bit concat01 = FALSE, concat10 = FALSE, void_fix = FALSE, reverse =
FALSE;
bte *w = NULL, *ww[2], *wt, *ws[2];
BUN res_count = 0, h = 0;
@@ -6232,12 +6232,26 @@
*res = NULL;
/* check arguments */
- for (t=0; t<ntabs; t++) {
- if (BATcount(b[t][0])>1 && !(BATtordered(b[t][0])&1)) {
- GDKerror("merged_union: tail of first BAT/column of
table %d must be sorted.\n", t+1);
- return GDK_FAIL;
- }
- }
+ for (t=0; t<ntabs && BATcount(b[t][0]) <= 1; t++);
+ if (t<ntabs && !(BATtordered(b[t][0])&1) && !(reverse =
(BATtordered(b[t][0]) == (bit) GDK_SORTED_REV))) {
+ GDKerror("merged_union: tail of first BAT/column of table %d
must be (reverse-)sorted.\n", t+1);
+ return GDK_FAIL;
+ }
+ if (reverse) {
+ for (; t<ntabs; t++) {
+ if (BATcount(b[t][0])>1 && !(BATtordered(b[t][0]) ==
(bit) GDK_SORTED_REV)) {
+ GDKerror("merged_union: tail of first
BAT/column of table %d must be reverse-sorted.\n", t+1);
+ return GDK_FAIL;
+ }
+ }
+ } else {
+ for (; t<ntabs; t++) {
+ if (BATcount(b[t][0])>1 && !(BATtordered(b[t][0])&1)) {
+ GDKerror("merged_union: tail of first
BAT/column of table %d must be sorted.\n", t+1);
+ return GDK_FAIL;
+ }
+ }
+ }
for (t=0; t<ntabs; t++) {
mat[t] = FALSE;
@@ -6375,21 +6389,40 @@
/* merge-union the first BATs/columns; regard and preserve tail-order */
concat01 = (cnt[0]==0 || cnt[1]==0);
concat10 = FALSE;
- if (BATtordered(src[0])&BATtordered(src[1])&1 || (BATtordered(src[0])&1
&& cnt[1]==1) || (cnt[0]==1 && BATtordered(src[1])&1) ) {
- if (!concat01) {
- concat01 =
@4_LE(b...@2(srci[0],BUNlast(src[0])-1),b...@3(srci[1],BUNfirst(src[1])),@1);
- }
- if (!concat01) {
- concat10 =
@4_LT(b...@3(srci[1],BUNlast(src[1])-1),b...@2(srci[0],BUNfirst(src[0])),@1);
- }
- }
- if (!concat01 && !concat10) {
- while ((idx[0] < cnt[0]) && (idx[1] < cnt[1])) {
-
@:merged_union_0(@1,@2,0,@4_LE(b...@2(srci[0],csr[0]),b...@3(srci[1],csr[1]),@1))@
- if (idx[0] < cnt[0]) {
-
@:merged_union_0(@1,@3,1,@4_GT(b...@2(srci[0],csr[0]),b...@3(srci[1],csr[1]),@1))@
- }
- }
+ if (reverse) {
+ if ((BATtordered(src[0]) == (bit) GDK_SORTED_REV &&
BATtordered(src[1]) == (bit) GDK_SORTED_REV) || (BATtordered(src[0]) == (bit)
GDK_SORTED_REV && cnt[1]==1) || (cnt[0]==1 && BATtordered(src[1]) == (bit)
GDK_SORTED_REV) ) {
+ if (!concat01) {
+ concat01 =
@4_GE(b...@2(srci[0],BUNlast(src[0])-1),b...@3(srci[1],BUNfirst(src[1])),@1);
+ }
+ if (!concat01) {
+ concat10 =
@4_GT(b...@3(srci[1],BUNlast(src[1])-1),b...@2(srci[0],BUNfirst(src[0])),@1);
+ }
+ }
+ if (!concat01 && !concat10) {
+ while ((idx[0] < cnt[0]) && (idx[1] < cnt[1])) {
+
@:merged_union_0(@1,@2,0,@4_GE(b...@2(srci[0],csr[0]),b...@3(srci[1],csr[1]),@1))@
+ if (idx[0] < cnt[0]) {
+
@:merged_union_0(@1,@3,1,@4_LT(b...@2(srci[0],csr[0]),b...@3(srci[1],csr[1]),@1))@
+ }
+ }
+ }
+ } else {
+ if (BATtordered(src[0])&BATtordered(src[1])&1 ||
(BATtordered(src[0])&1 && cnt[1]==1) || (cnt[0]==1 && BATtordered(src[1])&1) ) {
+ if (!concat01) {
+ concat01 =
@4_LE(b...@2(srci[0],BUNlast(src[0])-1),b...@3(srci[1],BUNfirst(src[1])),@1);
+ }
+ if (!concat01) {
+ concat10 =
@4_LT(b...@3(srci[1],BUNlast(src[1])-1),b...@2(srci[0],BUNfirst(src[0])),@1);
+ }
+ }
+ if (!concat01 && !concat10) {
+ while ((idx[0] < cnt[0]) && (idx[1] < cnt[1])) {
+
@:merged_union_0(@1,@2,0,@4_LE(b...@2(srci[0],csr[0]),b...@3(srci[1],csr[1]),@1))@
+ if (idx[0] < cnt[0]) {
+
@:merged_union_0(@1,@3,1,@4_GT(b...@2(srci[0],csr[0]),b...@3(srci[1],csr[1]),@1))@
+ }
+ }
+ }
}
/* get remaining BUNs */
if (!concat10) {
@@ -6461,7 +6494,7 @@
BATsetcount(tgt, (dst[0] - BUNfirst(tgt)));
if (!tgt->batDirty) tgt->batDirty = TRUE;
BATkey(BATmirror(tgt),FALSE);
- tgt->tsorted = GDK_SORTED;
+ tgt->tsorted = (reverse ? (bit) GDK_SORTED_REV : GDK_SORTED);
tgt->tdense = FALSE;
if (void_fix) {
BBPunfix(src[0]->batCacheid);
@@ -6574,7 +6607,10 @@
BATkey(bn[c],TRUE);
BATkey(BATmirror(bn[c]),(res_count < 2));
bn[c]->hsorted = GDK_SORTED;
- if (c == 0 || res_count < 2) {
+ if (c == 0) {
+ bn[c]->tsorted = (reverse ? (bit) GDK_SORTED_REV :
GDK_SORTED);
+ } else
+ if (res_count < 2) {
bn[c]->tsorted = GDK_SORTED;
} else
if (non_empty[ntabs] == 1) {
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins