Changeset: 38b6d2c8b26d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=38b6d2c8b26d
Modified Files:
        gdk/gdk_cbp.c
        gdk/gdk_cbp.h
        gdk/gdk_col.c
        gdk/gdk_heap.c
        gdk/gdk_inspect.c
        gdk/gdk_tm.c
        gdk/gdk_value.c
Branch: headless
Log Message:

col id's can't be negative anymore: fixed a few places where they were 
potentially negated.
Also fixed the type (int vs. bat) of some variables.


diffs (truncated from 1235 to 300 lines):

diff --git a/gdk/gdk_cbp.c b/gdk/gdk_cbp.c
--- a/gdk/gdk_cbp.c
+++ b/gdk/gdk_cbp.c
@@ -290,13 +290,13 @@
 void
 CBPextend(dbl factor, int buildhash)
 {
-       int newsize;
+       bat newsize;
        size_t maxsize;
 
        /* make sure the new size is at least CBPsize large */
-       newsize = (int) (CBPlimit * factor);
+       newsize = (bat) (CBPlimit * factor);
        while (newsize < CBPsize)
-               newsize = (int) (newsize * factor);
+               newsize = (bat) (newsize * factor);
        maxsize = MAX(newsize * 2, CBPmaxsize) * sizeof(CBPrec);
 
        CBP_notrim = MT_getpid();
@@ -306,7 +306,7 @@
 
        memset(CBP + CBPlimit, 0, (newsize - CBPlimit) * sizeof(CBPrec));
        CBPlimit = newsize;
-       CBPmaxsize = (int) (maxsize / sizeof(CBPrec));
+       CBPmaxsize = (bat) (maxsize / sizeof(CBPrec));
 
        if (buildhash) {
                int i;
@@ -338,18 +338,12 @@
 static inline str
 CBPtmpname(str s, int len, bat i)
 {
-       int reverse = i < 0;
-
-       if (reverse)
-               i = -i;
        s[--len] = 0;
        while (i > 0) {
                s[--len] = '0' + (i & 7);
                i >>= 3;
        }
        s[--len] = '_';
-       if (reverse)
-               s[--len] = 'r';
        s[--len] = 'p';
        s[--len] = 'm';
        s[--len] = 't';
@@ -386,7 +380,7 @@
  * The default src=0 is to read the full CBPdir file.
  */
 static COL *
-CBPreadEntries(FILE *fp, char *src, int bbpversion, int *min_stamp, int 
*max_stamp)
+CBPreadEntries(FILE *fp, char *src, int cbpversion, int *min_stamp, int 
*max_stamp)
 {
        bat bid = 0;
        char buf[4096];
@@ -423,7 +417,7 @@
                unsigned short storage;
                int n;
 
-               if (bbpversion == GDKLIBRARY_HEADED ?
+               if (cbpversion == GDKLIBRARY_HEADED ?
                    sscanf(buf,
                           "%lld %hu %128s %128s %128s %d %u %lld %lld %lld 
%lld %lld %hu %hu %hu %hu"
                           "%n",
@@ -468,7 +462,7 @@
                bs->map_buns = (char) map_head;
                bs->map_heap = (char) map_hheap;
 
-               if (bbpversion == GDKLIBRARY_HEADED) {
+               if (cbpversion == GDKLIBRARY_HEADED) {
                        if (sscanf(buf + nread,
                                   " %10s %hu %hu %hu %lld %lld %lld %lld %lld 
%lld %lld %hu"
                                   "%n",
@@ -592,10 +586,11 @@
 }
 
 static int
-CBPheader(FILE *fp, int *CBPlimit, oid *CBPoid, int silent)
+CBPheader(FILE *fp, bat *CBPlimit, oid *CBPoid, int silent)
 {
        char buf[BUFSIZ];
-       int sz, bbpversion, ptrsize, oidsize;
+       bat sz;
+       int cbpversion, ptrsize, oidsize;
        char *s;
 
        if (fgets(buf, sizeof(buf), fp) == NULL) {
@@ -605,7 +600,7 @@
                }
                GDKfatal("CBPinit: CBP.dir is empty");
        }
-       if (sscanf(buf, "CBP.dir, GDKversion %d\n", &bbpversion) != 1) {
+       if (sscanf(buf, "CBP.dir, GDKversion %d\n", &cbpversion) != 1) {
                GDKerror("CBPinit: old CBP without version number");
                GDKerror("dump the database using a compatible version,");
                GDKerror("then restore into new database using this 
version.\n");
@@ -613,15 +608,15 @@
                        return -1;
                exit(1);
        }
-       if (bbpversion != GDKLIBRARY && bbpversion != GDKLIBRARY_HEADED) {
+       if (cbpversion != GDKLIBRARY && cbpversion != GDKLIBRARY_HEADED) {
                if (silent) {
                        GDKerror("CBPinit: incompatible CBP version: "
                                 "expected 0%o, got 0%o.",
-                                GDKLIBRARY, bbpversion);
+                                GDKLIBRARY, cbpversion);
                        return -1;
                }
                GDKfatal("CBPinit: incompatible CBP version: "
-                        "expected 0%o, got 0%o.", GDKLIBRARY, bbpversion);
+                        "expected 0%o, got 0%o.", GDKLIBRARY, cbpversion);
        }
        if (fgets(buf, sizeof(buf), fp) == NULL) {
                if (silent) {
@@ -661,12 +656,12 @@
        }
        *CBPoid = OIDread(buf);
        if ((s = strstr(buf, "CBPsize")) != NULL) {
-               sscanf(s, "CBPsize=%d", &sz);
-               sz = (int) (sz * COLMARGIN);
+               sscanf(s, "CBPsize=%u", &sz);
+               sz = (bat) (sz * COLMARGIN);
                if (sz > *CBPlimit)
                        *CBPlimit = sz;
        }
-       return bbpversion;
+       return cbpversion;
 }
 
 /*
@@ -686,39 +681,39 @@
        char *s;
        FILE *fd;
        int min_stamp = 0x7fffffff, max_stamp = 0;
-       int bbpversion;
+       int cbpversion;
        COL *bs;
-       char bbpdir[BUFSIZ];
+       char cbpdir[BUFSIZ];
        char bufhead[BUFSIZ];
        char bufhheap[BUFSIZ];
        char path[BUFSIZ];
        struct stat st;
        oid CBPoid;
-       int CBPlimit;
+       bat limit;
 
        IODEBUG mnstr_printf(GDKerr, "#importEntry %s\n", nme);
-       strcpy(bbpdir, nme);
-       s = strstr(bbpdir, COLDIR);
+       strcpy(cbpdir, nme);
+       s = strstr(cbpdir, COLDIR);
        if (s == 0)
                return 0;
        *s = 0;
        nme = s + strlen(COLDIR) + 1;
-       snprintf(path, BUFSIZ, "%s%c%s/CBP.dir", bbpdir, DIR_SEP, COLDIR);
+       snprintf(path, BUFSIZ, "%s%c%s/CBP.dir", cbpdir, DIR_SEP, COLDIR);
        fd = fopen(path, "r");
        if (fd == 0) {
-               snprintf(path, BUFSIZ, "%s%c%s%c/CBP.bak", bbpdir, DIR_SEP, 
COLDIR, DIR_SEP);
+               snprintf(path, BUFSIZ, "%s%c%s%c/CBP.bak", cbpdir, DIR_SEP, 
COLDIR, DIR_SEP);
                fd = fopen(path, "r");
                if (fd == 0) {
-                       snprintf(path, BUFSIZ, "%s%c%s%cBACKUP/CBP.dir", 
bbpdir, DIR_SEP, COLDIR, DIR_SEP);
+                       snprintf(path, BUFSIZ, "%s%c%s%cBACKUP/CBP.dir", 
cbpdir, DIR_SEP, COLDIR, DIR_SEP);
                        fd = fopen(path, "r");
                        if (fd == 0)
                                return 0;
                }
        }
 
-       if ((bbpversion = CBPheader(fd, &CBPlimit, &CBPoid, TRUE)) < 0)
+       if ((cbpversion = CBPheader(fd, &limit, &CBPoid, TRUE)) < 0)
                return 0;
-       bs = CBPreadEntries(fd, nme, bbpversion, &min_stamp, &max_stamp);
+       bs = CBPreadEntries(fd, nme, cbpversion, &min_stamp, &max_stamp);
        fclose(fd);
        if (bs == 0)
                return 0;
@@ -730,8 +725,8 @@
        CBP_lrefs(bs->cacheid)++;
 
        /* re-adjust the files to become symbolic links */
-       snprintf(bufhead, BUFSIZ, "%s%c%s%c%s.tail", bbpdir, DIR_SEP, COLDIR, 
DIR_SEP, nme);
-       snprintf(bufhheap, BUFSIZ, "%s%c%s%c%s.theap", bbpdir, DIR_SEP, COLDIR, 
DIR_SEP, nme);
+       snprintf(bufhead, BUFSIZ, "%s%c%s%c%s.tail", cbpdir, DIR_SEP, COLDIR, 
DIR_SEP, nme);
+       snprintf(bufhheap, BUFSIZ, "%s%c%s%c%s.theap", cbpdir, DIR_SEP, COLDIR, 
DIR_SEP, nme);
 
        COLmode(bs, TRANSIENT);
        bs->copiedtodisk = 1;
@@ -792,7 +787,7 @@
        struct stat st;
        int min_stamp = 0x7fffffff, max_stamp = 0;
        bat bid;
-       int bbpversion;
+       int cbpversion;
        oid CBPoid;
 
        /* first move everything from SUBDIR to BAKDIR (its parent) */
@@ -829,7 +824,7 @@
        CBPlimit = CBPINIT;
        CBPsize = 1;
 
-       bbpversion = CBPheader(fp, &CBPlimit, &CBPoid, FALSE);
+       cbpversion = CBPheader(fp, &CBPlimit, &CBPoid, FALSE);
 
        /* allocate structures: try to reserve as much space as
           possible */
@@ -851,7 +846,7 @@
        }
        memset(CBP, 0, CBPlimit * sizeof(CBPrec));
 
-       (void) CBPreadEntries(fp, 0, bbpversion, &min_stamp, &max_stamp);
+       (void) CBPreadEntries(fp, 0, cbpversion, &min_stamp, &max_stamp);
        fclose(fp);
 
        /* normalize saved LRU stamps */
@@ -960,7 +955,7 @@
  * The tail of non-used entries is reclaimed as well.
  */
 static int
-new_bbpentry(stream *s, bat i)
+new_cbpentry(stream *s, bat i)
 {
        int t;
 
@@ -1015,7 +1010,7 @@
 }
 
 static int
-CBPdir_header(stream *s, int n)
+CBPdir_header(stream *s, bat n)
 {
        if (mnstr_printf(s, "CBP.dir, GDKversion %d\n", GDKLIBRARY) < 0 ||
            mnstr_printf(s, "%d %d\n", SIZEOF_SIZE_T, SIZEOF_OID) < 0 ||
@@ -1030,10 +1025,11 @@
 {
        FILE *fp;
        stream *s = NULL;
-       bat i, j = 1;
+       bat i;
+       int j = 1;
        char buf[3000];
        char *p;
-       int n;
+       bat n;
 
        assert(subcommit != NULL);
 
@@ -1092,9 +1088,9 @@
                if (j < cnt && (n == 0 || subcommit[j] <= n || fp == NULL)) {
                        i = subcommit[j];
                        if (CBP_status(i) & mask) {
-                               if (new_bbpentry(s, i) < 0)
+                               if (new_cbpentry(s, i) < 0)
                                        goto bailout;
-                               IODEBUG new_bbpentry(GDKerr, i);
+                               IODEBUG new_cbpentry(GDKerr, i);
                        }
                        if (i == n)
                                n = 0;  /* read new entry (i.e. skip this one 
from old CBP.dir */
@@ -1160,9 +1156,9 @@
 
                /* write the entry */
                if (CBP_status(i) & mask) {
-                       if (new_bbpentry(s, i) < 0)
+                       if (new_cbpentry(s, i) < 0)
                                break;
-                       IODEBUG new_bbpentry(GDKerr, i);
+                       IODEBUG new_cbpentry(GDKerr, i);
                }
        }
 
@@ -1285,9 +1281,7 @@
 COL *
 CBPgetdesc(bat i)
 {
-       if (i < 0)
-               i = -i;
-       if (i != bat_nil && i < CBPsize && i && CBP_logical(i)) {
+       if (i != bat_nil && i < CBPsize && i > 0 && CBP_logical(i)) {
                return CBP_desc(i);
        }
        return NULL;
@@ -1299,8 +1293,6 @@
        if (buf == NULL) {
                return NULL;
        } else if (CBPcheck(bid, "CBPlogical")) {
-               if (bid < 0 && CBP_logical(bid) == NULL)
-                       bid = -bid;
                strcpy(buf, CBP_logical(bid));
        } else {
                *buf = 0;
@@ -1364,6 +1356,7 @@
        str s;
        long_str dirname;
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to