Update of /cvsroot/monetdb/MonetDB5/src/modules/kernel
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12558/src/modules/kernel

Modified Files:
      Tag: MonetDB_5-2
        batcalc.mx batifthen.mx 
Log Message:
batcalc: fixed properties 
ifthen: fixed bugs in ifthenelse 
                handling of variable sized atoms and default properties


Index: batcalc.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/modules/kernel/batcalc.mx,v
retrieving revision 1.142
retrieving revision 1.142.4.1
diff -u -d -r1.142 -r1.142.4.1
--- batcalc.mx  29 Jun 2007 11:21:41 -0000      1.142
+++ batcalc.mx  19 Sep 2007 07:13:00 -0000      1.142.4.1
@@ -1072,6 +1072,7 @@
        }
        if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ); \
        *ret= bn->batCacheid;
+       BATkey(BATmirror(bn),FALSE);
        BBPkeepref(bn->batCacheid);
        BBPreleaseref(b->batCacheid);
        return MAL_SUCCEED;
@@ -1158,6 +1159,7 @@
        if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ); \
        *ret= bn->batCacheid;
        bn->tsorted = 0;
+       BATkey(BATmirror(bn),FALSE);
        BBPkeepref(bn->batCacheid);
        BBPreleaseref(b->batCacheid);
        return MAL_SUCCEED;
@@ -1215,6 +1217,7 @@
        }
 
        bn->tsorted= 0;
+       BATkey(BATmirror(bn),FALSE);
        if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ); \
        BBPkeepref(*ret= bn->batCacheid);
        BBPreleaseref(b->batCacheid);
@@ -1270,6 +1273,7 @@
        }
 
        bn->tsorted= 0;
+       BATkey(BATmirror(bn),FALSE);
        if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ); \
        BBPkeepref(*ret= bn->batCacheid);
        BBPreleaseref(b->batCacheid);
@@ -1320,6 +1324,7 @@
        }
 
        bn->tsorted= 0;
+       BATkey(BATmirror(bn),FALSE);
        BBPkeepref(*ret= bn->batCacheid);
        BBPreleaseref(b->batCacheid);
        return MAL_SUCCEED;
@@ -1354,6 +1359,7 @@
        }
 
        bn->tsorted= 0;
+       BATkey(BATmirror(bn),FALSE);
        if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ); \
        BBPkeepref(*ret= bn->batCacheid);
        BBPreleaseref(b->batCacheid);

Index: batifthen.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/modules/kernel/batifthen.mx,v
retrieving revision 1.7
retrieving revision 1.7.8.1
diff -u -d -r1.7 -r1.7.8.1
--- batifthen.mx        3 Jan 2007 12:20:21 -0000       1.7
+++ batifthen.mx        19 Sep 2007 07:13:01 -0000      1.7.8.1
@@ -89,6 +89,22 @@
     BBPkeepref(*ret);
     BBPreleaseref(b->batCacheid);
     return MAL_SUCCEED;
[EMAIL PROTECTED] resBAT
+       if (BAThvoid(b)) {
+               bn = BATnew(TYPE_oid, [EMAIL PROTECTED], BATcount(b));
+               BATseqbase(bn, b->hseqbase);
+       } else {
+               bn = BATnew(b->htype, [EMAIL PROTECTED], BATcount(b));
+       }
+       if( bn== NULL) {
+               @3
+               throw(MAL, @2, "can not create bat");
+       }
+       bn->hsorted = b->hsorted;
+       bn->tsorted = FALSE;
+       BATkey(bn, b->hkey);
+       BATkey(BATmirror(bn), FALSE);
+
 @- IfThenElse
 The conditional multiplex operations .
 @-
@@ -139,13 +155,7 @@
        size_t xx;
 
        @:getBATdescriptor(bid,b,"batcalc.ifThen")@
-       @:resultBAT(@1,"batcalc.ifThen")@
-       if( BAThvoid(b))
-               bn= BATnew(TYPE_oid,[EMAIL PROTECTED],BATcount(b));
-       else
-               bn= BATnew(b->htype,[EMAIL PROTECTED],BATcount(b));
-       if( bn == 0 )
-               throw(MAL, "batcalc.ifThen","Can not create BAT");
+       @:resBAT(@1,"batcalc.ifThen")@
        bn->hsorted= b->hsorted;
        bn->tsorted= b->tsorted;
 
@@ -162,42 +172,20 @@
 str [EMAIL PROTECTED](int *ret, int *bid, @1 *tid, @1 *eid){
        BAT *b, *bn;
        @1 nilval= (@1) @1_nil;
+       BUN p,q;
+       size_t xx;
 
        @:getBATdescriptor(bid,b,"batcalc.ifThenElse")@
-       @:resultBAT(@1,"batcalc.ifThenElse")@
-
-       if( b->htype == TYPE_void && !ATOMvarsized(b->ttype)){
-               BUN p,q;
-               @1 *o;
-               size_t xx= BUNsize(b);
-
-               o= (@1*) BUNtail(bn,BUNfirst(bn));
-               p= BUNtail(b,BUNfirst(b));
-               q= BUNtail(b,BUNlast(b));
+       @:resBAT(@1,"batcalc.ifThenElse")@
 
-               while(p<q){
-                       if( *(bit*) p== bit_nil) 
-                               *o++ = (@1) @1_nil;
-                       else if( *(bit*) p ) 
-                               *o++ = *tid;
-                       else
-                               *o++ = *eid;
-                       p += xx; 
-               }
-               (bn)->batBuns->free += BATcount(b)*sizeof(@1);
-               BATsetcount(bn, BATcount(b));
-       } else {
-               BUN p,q;
-               size_t xx;
-               BATloopFast(b, p, q, xx) {
-                       bit t = *(bit*)BUNtail(b,p);
-                       if( t== bit_nil) 
-                               BUNfastins(bn, BUNhead(b,p), (ptr) & nilval);
-                       else if( t ) 
-                               BUNfastins(bn, BUNhead(b,p), (ptr) tid);
-                       else
-                               BUNfastins(bn, BUNhead(b,p), (ptr) eid);
-               }
+       BATloopFast(b, p, q, xx) {
+               bit t = *(bit*)BUNtail(b,p);
+               if( t== bit_nil) 
+                       BUNfastins(bn, BUNhead(b,p), (ptr) & nilval);
+               else if( t ) 
+                       BUNfastins(bn, BUNhead(b,p), (ptr) tid);
+               else
+                       BUNfastins(bn, BUNhead(b,p), (ptr) eid);
        }
        @:wrapup@
 }
@@ -208,50 +196,26 @@
 {
        BAT *b, *tb, *eb, *bn;
        @1 nilval= (@1) @1_nil;
+       BUN p,q;
+       size_t xx;
 
        @:getBATdescriptor(bid,b,"batcalc.ifThenElse")@
        
@:getBATdescriptor(tid,tb,"batcalc.ifThenElse",BBPreleaseref(b->batCacheid);)@
        @:getBATdescriptor(eid,eb,"batcalc.ifThenElse", 
BBPreleaseref(b->batCacheid); BBPreleaseref(tb->batCacheid);)@
        @:chkSize(b,tb,ifThenElse)@
        @:chkSize(b,eb,ifThenElse)@
-       @:resultBAT(@1,"batcalc.ifThenElse")@
-
-       if( b->htype == TYPE_void && !ATOMvarsized(b->ttype)){
-               BUN p,q;
-               @1 *o, *t,*e;
-               size_t px = BUNsize(b);
-               size_t tx = BUNsize(tb);
-               size_t ex = BUNsize(eb);
+       @:resBAT(@1,"batcalc.ifThenElse")@
 
-               o= (@1*) BUNtail(bn,BUNfirst(bn));
-               p= BUNtail(b,BUNfirst(b));
-               q= BUNtail(b,BUNlast(b));
-               t= (@1*) BUNtail(tb,BUNfirst(tb));
-               e= (@1*) BUNtail(eb,BUNfirst(eb));
-               while(p<q){
-                       if( *(bit*) p== bit_nil) 
-                               *o++ = (@1) @1_nil;
-                       else if( *(bit*) p ) 
-                               *o++ = *t;
-                       else *o++ = *e;
-                       p+= px;  t+=tx; e+=ex;
-               }
-               (bn)->batBuns->free += BATcount(b)*sizeof(@1);
-               BATsetcount(bn, BATcount(b));
-       } else {
-               BUN p,q;
-               size_t xx;
-               BATloopFast(b, p, q, xx) {
-                       bit t = *(bit*) BUNtail(b,p);
-                       int idx = BUNindex(b, p);
+       BATloopFast(b, p, q, xx) {
+               bit t = *(bit*) BUNtail(b,p);
+               int idx = BUNindex(b, p);
 
-                       if( t== bit_nil) 
-                               BUNfastins(bn, BUNhead(b,p), (ptr) &nilval);
-                       else if( t ) 
-                               BUNfastins(bn, BUNhead(b,p), BUNtail(tb, 
BUNptr(tb, idx)));
-                       else
-                               BUNfastins(bn, BUNhead(b,p), BUNtail(eb, 
BUNptr(eb, idx)));
-               }
+               if( t== bit_nil) 
+                       BUNfastins(bn, BUNhead(b,p), (ptr) &nilval);
+               else if( t ) 
+                       BUNfastins(bn, BUNhead(b,p), BUNtail(tb, BUNptr(tb, 
idx)));
+               else
+                       BUNfastins(bn, BUNhead(b,p), BUNtail(eb, BUNptr(eb, 
idx)));
        }
        BBPreleaseref(tb->batCacheid);
        BBPreleaseref(eb->batCacheid);
@@ -264,45 +228,26 @@
 {
        BAT *b, *eb, *bn;
        @1 nilval= (@1) @1_nil;
+       BUN p,q;
+       size_t xx;
 
        @:getBATdescriptor(bid,b,"batcalc.ifThenElse")@
        @:getBATdescriptor(eid,eb,"batcalc.ifThenElse", 
BBPreleaseref(b->batCacheid);)@
        @:chkSize(b,eb,ifThenElse)@
-       @:resultBAT(@1,"batcalc.ifThenElse")@
+       @:resBAT(@1,"batcalc.ifThenElse")@
 
-       if( b->htype == TYPE_void && !ATOMvarsized(b->ttype)){
-               BUN p,q;
-               @1 *o,*e;
-               size_t px= BUNsize(b);
-               size_t ex= BUNsize(eb);
-               o= (@1*) BUNtail(bn,BUNfirst(bn));
-               p= BUNtail(b,BUNfirst(b));
-               q= BUNtail(b,BUNlast(b));
-               e= (@1*) BUNtail(eb,BUNfirst(eb));
-               while(p<q){
-                       if( *(bit*) p== bit_nil) 
-                               *o++ = (@1) @1_nil;
-                       else if( *(bit*) p ) 
-                               *o++ = *val;
-                       else *o++ = *e;
-                       p+=px;  e+=ex;
-               }
-               (bn)->batBuns->free += BATcount(b)*sizeof(@1);
-               BATsetcount(bn, BATcount(b));
-       } else {
-               BUN p,q;
-               size_t xx;
-               BATloopFast(b, p, q, xx) {
-                       bit t = *(bit*) BUNtail(b,p);
-                       int idx = BUNindex(b, p);
+       if (ATOMvarsized([EMAIL PROTECTED]))
+               val = *(@1**)val;
+       BATloopFast(b, p, q, xx) {
+               bit t = *(bit*) BUNtail(b,p);
+               int idx = BUNindex(b, p);
 
-                       if( t== bit_nil) 
-                               BUNfastins(bn, BUNhead(b,p), (ptr) &nilval);
-                       else if( t ) 
-                               BUNfastins(bn, BUNhead(b,p), (ptr) val);
-                       else
-                               BUNfastins(bn, BUNhead(b,p), BUNtail(eb, 
BUNptr(eb, idx)));
-               }
+               if( t== bit_nil) 
+                       BUNfastins(bn, BUNhead(b,p), (ptr) &nilval);
+               else if( t ) 
+                       BUNfastins(bn, BUNhead(b,p), (ptr) val);
+               else
+                       BUNfastins(bn, BUNhead(b,p), BUNtail(eb, BUNptr(eb, 
idx)));
        }
        BBPreleaseref(eb->batCacheid);
        @:wrapup@
@@ -314,45 +259,26 @@
 {
        BAT *b, *tb, *bn;
        @1 nilval= (@1) @1_nil;
+       BUN p,q;
+       size_t xx;
 
        @:getBATdescriptor(bid,b,"batcalc.ifThenElse")@
        
@:getBATdescriptor(tid,tb,"batcalc.ifThenElse",BBPreleaseref(b->batCacheid);)@
        @:chkSize(b,tb,ifThenElse)@
-       @:resultBAT(@1,"batcalc.ifThenElse")@
+       @:resBAT(@1,"batcalc.ifThenElse")@
 
-       if( b->htype == TYPE_void && !ATOMvarsized(b->ttype)){
-               BUN p,q;
-               @1 *o,*t;
-               size_t px= BUNsize(b);
-               size_t tx= BUNsize(tb);
-               o= (@1*) BUNtail(bn,BUNfirst(bn));
-               p= BUNtail(b,BUNfirst(b));
-               q= BUNtail(b,BUNlast(b));
-               t= (@1*) BUNtail(tb,BUNfirst(tb));
-               while(p<q){
-                       if( *(bit*)p== bit_nil) 
-                               *o++ = (@1) @1_nil;
-                       else if( *(bit*)p ) 
-                               *o++ = *t;
-                       else *o++ = *val;
-                       p+=px;  t+=tx; 
-               }
-               (bn)->batBuns->free += BATcount(b)*sizeof(@1);
-               BATsetcount(bn, BATcount(b));
-       } else {
-               BUN p,q;
-               size_t xx;
-               BATloopFast(b, p, q, xx) {
-                       bit t = *(bit*) BUNtail(b,p);
-                       int idx = BUNindex(b, p);
+       if (ATOMvarsized([EMAIL PROTECTED]))
+               val = *(@1**)val;
+       BATloopFast(b, p, q, xx) {
+               bit t = *(bit*) BUNtail(b,p);
+               int idx = BUNindex(b, p);
 
-                       if(  t== bit_nil) 
-                               BUNfastins(bn, BUNhead(b,p), (ptr) &nilval);
-                       else if( t ) 
-                               BUNfastins(bn, BUNhead(b,p), BUNtail(tb, 
BUNptr(tb, idx)));
-                       else
-                               BUNfastins(bn, BUNhead(b,p), val);
-               }
+               if(  t== bit_nil) 
+                       BUNfastins(bn, BUNhead(b,p), (ptr) &nilval);
+               else if( t ) 
+                       BUNfastins(bn, BUNhead(b,p), BUNtail(tb, BUNptr(tb, 
idx)));
+               else
+                       BUNfastins(bn, BUNhead(b,p), val);
        }
        BBPreleaseref(tb->batCacheid);
        @:wrapup@


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to