Update of /cvsroot/monetdb/MonetDB5/src/mal
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv32295/src/mal

Modified Files:
        mal_authorize.mx mal_debugger.mx mal_interpreter.mx 
        mal_profiler.mx 
Log Message:
Merged GDK-2 branch into development branch.

Current changes were mostly started for
fixing the void concurrency problem

As a side action, the bun/bat layout was also changed.
We now have a split head and tail. This means many of the well known
macros are changed (ie BUN{h,t}{loc,var} BUN{head,tail})

BAT iteration now needs a special struct
BATiter which can be correctly created as

BATiter bi = bat_iterator(b);


TODO
        1 some modules aren't ported (maybe be dropped as they aren't used)

        2 some more bugs to find


Next improvements which are now possible
        views based on 2 bats
        (or a bat where head is real and the tail a view (or vs))
        many more....

For a presentation about the changes, see
http://www.cwi.nl/~niels/download/gdk2.pdf


Index: mal_authorize.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_authorize.mx,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- mal_authorize.mx    16 Aug 2007 19:58:10 -0000      1.50
+++ mal_authorize.mx    4 Oct 2007 10:37:05 -0000       1.51
@@ -295,6 +295,7 @@
        BAT *b;
        BUN p, q;
        oid *id;
+       BATiter useri, passi;
 
        rethrow("checkCredentials", tmp, AUTHrequireAdminOrUser(username));
        assert(user);
@@ -305,12 +306,13 @@
                throw(INVCRED, "checkCredentials", "Invalid credentials for 
unknown user");
 
        p = BUNfnd(BATmirror(user), *username);
-       if (p == NULL) {
+       if (p == BUN_NONE) {
                /* DO NOT reveal that the user doesn't exist here! */
                throw(INVCRED, "checkCredentials", "Invalid credentials for 
user '%s'",
                                *username);
        }
-       id = (oid*)(BUNhead(user, p));
+       useri = bat_iterator(user);
+       id = (oid*)(BUNhead(useri, p));
 
        /* a NULL password is impossible (since we should be dealing with
         * hashes here) so we can bail out immediately
@@ -323,8 +325,9 @@
 
        /* find the corresponding password to the user */
        q = BUNfnd(pass, id);
-       assert (q != NULL);
-       tmp = (str)BUNtail(pass, q);
+       assert (q != BUN_NONE);
+       passi = bat_iterator(pass);
+       tmp = (str)BUNtail(passi, q);
        assert (tmp != NULL);
        /* decypher the password (we lose the original tmp here) */
        rethrow("checkCredentials", tmp, AUTHdecypherValue(&pwd, &tmp));
@@ -342,6 +345,8 @@
         */
        b = BATselect(scen, id, id);
        if (b && BATcount(b) > 0) {
+               BATiter bi = bat_iterator(b);
+
                if (*scenario == NULL || strNil(*scenario)) {
                        /* of course we DO NOT tell the exact reason here again 
*/
                        throw(INVCRED, "checkCredentials", "Invalid credentials 
for user '%s'",
@@ -350,7 +355,7 @@
 
                /* ok, there are some tuples that we have to consider */
                BATloop(b, p, q) {
-                       tmp = (str)BUNtail(b, p);
+                       tmp = (str)BUNtail(bi, p);
                        assert (tmp != NULL);
                        if (strcmp(*scenario, tmp) == 0) {
                                /* YAY!  fun!  party!  We are granted access! */
@@ -382,6 +387,7 @@
        oid *id;
        str tmp;
        str hash;
+       BATiter useri;
 
        rethrow("addUser", tmp, AUTHrequireAdmin());
        assert(user);
@@ -396,7 +402,7 @@
 
        /* ensure that the username is not already there */
        p = BUNfnd(BATmirror(user), *username);
-       if (p != NULL)
+       if (p != BUN_NONE)
                throw(MAL, "addUser", "user '%s' already exists", *username);
        
        /* we assume the BATs are still aligned */
@@ -406,8 +412,9 @@
        BUNappend(pass, hash, FALSE);   /* should always be private! */
        /* retrieve the oid of the just inserted user */
        p = BUNfnd(BATmirror(user), *username);
-       assert (p != NULL);
-       id = (oid*)(BUNhead(user, p));
+       assert (p != BUN_NONE);
+       useri = bat_iterator(user);
+       id = (oid*)(BUNhead(useri, p));
 
        if (*scenarios != bat_nil) {
                b = BATdescriptor(*scenarios);
@@ -424,9 +431,11 @@
 
                /* associate scenarios given in the BAT with the user */
                if (BATcount(b) > 0) {
+                       BATiter bi = bat_iterator(b);
+                       
                        BATloop(b, p, q) {
                                /* needs force, as sql makes a view over it */
-                               BUNins(scen, id, BUNhead(b, p), TRUE);
+                               BUNins(scen, id, BUNhead(bi, p), TRUE);
                        }
                }
        }
@@ -448,6 +457,7 @@
        BAT *b;
        oid id;
        str tmp;
+       BATiter useri;
 
        rethrow("removeUser", tmp, AUTHrequireAdmin());
        assert(user);
@@ -460,9 +470,10 @@
 
        /* ensure that the username exists */
        p = BUNfnd(BATmirror(user), *username);
-       if (p == NULL)
+       if (p == BUN_NONE)
                throw(MAL, "removeUser", "no such user: '%s'", *username);
-       id = *(oid*)(BUNhead(user, p));
+       useri = bat_iterator(user);
+       id = *(oid*)(BUNhead(useri, p));
 
        /* find the name of the administrator and see if it equals username */
        if (id == MCgetClient()->user)
@@ -490,9 +501,11 @@
  * is modified.
  */
 str
-AUTHchangeUsername(str *olduser, str *newuser) {
+AUTHchangeUsername(str *olduser, str *newuser) 
+{
        BUN p, q;
        str tmp;
+       BATiter useri;
 
        rethrow("addUser", tmp, AUTHrequireAdminOrUser(olduser));
 
@@ -504,15 +517,16 @@
 
        /* see if the olduser is valid */
        p = BUNfnd(BATmirror(user), *olduser);
-       if (p == NULL)
+       if (p == BUN_NONE)
                throw(MAL, "changeUsername", "user '%s' does not exist", 
*olduser);
        /* ... and if the newuser is not there yet */
        q = BUNfnd(BATmirror(user), *newuser);
-       if (q != NULL)
+       if (q != BUN_NONE)
                throw(MAL, "changeUsername", "user '%s' already exists", 
*newuser);
 
        /* ok, just do it! (with force, because sql makes view over it) */
-       BUNinplace(BATmirror(user), p, *newuser, BUNhead(user, p), TRUE);
+       useri = bat_iterator(user);
+       BUNinplace(BATmirror(user), p, *newuser, BUNhead(useri, p), TRUE);
        AUTHcommit();
 
        return(MAL_SUCCEED);
@@ -529,6 +543,7 @@
        str tmp;
        str hash;
        oid id;
+       BATiter passi;
 
        /* precondition checks */
        if (*oldpass == NULL || strNil(*oldpass))
@@ -539,8 +554,9 @@
        /* check the old password */
        id = MCgetClient()->user;
        p = BUNfnd(pass, &id);
-       assert(p != NULL);
-       tmp = BUNtail(pass, p);
+       assert(p != BUN_NONE);
+       passi = bat_iterator(pass);
+       tmp = BUNtail(passi, p);
        assert (tmp != NULL);
        if (strcmp(tmp, *oldpass) != 0)
                throw(INVCRED, "changePassword", "Access denied");
@@ -548,7 +564,7 @@
        /* cypher the password */
        rethrow("setPassword", tmp, AUTHcypherValue(&hash, passwd));
        /* ok, just overwrite the password field for this user */
-       BUNinplace(pass, p, BUNhead(pass, p), &hash, FALSE);
+       BUNinplace(pass, p, BUNhead(passi, p), &hash, FALSE);
        AUTHcommit();
 
        return(MAL_SUCCEED);
@@ -566,6 +582,7 @@
        str tmp;
        str hash;
        oid id;
+       BATiter useri, passi;
 
        rethrow("setPassword", tmp, AUTHrequireAdmin());
 
@@ -578,24 +595,26 @@
        id = MCgetClient()->user;
        /* find the name of the administrator and see if it equals username */
        p = BUNfnd(user, &id);
-       assert (p != NULL);
-       tmp = BUNtail(user, p);
+       assert (p != BUN_NONE);
+       useri = bat_iterator(user);
+       tmp = BUNtail(useri, p);
        assert (tmp != NULL);
        if (strcmp(tmp, *username) == 0)
                throw(INVCRED, "setPassword", "The administrator cannot set its 
own password, use changePassword instead");
 
        /* see if the user is valid */
        p = BUNfnd(BATmirror(user), *username);
-       if (p == NULL)
+       if (p == BUN_NONE)
                throw(MAL, "setPassword", "no such user '%s'", *username);
-       id = *(oid*)BUNhead(user, p);
+       id = *(oid*)BUNhead(useri, p);
 
        /* cypher the password */
        rethrow("setPassword", tmp, AUTHcypherValue(&hash, passwd));
        /* ok, just overwrite the password field for this user */
        p = BUNfnd(pass, &id);
-       assert (p != NULL);
-       BUNinplace(pass, p, BUNhead(pass, p), &hash, FALSE);
+       assert (p != BUN_NONE);
+       passi = bat_iterator(pass);
+       BUNinplace(pass, p, BUNhead(passi, p), &hash, FALSE);
        AUTHcommit();
 
        return(MAL_SUCCEED);
@@ -613,6 +632,7 @@
        str tmp;
        oid *id;
        BAT *b;
+       BATiter useri;
 
        rethrow("addScenario", tmp, AUTHrequireAdmin());
 
@@ -624,9 +644,10 @@
 
        /* see if the user is valid */
        p = BUNfnd(BATmirror(user), *username);
-       if (p == NULL)
+       if (p == BUN_NONE)
                throw(MAL, "addScenario", "user '%s' does not exist", 
*username);
-       id = (oid*)BUNhead(user, p);
+       useri = bat_iterator(user);
+       id = (oid*)BUNhead(useri, p);
 
        /* see if this scenario is not already there */
        b = BATselect(BATmirror(scen), id, id);
@@ -637,7 +658,7 @@
                throw(MAL, "addScenario", "inconsistent authorisation 
administration, scenario '%s' multiple times defined", *scenario);
 
        /* add the scenario for this user, use force as sql makes view over it 
*/
-       BUNins(scen, BUNhead(user, p), *scenario, TRUE);
+       BUNins(scen, BUNhead(useri, p), *scenario, TRUE);
        AUTHcommit();
 
        return(MAL_SUCCEED);
@@ -654,6 +675,7 @@
        BAT *b;
        oid *id;
        str tmp;
+       BATiter useri;
 
        rethrow("removeScenario", tmp, AUTHrequireAdmin());
 
@@ -665,9 +687,10 @@
 
        /* see if the user is valid */
        p = BUNfnd(BATmirror(user), *username);
-       if (p == NULL)
+       if (p == BUN_NONE)
                throw(MAL, "removeScenario", "user '%s' does not exist", 
*username);
-       id = (oid*)BUNhead(user, p);
+       useri = bat_iterator(user);
+       id = (oid*)BUNhead(useri, p);
 
        /* see if the scenario is valid for this user */
        b = BATselect(BATmirror(scen), id, id);
@@ -692,22 +715,25 @@
  * allocated buffer, it is supposed to be of size BUFSIZ.
  */
 str
-AUTHresolveUser(str *username, oid *uid) {
+AUTHresolveUser(str *username, oid *uid) 
+{
        BUN p;
+       BATiter useri;
 
        if (uid == NULL || *uid == oid_nil)
                throw(ILLARG, "resolveUser", "userid should not be nil");
        
        p = BUNfnd(user, uid);
-       if (p == NULL)
+       if (p == BUN_NONE)
                throw(MAL, "resolveUser", "No such user with id: " OIDFMT, 
*uid);
 
        assert (username != NULL);
 
+       useri = bat_iterator(user);
        if (*username == NULL) {
-               *username = GDKstrdup((str)(BUNtail(user, p)));
+               *username = GDKstrdup((str)(BUNtail(useri, p)));
        } else {
-               snprintf(*username, BUFSIZ, "%s", (str)(BUNtail(user, p)));
+               snprintf(*username, BUFSIZ, "%s", (str)(BUNtail(useri, p)));
        }
 
        return(MAL_SUCCEED);
@@ -720,15 +746,17 @@
 AUTHgetUsername(str *username) {
        BUN p;
        oid id;
+       BATiter useri;
 
        id = MCgetClient()->user;
        p = BUNfnd(user, &id);
-       if (p == NULL) {
+       if (p == BUN_NONE) {
                GDKfatal("Internal error: user id that doesn't exist: " OIDFMT,
                                MCgetClient()->user);
        }
 
-       *username = BUNtail(user, p);
+       useri = bat_iterator(user);
+       *username = BUNtail(useri, p);
        return(MAL_SUCCEED);
 }
 

Index: mal_profiler.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_profiler.mx,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -d -r1.99 -r1.100
--- mal_profiler.mx     9 Sep 2007 18:34:01 -0000       1.99
+++ mal_profiler.mx     4 Oct 2007 10:37:08 -0000       1.100
@@ -1160,18 +1160,19 @@
                        b= BATdescriptor(i);
                        if( b){
                                size += sizeof(BAT);
-                               if (!VIEWparent(b)) {
+                               if (!isVIEW(b)) {
                                        size_t cnt = BATcount(b);
 
-                                       size += cnt * BUNsize(b);
+                                       size += headsize(b,cnt);
+                                       size += tailsize(b,cnt);
                                        /* the upperbound is used for the heaps 
*/
                                        if (b->hheap)
                                                size += b->hheap->size;
                                        if (b->theap)
                                                size += b->theap->size;
-                                       if (b->hhash)
+                                       if (b->H->hash)
                                                size += sizeof(hash_t) * cnt;
-                                       if (b->thash)
+                                       if (b->T->hash)
                                                size += sizeof(hash_t) * cnt;
                                }
                                BBPunfix(i);

Index: mal_debugger.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_debugger.mx,v
retrieving revision 1.209
retrieving revision 1.210
diff -u -d -r1.209 -r1.210
--- mal_debugger.mx     14 Sep 2007 08:16:24 -0000      1.209
+++ mal_debugger.mx     4 Oct 2007 10:37:06 -0000       1.210
@@ -1719,9 +1719,12 @@
                                return;
                        }
                        p= BUNfnd(b,props);
-                       if( p) {
-                               stream_printf(f," %s\n", (str) BUNtail(b,p));
-                       } else stream_printf(f," not found\n");
+                       if (p != BUN_NONE) {
+                               BATiter bi = bat_iterator(b);
+                               stream_printf(f," %s\n", (str) BUNtail(bi,p));
+                       } else {
+                               stream_printf(f," not found\n");
+                       }
                        BBPunfix(b->batCacheid);
                }
        }
@@ -1731,14 +1734,14 @@
 The memory positions for the BATs is useful information to
 asses for memory fragmentation.
 @= heapinfo
-hp= b->@1;
+hp= @1;
 if(hp && hp->base){
-       stream_printf(GDKout,"[EMAIL PROTECTED] size=%d\n",hp->base, hp->size);}
+       stream_printf(GDKout,"[EMAIL PROTECTED] size=%d\n",hp->base, hp->size);}
 @= hashinfo
-h= b->@1;
+h= @1;
 if(h && h->mask){
-           stream_printf(GDKout,"[EMAIL PROTECTED] size=%d\n",h, sizeof(*h));
-           stream_printf(GDKout,"[EMAIL PROTECTED] size=%d\n",h->link,
+           stream_printf(GDKout,"[EMAIL PROTECTED] size=%d\n",h, sizeof(*h));
+           stream_printf(GDKout,"[EMAIL PROTECTED] size=%d\n",h->link,
                    (h->mask+h->lim+1)*sizeof(int));
 }
 @-
@@ -1786,8 +1789,8 @@
 #endif
 
                        stream_printf(GDKout, "\tdesc=%d size=%d\n", b, 
sizeof(*b));
-                       hp = b->batBuns;
-                       stream_printf(GDKout, "\tbuns=%d size=%d\n", hp->base, 
hp->size);
+                       @:heapinfo(&b->H->heap,tail)@
+                       @:heapinfo(&b->T->heap,head)@
 #ifdef HAVE_SBRK
                        if (min == 0) {
                                min = (long) b;
@@ -1799,10 +1802,10 @@
                        @:setVector(hp->base, hp->size)@
 #endif
 
-                       @:heapinfo(hheap)@
-                       @:heapinfo(theap)@
-                       @:hashinfo(hhash)@
-                       @:hashinfo(thash)@
+                       @:heapinfo(b->H->vheap,hheap)@
+                       @:heapinfo(b->T->vheap,theap)@
+                       @:hashinfo(b->H->hash,hhash)@
+                       @:hashinfo(b->T->hash,thash)@
                        BBPunfix(b->batCacheid);
                }
        return v;

Index: mal_interpreter.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_interpreter.mx,v
retrieving revision 1.200
retrieving revision 1.201
diff -u -d -r1.200 -r1.201
--- mal_interpreter.mx  28 Sep 2007 21:05:29 -0000      1.200
+++ mal_interpreter.mx  4 Oct 2007 10:37:07 -0000       1.201
@@ -1660,9 +1660,12 @@
                if( b==0) return;
                /* count it once ! */
                if( add){
-                       cntxt->vmfoot += BATcount(b) * BUNsize(b);
-               } else
-                       cntxt->vmfoot -= BATcount(b) * BUNsize(b);
+                       cntxt->vmfoot += headsize(b,BATcount(b));
+                       cntxt->vmfoot += tailsize(b,BATcount(b));
+               } else {
+                       cntxt->vmfoot -= headsize(b,BATcount(b));
+                       cntxt->vmfoot -= tailsize(b,BATcount(b));
+               }
                if( cntxt->vmfoot > cntxt->bigfoot)
                        cntxt->bigfoot= cntxt->vmfoot;
                BBPunfix(b->batCacheid);
@@ -1685,7 +1688,8 @@
        if( stk->stk[getArg(pci,i)].vtype == TYPE_bat){
                b= BATdescriptor( stk->stk[getArg(pci,i)].val.br.id);
                if( b==0) continue;
-               vol += BATcount(b) * BUNsize(b);
+               vol += headsize(b,BATcount(b));
+               vol += tailsize(b,BATcount(b));
                BBPunfix(b->batCacheid);
        }
        return vol;


-------------------------------------------------------------------------
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

Reply via email to