Update of /cvsroot/monetdb/MonetDB/src/gdk
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv17490/src/gdk
Modified Files:
Tag: GDK-2
gdk_batop.mx gdk_bbp.mx gdk_relop.mx
Log Message:
propagated changes since the creation of the GDK-2 branch (tag GDK-2_root) til
Monday Aug 13 2007
from the development trunk to the GDK-2 branch
resolved minor conflicts in src/gdk/gdk_relop.mx.
resolved major conflicts in src/gdk/gdk_batop.mx (BATordered())
(hopefully correctly)
compilation NOT tested!
Index: gdk_bbp.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB/src/gdk/gdk_bbp.mx,v
retrieving revision 1.201.2.4
retrieving revision 1.201.2.5
diff -u -d -r1.201.2.4 -r1.201.2.5
--- gdk_bbp.mx 10 Aug 2007 15:31:45 -0000 1.201.2.4
+++ gdk_bbp.mx 13 Aug 2007 22:42:38 -0000 1.201.2.5
@@ -1101,7 +1101,7 @@
THRprintf(GDKout, "#clear %d (%s)\n", (int) i, BBPname(i));
}
BBPuncacheit_(i, TRUE);
- BBP_status_set(i, 0, "BBPclear");
+ BBP_status_set(i, BBPUNLOADING, "BBPclear");
BBP_refs(i) = 0;
BBP_lrefs(i) = 0;
if (lock)
@@ -1122,6 +1122,7 @@
}
if (BBP_logical(i) != BBP[ABS(i)].bak[(i) < 0])
GDKfree(BBP_logical(i));
+ BBP_status_set(i, 0, "BBPclear");
BBP_logical(i) = NULL;
BBP_next(i) = BBP_free(idx);
BBP_free(idx) = i;
Index: gdk_relop.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB/src/gdk/gdk_relop.mx,v
retrieving revision 1.134.4.6
retrieving revision 1.134.4.7
diff -u -d -r1.134.4.6 -r1.134.4.7
--- gdk_relop.mx 11 Aug 2007 22:25:24 -0000 1.134.4.6
+++ gdk_relop.mx 13 Aug 2007 22:42:39 -0000 1.134.4.7
@@ -761,11 +761,11 @@
ALGODEBUG THRprintf(GDKout, "#BATfetchjoin: BAThvoid(l) &&
!BATtvoid(l) && BATtdense(l)\n");
@:densevoidfetchjoin(@1,@2,@3)@
} else if ((BATtordered(l)&1) || hitalways) {
- /* we did check the bounderies already above */
- ALGODEBUG THRprintf(GDKout, "#BATfetchjoin: BAThvoid(l) &&
!BATtvoid(l) && !BATtdense(l) && BATtordered(l)&1\n");
+ /* we did check the bounderies already above (BATtordered(l)&1)
or simply "trust" hitalways */
+ ALGODEBUG THRprintf(GDKout, "#BATfetchjoin: BAThvoid(l) &&
!BATtvoid(l) && !BATtdense(l) && ( BATtordered(l)&1 [== %d] || hitalways [==
%d] )\n", (int)(BATtordered(l)&1), (int)hitalways);
@:orderedvoidfetchjoin(@1,@2,@3)@
} else {
- ALGODEBUG THRprintf(GDKout, "#BATfetchjoin: BAThvoid(l) &&
!BATtvoid(l) && !BATtdense(l) && !BATtordered(l)&1\n");
+ ALGODEBUG THRprintf(GDKout, "#BATfetchjoin: BAThvoid(l) &&
!BATtvoid(l) && !BATtdense(l) && !BATtordered(l)&1 && !hitalways\n");
@:defaultvoidfetchjoin(@1,@2,@3)@
}
@c
@@ -781,7 +781,7 @@
BUN r_cur, l_cur, l_end, dst;
oid seqbase;
BAT *ret = NULL, *bn = NULL, *l_orig = l;
- int hitalways_check = 0;
+ bit hitalways_check = FALSE;
BATiter li = bat_iterator(l);
BATiter ri = bat_iterator(r);
@@ -808,19 +808,20 @@
/* not checking boundaries is very dangerous; use regression tests with
debugmask=8 first */
PROPDEBUG {
hitalways_check = hitalways;
- hitalways = 0;
+ hitalways = FALSE;
}
if (lcount == 0 || rcount == 0) {
/* below range checking do not support empty bats. so treat
them separately (easy) */
@:return_empty_join_result(l_orig,r, BATfetchjoin: |l|==0 or
|r|==0,1)@
@= return_empty_join_result
+ ALGODEBUG THRprintf(GDKout, "[EMAIL PROTECTED] => empty
result\n");
#if @4
- if (hitalways_check && lcount > 0) {
- GDKerror("BATfetchjoin(%s,%s) does not hit always
(|bn|="SZFMT" != "SZFMT"=|l|) => can't use fetchjoin.\n", BATgetId(l),
BATgetId(r), BATcount(bn), lcount);
+ if (hitalways|hitalways_check && lcount > 0) {
+ GDKerror("BATfetchjoin(%s,%s) does not hit always
(|bn|=0 != "SZFMT"=|l|) => can't use fetchjoin.\n", BATgetId(l), BATgetId(r),
lcount);
+ return NULL;
}
#endif
- ALGODEBUG THRprintf(GDKout, "[EMAIL PROTECTED] => empty
result\n");
bn = BATnew(@1->htype, @2->ttype, 0);
bn->hsorted = bn->tsorted = GDK_SORTED;
BATkey(bn, TRUE);
@@ -865,13 +866,12 @@
empty = 1;
}
}
- if (hitalways && (empty?0:BATcount(l)) < lcount) {
- GDKerror("BATfetchjoin(%s,%s) does not hit always
(|bn|=" SZFMT " != " SZFMT "=|l|) => can't use fetchjoin.\n", BATgetId(l),
BATgetId(r), empty?0:BATcount(l), lcount);
- return NULL;
- }
if (empty) {
@:return_empty_join_result(l_orig, r, BATfetchjoin:
empty,1)@
- }
+ } else if (hitalways|hitalways_check && BATcount(l) < lcount) {
+ GDKerror("BATfetchjoin(%s,%s) does not hit always
(|bn|=" SZFMT " != " SZFMT "=|l|) => can't use fetchjoin.\n", BATgetId(l),
BATgetId(r), BATcount(l), lcount);
+ return NULL;
+ }
lcount = BATcount(l);
}
ALGODEBUG THRprintf(GDKout, "#BATfetchjoin: 1\n");
@@ -919,12 +919,12 @@
@:fetchjoin_switch_lht(dense)@
} else if ((BATtordered(l) & 1) || hitalways) {
- /* we did check the boundaries already above */
- ALGODEBUG THRprintf(GDKout, "#BATfetchjoin:
!BAThvoid(l) && !BATtdense(l) && BATtordered(l)&1\n");
+ /* we did check the bounderies already above
(BATtordered(l)&1) or simply "trust" hitalways */
+ ALGODEBUG THRprintf(GDKout, "#BATfetchjoin:
!BAThvoid(l) && !BATtdense(l) && ( BATtordered(l)&1 [== %d] || hitalways [==
%d] )\n", (int)(BATtordered(l)&1), (int)hitalways);
@:fetchjoin_switch_lht(ordered)@
} else {
- ALGODEBUG THRprintf(GDKout, "#BATfetchjoin:
!BAThvoid(l) && !BATtdense(l) && !BATtordered(l)&1\n");
+ ALGODEBUG THRprintf(GDKout, "#BATfetchjoin:
!BAThvoid(l) && !BATtdense(l) && !BATtordered(l)&1 && !hitalways\n");
@:fetchjoin_switch_lht(default)@
}
@@ -1048,8 +1048,11 @@
if (BATcount(bn) == lcount) {
ALIGNsetH(bn, l); /* BAThkey(r), remember? */
} else {
- if (hitalways_check) {
+ if (hitalways|hitalways_check) {
GDKerror("BATfetchjoin(%s,%s) does not hit always
(|bn|=" SZFMT " != " SZFMT "=|l|) => can't use fetchjoin.\n", BATgetId(l),
BATgetId(r), BATcount(bn), lcount);
+ BBPreclaim(bn);
+ ret = NULL;
+ goto ready;
}
bn->hsorted = l->hsorted;
}
@@ -1067,8 +1070,7 @@
if (l != l_orig) {
BBPreclaim(l); /* was created as a temporary (slice) select on
l */
}
- ESTIDEBUG THRprintf(GDKout, "#BATfetchjoin: actual resultsize: " SZFMT
"\n", BATcount(bn));
-
+ ESTIDEBUG THRprintf(GDKout, "#BATfetchjoin: actual resultsize: " SZFMT
"\n", ret?BATcount(ret):(size_t)0);
return ret;
}
Index: gdk_batop.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB/src/gdk/gdk_batop.mx,v
retrieving revision 1.138.4.6
retrieving revision 1.138.4.7
diff -u -d -r1.138.4.6 -r1.138.4.7
--- gdk_batop.mx 11 Aug 2007 22:25:26 -0000 1.138.4.6
+++ gdk_batop.mx 13 Aug 2007 22:42:38 -0000 1.138.4.7
@@ -1364,21 +1364,72 @@
@:sort(1,,,_rev,>)@
@:sort(GDK_SORTED_REV,_REV,_rev,,<)@
[EMAIL PROTECTED] sort_tpe
[EMAIL PROTECTED] chk_order
+ /* for [tpe,void], we have fast 128-at-a-time routines */
+ if (b->hkey == 0) {
+ /* sorted and key? */
+ while (cur + 128 < end) {
+ if ([EMAIL PROTECTED]@1((@1 *) BUNhloc(bi,cur))) {
+ key = FALSE;
+ break;
+ }
+ cur += 128;
+ }
+ }
+ /* sorted? */
+ while (cur + 128 < end) {
+ if ([EMAIL PROTECTED]@1((@1 *) BUNhloc(bi,cur)))
+ break;
+ cur += 128;
+ }
+ /* finish remaining <128 tuples */
+ if (cur < end) {
+ @1 val, prv = *(@1*)BUNhloc(bi,cur);
+ cur++;
+ if (b->hkey == 0 && key) {
+ /* sorted and key? */
+ while (cur < end) {
+ val = *(@1*)BUNhloc(bi,cur);
+ if (prv @3= val) {
+ key = FALSE;
+ break;
+ }
+ prv = val;
+ cur++;
+ }
+ }
+ /* sorted? */
+ while (cur < end) {
+ val = *(@1*)BUNhloc(bi,cur);
+ if (prv @3 val) {
+ /* record negative position info */
+ b->H->[EMAIL PROTECTED] = cur;
+ return FALSE;
+ }
+ prv = val;
+ cur++;
+ }
+ }
+
[EMAIL PROTECTED] sort_key_tpe
static int
[EMAIL PROTECTED]@1(@1*__r col)
[EMAIL PROTECTED]@[EMAIL PROTECTED](@4*__r col)
{
- size_t i, r = 1;
+ int i, r = 1;
for (i = 0; i < 128; i += 4) {
- r &= (col[i + 1] @2= col[i + 0]) &
- (col[i + 2] @2= col[i + 1]) &
- (col[i + 3] @2= col[i + 2]) &
- (col[i + 4] @2= col[i + 3]);
+ r &= (col[i + 1] @2 col[i + 0]) &
+ (col[i + 2] @2 col[i + 1]) &
+ (col[i + 3] @2 col[i + 2]) &
+ (col[i + 4] @2 col[i + 3]);
}
- return r != 0;
+ return r;
}
[EMAIL PROTECTED] sort_tpe
+@:sort_key_tpe(_key,@2,@3,@1)@
+@:sort_key_tpe(,@2=,@3,@1)@
+
@= sort
@:sort_tpe(chr,@5,@3)@
@:sort_tpe(bte,@5,@3)@
@@ -1392,94 +1443,102 @@
[EMAIL PROTECTED](BAT* b)
{
size_t cnt = BATcount(b);
+ bit key = (cnt < 2);
if ((BAThordered(b) & @1) == 0 && cnt > 0) {
int (*cmp)(ptr, ptr) = BATatoms[b->htype].atomCmp;
BUN cur = BUNfirst(b);
BUN end = BUNlast(b);
BATiter bi = bat_iterator(b);
+ BUN prv = NULL;
+
+ key = TRUE;
/* we may have negative information already; this saves a scan
*/
if (b->H->[EMAIL PROTECTED] > cur && b->H->[EMAIL PROTECTED] <
end && cmp(BUNhead(bi, b->H->[EMAIL PROTECTED] - 1), BUNhead(bi, b->H->[EMAIL
PROTECTED])) @5 0) {
return FALSE;
}
+ /* for [tpe,void] bats, we have fast 128-at-a-time routines */
if (ATOMstorage(b->htype) == TYPE_chr) {
- while (cur + 128 < end) {
- if ([EMAIL PROTECTED]((chr *)BUNhloc(bi,cur)))
- break;
- cur += 128;
- }
+ @:chk_order(chr,@3,@5)@
} else if (ATOMstorage(b->htype) == TYPE_bte) {
- while (cur + 128 < end) {
- if ([EMAIL PROTECTED]((bte *)BUNhloc(bi,cur)))
- break;
- cur += 128;
- }
+ @:chk_order(bte,@3,@5)@
} else if (ATOMstorage(b->htype) == TYPE_sht) {
- while (cur + 128 < end) {
- if ([EMAIL PROTECTED]((sht *)BUNhloc(bi,cur)))
- break;
- cur += 128;
- }
+ @:chk_order(sht,@3,@5)@
} else if (ATOMstorage(b->htype) == TYPE_int) {
- while (cur + 128 < end) {
- if ([EMAIL PROTECTED]((int *)BUNhloc(bi,cur)))
- break;
- cur += 128;
- }
+ @:chk_order(int,@3,@5)@
} else if (ATOMstorage(b->htype) == TYPE_lng) {
- while (cur + 128 < end) {
- if ([EMAIL PROTECTED]((lng *)BUNhloc(bi,cur)))
- break;
- cur += 128;
- }
+ @:chk_order(lng,@3,@5)@
} else if (ATOMstorage(b->htype) == TYPE_flt) {
- while (cur + 128 < end) {
- if ([EMAIL PROTECTED]((flt *)BUNhloc(bi,cur)))
- break;
- cur += 128;
- }
+ @:chk_order(flt,@3,@5)@
} else if (ATOMstorage(b->htype) == TYPE_dbl) {
- while (cur + 128 < end) {
- if ([EMAIL PROTECTED]((dbl *)BUNhloc(bi,cur)))
- break;
- cur += 128;
- }
- }
-
- /* check sortedness tuple-by-tuple */
- if (b->hheap) {
- char *base = b->H->vheap->base;
- char *prv = base + *(((var_t *)b->H->heap.base)+ cur);
+ @:chk_order(dbl,@3,@5)@
+ } else {
+ /* check sortedness tuple-by-tuple */
+ if (b->hheap) {
+ BUN base = b->hheap->base;
+ char *base = b->H->vheap->base;
+ char *prv = base + *(((var_t
*)b->H->heap.base)+ cur);
- cur ++;
- while (cur < end) {
- char *val = base + *(((var_t
*)b->H->heap.base)+ cur);
+ cur ++;
+ if (b->hkey == 0) {
+ /* sorted and key? */
+ while (cur < end) {
+ char *val = base + *(((var_t
*)b->H->heap.base)+ cur);
- if (cmp(prv, val) @5 0) {
- /* record negative position info */
- b->H->[EMAIL PROTECTED] = cur;
- return FALSE;
+ if (cmp(prv, val) @5= 0) {
+ key = FALSE;
+ break;
+ }
+ prv = val;
+ cur++;
+ }
}
- prv = val;
- cur ++;
- }
- } else {
- BUN prv = cur;
+ /* sorted? */
+ while (cur < end) {
+ char *val = base + *(((var_t
*)b->H->heap.base)+ cur);
- cur ++;
- while (cur < end) {
- if (cmp(BUNhloc(bi,prv), BUNhloc(bi,cur)) @5 0){
- /* record negative position info */
- b->H->[EMAIL PROTECTED] = cur;
- return FALSE;
+ if (cmp(prv, val) @5 0) {
+ /* record negative position
info */
+ b->H->[EMAIL PROTECTED] = cur;
+ return FALSE;
+ }
+ prv = val;
+ cur ++;
}
- prv = cur;
+ } else {
+ BUN prv = cur;
+
cur ++;
+ if (b->hkey == 0) {
+ /* sorted and key? */
+ while (cur < end) {
+ if (cmp(BUNhloc(bi,prv),
BUNhloc(bi,cur)) @5= 0){
+ key = FALSE;
+ break;
+ }
+ prv = cur;
+ cur ++;
+ }
+ }
+ /* sorted? */
+ while (cur < end) {
+ if (cmp(BUNhloc(bi,prv),
BUNhloc(bi,cur)) @5 0){
+ /* record negative position
info */
+ b->H->[EMAIL PROTECTED] = cur;
+ return FALSE;
+ }
+ prv = cur;
+ cur ++;
+ }
}
}
}
+ if (b->hkey == 0 && key) {
+ b->batDirtydesc = TRUE;
+ BATkey(b, TRUE);
+ }
/* it is [EMAIL PROTECTED] set the properties */
if ((b->hsorted & (bit) [EMAIL PROTECTED]) == 0) {
b->batDirtydesc = TRUE;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins