Update of /cvsroot/monetdb/MonetDB/src/gdk
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv29837/src/gdk
Modified Files:
gdk_batop.mx
Log Message:
made BATconst slightly faster, we don't copy the head if the bat is restricted.
Simply create a bat[void,tailtype] bn and return a VIEW (b,bn) (b input)
Index: gdk_batop.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB/src/gdk/gdk_batop.mx,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -d -r1.144 -r1.145
--- gdk_batop.mx 14 Nov 2007 12:40:55 -0000 1.144
+++ gdk_batop.mx 11 Dec 2007 17:36:14 -0000 1.145
@@ -2318,26 +2318,66 @@
BAT *
BATconst(BAT *b, int tailtype, ptr v)
{
- BAT *bn;
+ BAT *bn = NULL;
BUN p, q, r;
- size_t hs, ts;
+ size_t hs, ts, cnt = BATcount(b);
BATiter bi = bat_iterator(b);
BATcheck(b, "BATconst");
- if (BAThrestricted(b) == BAT_READ && tailtype == TYPE_void) {
- oid seqbase = (tailtype == TYPE_void) ? oid_nil : *(oid *) v;
+ if (BAThrestricted(b) == BAT_READ && !ATOMvarsized(tailtype)) {
+ if (tailtype == TYPE_void) {
+ oid seqbase = oid_nil;
- bn = VIEWhead(b);
- BATseqbase(BATmirror(bn), seqbase);
- return bn;
+ bn = VIEWhead(b);
+ BATseqbase(BATmirror(bn), seqbase);
+ return bn;
+ } else {
+ BAT *bt = BATnew(TYPE_void, tailtype, cnt);
+
+ if (!bt)
+ return NULL;
+ ts = Tsize(bt);
+ switch(ATOMsize(ATOMstorage(tailtype))) {
+ case 1: {
+ bte *d = (bte*)Tloc(bt, BUNfirst(bt)), V =
*(bte*)v;
+ for(r=0; r<cnt; r++)
+ d[r] = V;
+ BATsetcount(bt, cnt);
+ } break;
+ case 2: {
+ sht *d = (sht*)Tloc(bt, BUNfirst(bt)), V =
*(sht*)v;
+ for(r=0; r<cnt; r++)
+ d[r] = V;
+ BATsetcount(bt, cnt);
+ } break;
+ case 4: {
+ int *d = (int*)Tloc(bt, BUNfirst(bt)), V =
*(int*)v;
+ for(r=0; r<cnt; r++)
+ d[r] = V;
+ BATsetcount(bt, cnt);
+ } break;
+ case 8: {
+ lng *d = (lng*)Tloc(bt, BUNfirst(bt)), V =
*(lng*)v;
+ for(r=0; r<cnt; r++)
+ d[r] = V;
+ BATsetcount(bt, cnt);
+ } break;
+ default:
+ for(r=BUNfirst(bt), cnt+=r; r<cnt; r++)
+ bunfastins_nocheck(bt, r, NULL, v, 0,
ts);
+ }
+ bt->tsorted = GDK_SORTED;
+ bn = VIEWcreate(b, bt);
+ BBPunfix(bt->batCacheid);
+ return bn;
+ }
}
if (tailtype == TYPE_bat) {
v = &((BAT *) v)->batCacheid;
}
bn = BATnew(b->htype, tailtype, BATcount(b));
- if (bn == NULL) {
+ if (bn == NULL)
return bn;
- }
r = BUNfirst(bn);
hs = Hsize(bn);
ts = Tsize(bn);
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins