Changeset: b20208d8968c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b20208d8968c
Modified Files:
        gdk/gdk.h
        gdk/gdk_bbp.c
        gdk/gdk_storage.c
        gdk/gdk_storage.h
        gdk/gdk_storage.mx
Branch: headless
Log Message:

Pass through gdk_storage.
The function COLmultiprintf (was: BATmultiprintf) needs work:
- We should decide whether it should get an option to print the index
  (was printhead argument).
- It may not be necessary to call BATmultijoin since joining is so
  much easier: just loop over the arguments in parallel and produce
  the output.  (But then again, BATmultijoin will also be very much
  simpler for this same reason.)


diffs (truncated from 1362 to 300 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1614,20 +1614,20 @@
 #define BUF_WILLNEED   3       /* Will need these pages */
 #define BUF_DONTNEED   4       /* Don't need these pages */
 
-/* Heaps that are use and hence should to be loaded by BATaccess */
+/* Heaps that are use and hence should to be loaded by COLaccess */
 #define USE_HEAP       1       /* BUNs & string heap */
 #define USE_HASH       4       /* hash index */
 #define USE_ALL        (USE_HEAP|USE_HASH)
 
-gdk_export COL *BATload(const char *nme);
-gdk_export COL *BATload_intern(bat bid, int lock);
-#define BATaccessBegin(b,what,advice) BATaccess(b,what,advice,1)
-#define BATaccessEnd(b,what,advice) BATaccess(b,what,advice,-1)
-gdk_export size_t BATaccess(COL *b, int what, int advice, int load);
-gdk_export COL *BATsave(COL *b);
+gdk_export COL *COLload(const char *nme);
+gdk_export COL *COLload_intern(bat bid, int lock);
+#define BATaccessBegin(b,what,advice) COLaccess(b,what,advice,1)
+#define BATaccessEnd(b,what,advice) COLaccess(b,what,advice,-1)
+gdk_export size_t COLaccess(COL *b, int what, int advice, int load);
+gdk_export COL *COLsave(COL *b);
 gdk_export int BATmmap(COL *b, int b, int h, int force);
 gdk_export int BATmadvise(COL *b, int b, int h);
-gdk_export int BATdelete(COL *b);
+gdk_export int COLdelete(COL *b);
 gdk_export size_t BATvmsize(COL *b, int dirty);
 gdk_export size_t BATmemsize(COL *b, int dirty);
 
@@ -1665,9 +1665,9 @@
  * over them, and prints the multi-column result on the file.
  * 
  */
-gdk_export int BATprint(COL *b);
-gdk_export int BATprintf(stream *f, COL *b);
-gdk_export int BATmultiprintf(stream *f, int argc, COL *argv[], int printoid, 
int order, int printorderby);
+gdk_export int COLprint(COL *b);
+gdk_export int COLprintf(stream *f, COL *b);
+gdk_export int COLmultiprintf(stream *f, int argc, COL *argv[], int printoid, 
int order, int printorderby);
 
 /*
  * 
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -2089,7 +2089,7 @@
                        ret = BBPbackup(b, FALSE);
                if (ret == 0) {
                        BBPout++;
-                       ret = (BATsave(b) == NULL);
+                       ret = (COLsave(b) == NULL);
                }
                /* clearing bits can be done without the lock */
                BBP_status_off(bid, BBPSAVING, "BBPsave");
@@ -2882,7 +2882,7 @@
        /* only cache simple non-saved non-renamed transient bats */
        if (batcache_maxbuckets == 0 || b->batCopiedtodisk || b->heap.storage 
!= STORE_MEM || b->lview || BBPtmpcheck(s) == 0 || (b->type == TYPE_str && 
b->width > 1) || b->type > TYPE_str || VIEWvparent(b)) {
                BATDEBUG THRprintf(GDKout, "#BBPaddtobin %d " BUNFMT " %d 
N1\n", b->type, b->capacity, bin);
-               BATdelete(b);   /* handles persistent case also (file deletes) 
*/
+               COLdelete(b);   /* handles persistent case also (file deletes) 
*/
                return 1;
        }
        if (hp == 0 && b->type) {
@@ -2890,7 +2890,7 @@
                /* bat should be of the right size, types and BUN layout */
                if (b->capacity > (BUN) BATTINY * batcache_maxbuckets || 
(b->capacity & ((BUN) BATTINY - 1)) != 0 || BATCACHE_NOTYPE(b->type)) {
                        BATDEBUG THRprintf(GDKout, "#BBPaddtobin %d " BUNFMT " 
%d N2\n", b->type, b->capacity, bin);
-                       BATdelete(b);   /* handles persistent case also (file 
deletes) */
+                       COLdelete(b);   /* handles persistent case also (file 
deletes) */
                        return 1;
                }
        }
@@ -3339,7 +3339,7 @@
                                BAT *b = dirty_bat(&i, subcommit != NULL);
                                if (i <= 0)
                                        break;
-                               if (b != NULL && BATsave(b) == NULL)
+                               if (b != NULL && COLsave(b) == NULL)
                                        break;  /* write error */
                        }
                }
diff --git a/gdk/gdk_storage.mx b/gdk/gdk_storage.c
rename from gdk/gdk_storage.mx
rename to gdk/gdk_storage.c
--- a/gdk/gdk_storage.mx
+++ b/gdk/gdk_storage.c
@@ -1,50 +1,42 @@
-@/
-The contents of this file are subject to the MonetDB Public License
-Version 1.1 (the "License"); you may not use this file except in
-compliance with the License. You may obtain a copy of the License at
-http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
+/*
+ * The contents of this file are subject to the MonetDB Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the MonetDB Database System.
+ *
+ * The Initial Developer of the Original Code is CWI.
+ * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+ * Copyright August 2008-2011 MonetDB B.V.
+ * All Rights Reserved.
+ */
 
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
+/*
+ * @f gdk_storage
+ * @a M. L. Kersten, P. Boncz, N. Nes
+ *
+ * @* Database Storage Management
+ * Contains routines for writing and reading GDK data to and from disk.
+ * This section contains the primitives to manage the disk-based images
+ * of the BATs. It relies on the existence of a UNIX file system, including
+ * memory mapped files. Solaris and IRIX have different implementations of
+ * madvise().
+ *
+ * The current version assumes that all BATs are stored on a single disk
+ * partition. This simplistic assumption should be replaced in the near
+ * future by a multi-volume version. The intension is to use several
+ * BAT home locations.
+ * The files should be owned by the database server. Otherwise, IO operations 
are
+ * likely to fail. This is accomplished by setting the GID and UID upon
+ * system start.
+ */
 
-The Original Code is the MonetDB Database System.
-
-The Initial Developer of the Original Code is CWI.
-Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
-Copyright August 2008-2011 MonetDB B.V.
-All Rights Reserved.
-@
-
-@f gdk_storage
-@a M. L. Kersten, P. Boncz, N. Nes
-
-@* Database Storage Management
-Contains routines for writing and reading GDK data to and from disk.
-This section contains the primitives to manage the disk-based images
-of the BATs. It relies on the existence of a UNIX file system, including
-memory mapped files. Solaris and IRIX have different implementations of
-madvise().
-
-The current version assumes that all BATs are stored on a single disk
-partition. This simplistic assumption should be replaced in the near
-future by a multi-volume version. The intension is to use several
-BAT home locations.
-The files should be owned by the database server. Otherwise, IO operations are
-likely to fail. This is accomplished by setting the GID and UID upon
-system start.
-@{
-@h
-#ifndef _GDK_STORAGE_H_
-#define _GDK_STORAGE_H_
-#include "gdk.h"
-
-extern void DESCclean(BAT *);
-extern int DESCsetmodes(BAT *b);
-
-#endif /* _GDK_STORAGE_H_ */
-@c
 #include "monetdb_config.h"
 #include "gdk.h"
 #include <stdlib.h>
@@ -54,8 +46,6 @@
 #include <fcntl.h>
 #endif
 
-@
-@c
 void
 GDKfilepath(str path, const char *dir, const char *name, const char *ext)
 {
@@ -191,9 +181,9 @@
 }
 
 
-@-
-Unlink the file.
-@c
+/*
+ * Unlink the file.
+ */
 static int
 delete_file(const char *path)
 {
@@ -219,9 +209,9 @@
        return -1;
 }
 
-@-
-A move routine is overloaded to deal with extensions.
-@c
+/*
+ * A move routine is overloaded to deal with extensions.
+ */
 int
 GDKmove(const char *dir1, const char *nme1, const char *ext1, const char 
*dir2, const char *nme2, const char *ext2)
 {
@@ -243,17 +233,18 @@
        return ret;
 }
 
-@}
-@+ Save and load.
-The BAT is saved on disk in several files. The extension DESC
-denotes the descriptor, BUNs the bun heap, and HHEAP and THEAP
-the other heaps. The storage mechanism off a file can be memory mapped
-(STORE_MMAP) or malloced (STORE_MEM).
-
-These modes indicates the disk-layout and the intended mapping.
-The primary concern here is to handle STORE_MMAP and STORE_MEM.
-@{
-@c
+/*
+ * Save and load.
+ * --------------
+ *
+ * The BAT is saved on disk in several files. The extension DESC
+ * denotes the descriptor, BUNs the bun heap, and HHEAP and THEAP
+ * the other heaps. The storage mechanism off a file can be memory mapped
+ * (STORE_MMAP) or malloced (STORE_MEM).
+ * 
+ * These modes indicates the disk-layout and the intended mapping.
+ * The primary concern here is to handle STORE_MMAP and STORE_MEM.
+ */
 int
 GDKsave(const char *nme, const char *ext, void *buf, size_t size, int mode)
 {
@@ -262,18 +253,16 @@
        IODEBUG THRprintf(GDKout, "#GDKsave: name=%s, ext=%s, mode %d\n", nme, 
ext ? ext : "", mode);
 
        if (mode == STORE_MMAP) {
-@-
-@}
-Only dirty pages must be written to disk. Unchanged block will still be mapped
-on the file, reading those will be cheap.  Only the changed blocks are now
-mapped to swap space. PUSHED OUT: due to rather horrendous performance
-caused by updating the image on disk.
-
-Maybe it is better to make use of @%MT_msync()@. But then, we would need to
-bring in a backup mechanism, in which stable images of the BATs are created
-at commit-time.
-@{
-@c
+/*
+ * Only dirty pages must be written to disk. Unchanged block will still be 
mapped
+ * on the file, reading those will be cheap.  Only the changed blocks are now
+ * mapped to swap space. PUSHED OUT: due to rather horrendous performance
+ * caused by updating the image on disk.
+ * 
+ * Maybe it is better to make use of @%MT_msync()@. But then, we would need to
+ * bring in a backup mechanism, in which stable images of the BATs are created
+ * at commit-time.
+ */
                if (size)
                        err = MT_msync(buf, 0, size, MMAP_SYNC);
                if (err)
@@ -312,11 +301,11 @@
        return err;
 }
 
-@-
-Space for the load is directly allocated and the heaps are mapped.
-Further initialization of the atom heaps require a separate action
-defined in their implementation.
-@c
+/*
+ * Space for the load is directly allocated and the heaps are mapped.
+ * Further initialization of the atom heaps require a separate action
+ * defined in their implementation.
+ */
 char *
 GDKload(const char *nme, const char *ext, size_t size, size_t maxsize, int 
mode)
 {
@@ -333,8 +322,9 @@
                        ssize_t n_expected, n = 0;
 
                        if (ret) {
-                               /* read in chunks, some OSs do not give you all 
at once
-                                  and Windows only accepts int */
+                               /* read in chunks, some OSs do not
+                                  give you all at once and Windows
+                                  only accepts int */
                                for (n_expected = (ssize_t) size; n_expected > 
0; n_expected -= n) {
                                        n = read(fd, dst, (unsigned) MIN(1 << 
30, n_expected));
                                        IODEBUG THRprintf(GDKout, "#read(dst " 
PTRFMT ", n_expected " SSZFMT ", fd %d) = " SSZFMT "\n", PTRFMTCAST(void *)dst, 
n_expected, fd, n);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to