Changeset: 7872b82d5d5a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7872b82d5d5a
Modified Files:
        gdk/gdk_imprints.c
        gdk/gdk_private.h
        gdk/gdk_storage.c
        monetdb5/modules/kernel/bat5.c
Branch: default
Log Message:

Merge with Jan2014 branch.


diffs (137 lines):

diff --git a/gdk/gdk_imprints.c b/gdk/gdk_imprints.c
--- a/gdk/gdk_imprints.c
+++ b/gdk/gdk_imprints.c
@@ -551,7 +551,7 @@ BATimprints(BAT *b) {
        MT_lock_set(&GDKimprintsLock(ABS(b->batCacheid)), "BATimprints");
        if (b->T->imprints == NULL) {
                Imprints *imprints;
-               BAT *smp;
+               BAT *smp, *t;
                BUN cnt;
                str nme = BBP_physical(b->batCacheid);
 
@@ -569,8 +569,9 @@ BATimprints(BAT *b) {
 
 #define SMP_SIZE 2048
                smp = BATsample(b, SMP_SIZE);
-               smp = BATmirror(BATorder(BATmirror(smp)));
-               smp = BATmirror(BATkunique(BATmirror(smp)));
+               t = BATmirror(BATorder(BATmirror(smp)));
+               smp = BATmirror(BATkunique(BATmirror(t)));
+               BBPunfix(t->batCacheid);
                /* sample now is ordered and unique on tail */
                assert(smp->tkey && smp->tsorted);
                cnt = BATcount(smp);
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -50,9 +50,7 @@ void BBPtrim(size_t delta);
 void BBPunshare(bat b);
 void GDKclrerr(void);
 int GDKextend(const char *fn, size_t size);
-#ifndef NATIVE_WIN32
-int GDKextendf(int fd, off_t size);
-#endif
+int GDKextendf(int fd, size_t size);
 int GDKfdlocate(const char *nme, const char *mode, const char *ext);
 FILE *GDKfilelocate(const char *nme, const char *mode, const char *ext);
 char *GDKload(const char *nme, const char *ext, size_t size, size_t *maxsize, 
storage_t mode);
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -228,9 +228,8 @@ GDKmove(const char *dir1, const char *nm
        return ret;
 }
 
-#ifndef NATIVE_WIN32
 int
-GDKextendf(int fd, off_t size)
+GDKextendf(int fd, size_t size)
 {
        struct stat stb;
 
@@ -239,35 +238,31 @@ GDKextendf(int fd, off_t size)
                return -1;
        }
        /* if necessary, extend the underlying file */
-       if (stb.st_size < size)
-               return ftruncate(fd, size);
+       if (stb.st_size < (off_t) size) {
+#ifdef WIN32
+               return -(_chsize_s(fd, (__int64) size) != 0);
+#else
+               return ftruncate(fd, (off_t) size);
+#endif
+       }
        return 0;
 }
-#endif
 
 int
 GDKextend(const char *fn, size_t size)
 {
        int t0 = 0;
+       int rt = -1, fd;
 
        IODEBUG t0 = GDKms();
-#ifdef WIN32
-       {
-               int fd, rt;
-
-               if ((fd = open(fn, O_RDWR)) < 0)
-                       return -1;
-               rt = _chsize_s(fd, (__int64) size);
+       rt = -1;
+       if ((fd = open(fn, O_RDWR)) >= 0) {
+               rt = GDKextendf(fd, size);
                close(fd);
-               if (rt != 0)
-                       return -1;
        }
-#else
-       if (truncate(fn, (off_t) size) < 0)
-               return -1;
-#endif
-       IODEBUG fprintf(stderr, "#GDKextend %s " SZFMT " %dms\n", fn, size, 
GDKms() - t0);
-       return 0;
+       IODEBUG fprintf(stderr, "#GDKextend %s " SZFMT " %dms%s\n", fn, size,
+                       GDKms() - t0, rt < 0 ? " (failed)" : "");
+       return rt;
 }
 
 /*
@@ -418,7 +413,6 @@ GDKload(const char *nme, const char *ext
                }
        } else {
                char path[PATHLENGTH];
-               struct stat st;
 
                /* round up to multiple of GDK_mmap_pagesize with a
                 * minimum of one */
@@ -426,10 +420,7 @@ GDKload(const char *nme, const char *ext
                if (size == 0)
                        size = GDK_mmap_pagesize;
                GDKfilepath(path, BATDIR, nme, ext);
-               if (stat(path, &st) >= 0 &&
-                   (size <= (size_t) st.st_size ||
-                    /* mmap storage is auto-extended here */
-                    GDKextend(path, size) == 0)) {
+               if (GDKextend(path, size) == 0) {
                        int mod = MMAP_READ | MMAP_WRITE | MMAP_SEQUENTIAL | 
MMAP_SYNC;
 
                        if (mode == STORE_PRIV)
diff --git a/monetdb5/modules/kernel/bat5.c b/monetdb5/modules/kernel/bat5.c
--- a/monetdb5/modules/kernel/bat5.c
+++ b/monetdb5/modules/kernel/bat5.c
@@ -172,9 +172,9 @@ CMDinfo(BAT **ret1, BAT **ret2, BAT *b)
        BAT *bk, *bv;
        const char *mode, *accessmode;
 
-       if (!(bk = BATnew(TYPE_oid, TYPE_str, 128)))
+       if (!(bk = BATnew(TYPE_void, TYPE_str, 128)))
                return GDK_FAIL;
-       if (!(bv = BATnew(TYPE_oid, TYPE_str, 128)))
+       if (!(bv = BATnew(TYPE_void, TYPE_str, 128)))
                return GDK_FAIL;
        BATseqbase(bk,0);
        BATseqbase(bv,0);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to