Update of /cvsroot/monetdb/sql/src/backends/monet5
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv32459/src/backends/monet5

Modified Files:
      Tag: GDK-2
        sql.mx sql_result.mx sql_user.mx 
Log Message:
prepared sql for the split bats
m4/sql runs as well as before the split
m5/sql needs a bit more work (about 35 failing tests)


Index: sql_result.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_result.mx,v
retrieving revision 1.60
retrieving revision 1.60.2.1
diff -u -d -r1.60 -r1.60.2.1
--- sql_result.mx       14 Jul 2007 17:47:57 -0000      1.60
+++ sql_result.mx       12 Aug 2007 17:42:29 -0000      1.60.2.1
@@ -250,9 +250,10 @@
        BUN p, q;
        size_t max = 0;
        size_t l = 0;
+       BATiter bi = bat_iterator(b);
 
        BATloop(b, p, q) {
-               char *s = BUNtail(b, p);
+               char *s = BUNtail(bi, p);
                l = strlen(s);
 
                if (l > max)
@@ -269,9 +270,10 @@
        lng max = 0;
        lng min = 0;
        size_t ret = 0;
+       BATiter bi = bat_iterator(b);
 
        BATloop(b, p, q) {
-               @1 l = *((@1 *)BUNtail(b, p));
+               @1 l = *((@1 *)BUNtail(bi, p));
                if (l == @1_nil) l = 4;
                if (l > max) max = l;
                if (l < min) min = l;
@@ -749,6 +751,7 @@
                        break;
 
                fmt[i].c = BATdescriptor(c->b);
+               fmt[i].ci = bat_iterator(fmt[i].c);
                fmt[i].name = NULL;
                fmt[i].sep = ((i - 1) < (t->nr_cols - 1)) ? _strdup(sep) : 
_strdup(rsep);
                fmt[i].seplen = _strlen(fmt[i].sep);

Index: sql_user.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_user.mx,v
retrieving revision 1.30
retrieving revision 1.30.4.1
diff -u -d -r1.30 -r1.30.4.1
--- sql_user.mx 3 May 2007 23:41:07 -0000       1.30
+++ sql_user.mx 12 Aug 2007 17:42:29 -0000      1.30.4.1
@@ -165,7 +165,7 @@
        BBPunfix(users->batCacheid);
 
        /* yeah, I would prefer to return something different too */
-       return(p == NULL ? -1 : 1);
+       return(p == BUN_NONE ? -1 : 1);
 }
 
 str

Index: sql.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql.mx,v
retrieving revision 1.230
retrieving revision 1.230.2.1
diff -u -d -r1.230 -r1.230.2.1
--- sql.mx      1 Jul 2007 14:34:35 -0000       1.230
+++ sql.mx      12 Aug 2007 17:42:29 -0000      1.230.2.1
@@ -1044,12 +1044,12 @@
 {
        mvc *m = NULL;
        str msg = getContext(&m, NULL);
-       int xx;
        BAT *b, *r;
        BUN p,q;
        sql_schema *s = NULL;
        sql_sequence *seq = NULL;
        seqbulk *sb = NULL;
+       BATiter bi;
 
        if (msg)
                return msg;
@@ -1070,8 +1070,9 @@
                return MAL_SUCCEED;
        }
 
-       BATloopFast(b,p,q,xx){
-               str sname = BUNtail(b,BUNfirst(b));
+       bi = bat_iterator(b);
+       BATloop(b,p,q){
+               str sname = BUNtail(bi,BUNfirst(b));
                lng l;
 
                if (!s || strcmp(s->base.name, sname) != 0) {
@@ -1093,7 +1094,7 @@
                        seqbulk_destroy(sb);
                        throw(SQL, "sql.next_value", "error");
                }
-               BUNins(r, BUNhead(b,p), &l, FALSE);
+               BUNins(r, BUNhead(bi,p), &l, FALSE);
        }
        if (sb) 
                seqbulk_destroy(sb);
@@ -1283,13 +1284,15 @@
 {
        BAT *b, *bn;
        int r;
-       ptr p;
+       BUN p;
+       BATiter bni;
 
        if( (bn= BATdescriptor(*bid)) == NULL)
                throw(SQL, "sql.bind","Cannot access descriptor");
 
        p = BUNfnd(bn, *name);
-       r = *(int *) BUNtail(bn, p);
+       bni = bat_iterator(bn);
+       r = *(int *) BUNtail(bni, p);
        if( (b= BATdescriptor(r)) == NULL)
                throw(SQL, "sql.bind","Cannot access descriptor");
        BBPkeepref(*ret= b->batCacheid);
@@ -1597,7 +1600,8 @@
        if (c == 0) {
                p = ATOMnilptr(b->ttype);
        } else if (c == 1) {
-               p = BUNtail(b,BUNfirst(b));
+               BATiter bi = bat_iterator(b);
+               p = BUNtail(bi,BUNfirst(b));
        } else {
                char buf[BUFSIZ];
 
@@ -1642,12 +1646,10 @@
                return MAL_SUCCEED;
        } else if (b->tsorted&1) {
                BUN p,q;
-               int sz;
+               oid c = *(oid*)Tloc(b, BUNfirst(b)); 
 
-               oid c = *(oid*)BUNtloc(b, BUNfirst(b)); 
-               sz = BUNsize(b);
-               for(p=BUNfirst(b)+sz, q=BUNlast(b);p<q;p+=sz) {
-                       oid v = *(oid*)BUNtloc(b,p);
+               for(p=BUNfirst(b), q=BUNlast(b);p<q;p++) {
+                       oid v = *(oid*)Tloc(b,p);
                        if (v<=c) {
                                *ret = TRUE;
                                break;
@@ -1668,6 +1670,7 @@
        BAT *dst;
        hash_t (*hash)(ptr v); 
        int *r, *f;
+       BATiter bi, dsti;
 
        dst= BATnew(TYPE_void,TYPE_int, BATcount(b));
        if (!dst) {
@@ -1676,27 +1679,28 @@
        }
        BATseqbase(dst, b->hseqbase);
 
-       r = (int*)BUNtail(dst, BUNfirst(dst));
+       dsti = bat_iterator(dst);
+       bi = bat_iterator(b);
+       r = (int*)BUNtail(dsti, BUNfirst(dst));
        f = r;
        hash = BATatoms[b->ttype].atomHash;
        if (ATOMvarsized(b->ttype)) { /* ugh */
                BUN p,q;
-               int xx;
 
-               BATloopFast(b,p,q,xx){
-                       ptr v = BUNtail(b,p);
+               BATloop(b,p,q){
+                       ptr v = BUNtail(bi,p);
                        *r++ = (hash(v)) & 0xEFFFFFFF;
                }
        } else {
-               char *v = BUNtail(b,BUNfirst(b)), *e = BUNtail(b,BUNlast(b));
-               int sz = BUNsize(b);
+               char *v = BUNtail(bi,BUNfirst(b)), *e = BUNtail(bi,BUNlast(b));
+               int sz = Tsize(b);
 
                for(; v < e; v+=sz) {
                        *r++ = (hash(v)) & 0xEFFFFFFF;
                }
        }
-       dst->batBuns->free = ((r-f)*BUNsize(dst));
        BATsetcount(dst, r-f);
+       dst->T->heap.free = tailsize(dst, BATcount(dst));
        BATkey(BATmirror(dst), 0);
        dst->tsorted = 0;
 
@@ -1710,6 +1714,7 @@
 {
        BAT *b, *dst;
        hash_t (*hash)(ptr v); 
+       BATiter bi;
 
        if( (b = BATdescriptor(*bid)) == NULL ){
                throw(SQL, "bathash", "Cannot access descriptor");
@@ -1725,23 +1730,22 @@
        }
 
        hash = BATatoms[b->ttype].atomHash;
+       bi = bat_iterator(b);
        if (ATOMvarsized(b->ttype)) { /* ugh */
                BUN p,q;
-               int xx;
 
-               BATloopFast(b,p,q,xx){
-                       ptr v = BUNtail(b,p);
+               BATloop(b,p,q){
+                       ptr v = BUNtail(bi,p);
                        int h = (hash(v)) & 0xEFFFFFFF;
-                       BUNins(dst, BUNhead(b,p), &h, FALSE);
+                       BUNins(dst, BUNhead(bi,p), &h, FALSE);
                }
        } else {
                BUN p,q;
-               int xx;
 
-               BATloopFast(b,p,q,xx){
-                       ptr v = BUNtail(b,p);
+               BATloop(b,p,q){
+                       ptr v = BUNtail(bi,p);
                        int h = (hash(v)) & 0xEFFFFFFF;
-                       BUNins(dst, BUNhead(b,p), &h, FALSE);
+                       BUNins(dst, BUNhead(bi,p), &h, FALSE);
                }
        }
 


-------------------------------------------------------------------------
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-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to