Changeset: 29eabb9f9e1f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=29eabb9f9e1f
Modified Files:
gdk/gdk.h
gdk/gdk_bbp.c
gdk/gdk_bbp.h
gdk/gdk_bbp.mx
Branch: headless
Log Message:
Did a "headless" pass through gdk_bbp, converting it to .c/.h in the process.
diffs (truncated from 3903 to 300 lines):
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -844,9 +844,8 @@
/* assert that atom width is power of 2, i.e., width == 1<<shift */
#define assert_shift_width(shift,width) assert(((shift) == 0 && (width) == 0)
|| ((unsigned)1<<(shift)) == (unsigned)(width))
-#define GDKLIBRARY_PRE_VARSHIFT 061022 /* almost compatible version,
see gdk_bbp.mx */
-#define GDKLIBRARY_PRE_VARWIDTH 061023 /* backward compatible version */
-#define GDKLIBRARY 061024
+#define GDKLIBRARY_HEADED 061024 /* BAT version (i.e. with head/tail) */
+#define GDKLIBRARY 061025
typedef struct BATiter {
COL *b;
@@ -897,10 +896,8 @@
persistence:2, /* should the COL persist on disk? */
unused:21; /* value=0 for now */
int sharecnt; /* incoming view count */
- char map_head; /* mmap mode for head bun heap */
- char map_tail; /* mmap mode for tail bun heap */
- char map_hheap; /* mmap mode for head atom heap */
- char map_theap; /* mmap mode for tail atom heap */
+ char map_buns; /* mmap mode for bun heap */
+ char map_heap; /* mmap mode for atom heap */
/* delta status administration */
BUN deleted; /* start of deleted elements */
@@ -1843,17 +1840,17 @@
gdk_export BBPrec *BBP;
/* fast defines without checks; internal use only */
-#define BBP_cache(i) BBP[ABS(i)].b
-#define BBP_logical(i) BBP[ABS(i)].nme
-#define BBP_next(i) BBP[ABS(i)].next
-#define BBP_physical(i) BBP[ABS(i)].path
-#define BBP_options(i) BBP[ABS(i)].options
-#define BBP_desc(i) BBP[ABS(i)].cache
-#define BBP_refs(i) BBP[ABS(i)].refs
-#define BBP_lrefs(i) BBP[ABS(i)].lrefs
-#define BBP_lastused(i) BBP[ABS(i)].lastused
-#define BBP_status(i) BBP[ABS(i)].status
-#define BBP_pid(i) BBP[ABS(i)].pid
+#define BBP_cache(i) BBP[i].b
+#define BBP_logical(i) BBP[i].nme
+#define BBP_next(i) BBP[i].next
+#define BBP_physical(i) BBP[i].path
+#define BBP_options(i) BBP[i].options
+#define BBP_desc(i) BBP[i].cache
+#define BBP_refs(i) BBP[i].refs
+#define BBP_lrefs(i) BBP[i].lrefs
+#define BBP_lastused(i) BBP[i].lastused
+#define BBP_status(i) BBP[i].status
+#define BBP_pid(i) BBP[i].pid
/* macros that nicely check parameters */
#define BBPdirty(x) (BBP_dirty=(x))
@@ -2533,13 +2530,12 @@
static inline bat
BBPcheck(register bat x, register const char *y)
{
+ assert(x >= 0 || x == bat_nil);
if (x && x != bat_nil) {
- register bat z = ABS(x);
-
- if (z >= BBPsize || BBP[z].nme == NULL) {
+ if (x >= BBPsize || BBP[x].nme == NULL) {
CHECKDEBUG THRprintf(GDKout, "#%s: range error %d\n",
y, (int) x);
} else {
- return z;
+ return x;
}
}
return 0;
@@ -2829,10 +2825,10 @@
#define isVIEW(x) \
(!(x)->lview && \
((x)->heap.parentid || \
- ((x)->vheap && (x)->vheap->parentid != ABS((x)->batCacheid))))
+ ((x)->vheap && (x)->vheap->parentid != (x->batCacheid))))
#define VIEWparent(x) ((x)->lview?0:(x)->heap.parentid)
-#define VIEWvhparent(x)
(((x)->lview||(x)->vheap==NULL||(x)->vheap->parentid==ABS((x)->batCacheid))?0:(x)->vheap->parentid)
+#define VIEWvparent(x)
(((x)->lview||(x)->vheap==NULL||(x)->vheap->parentid==(x->batCacheid))?0:(x)->vheap->parentid)
/* VIEWparentcol(b) tells whether the head column was inherited from the parent
* "as is". We must check whether the type was not overridden in the view.
diff --git a/gdk/gdk_bbp.mx b/gdk/gdk_bbp.c
rename from gdk/gdk_bbp.mx
rename to gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.mx
+++ b/gdk/gdk_bbp.c
@@ -1,171 +1,95 @@
-@/
-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.
-@
-
-@f gdk_bbp
-@a M. L. Kersten, P. Boncz, N. J. Nes
-@* BAT Buffer Pool (BBP)
-The BATs created and loaded are collected in a BAT buffer pool.
-The Bat Buffer Pool has a number of functions:
-@table @code
-
-@item administration and lookup
-The BBP is a directory which contains status information about all known BATs.
-This interface may be used very heavily, by data-intensive applications.
-To eliminate all overhead, read-only access to the BBP may be done by
-table-lookups. The integer index type for these lookups is @emph{bat}, as
-retrieved by @emph{BBPcacheid(b)}. The @emph{bat} zero is reserved for the nil
bat.
-
-@item persistence
-The BBP is made persistent by saving it to the dictionary file
-called @emph{BBP.dir} in the database.
-
-When the number of BATs rises, having all files in one directory
-becomes a bottleneck. The BBP therefore implements a scheme that distributes
-all BATs in a growing directory tree with at most 64 BATs stored in one node.
-
-@item buffer management
-The BBP is responsible for loading and saving of BATs to disk. It also
-contains routines to unload BATs from memory when memory resources
-get scarce. For this purpose, it administers BAT memory reference
-counts (to know which BATs can be unloaded) and BAT usage statistics
-(it unloads the least recently used BATs).
-
-@item recovery
-When the database is closed or during a run-time syncpoint, the system
-tables must be written to disk in a safe way, that is immune for system
-failures (like disk full). To do so, the BBP implements an atomic commit and
-recovery protocol: first all files to be overwritten are moved to a BACKUP/
-dir. If that succeeds, the writes are done. If that also fully succeeds
-the BACKUP/ dir is renamed to DELETE_ME/ and subsequently deleted.
-If not, all files in BACKUP/ are moved back to their original location.
-
-@item unloading
-Bats which have a logical reference (ie. a lrefs > 0) but no memory
-reference (refcnt == 0) can be unloaded. Unloading dirty bats means,
-moving the original (committed version) to the BACKUP/ dir and saving
-the bat. This complicates the commit and recovery/abort issues.
-The commit has to check if the bat is already moved. And The recovery
-has to always move back the files from the BACKUP/ dir.
-
-@item reference counting
-Bats use have two kinds of references: logical and physical (pointer) ones.
-Both are administered with the BBPincref/BBPdecref routines. For
-backward compatibility, we maintain BBPfix/BBPunfix as shorthands
-for the adjusting the pointer references.
-
-@item share counting
-Views use the heaps of there parent bats. To save guard this, the
-parent has a shared counter, which is incremented and decremented
-using BBPshare and BBPunshare. These functions make sure the
-parent is memory resident as required because of the 'pointer' sharing.
-@end table
-@{
-@h
-#ifndef _GDK_BBP_H_
-#define _GDK_BBP_H_
-
-#define BBPINIT 2048
-#define BBPMAXSIZE (1024*1024)
-
-#define BBPLOADED 1 /* set if bat in memory */
-#define BBPSWAPPED 2 /* set if dirty bat is not in memory */
-#define BBPTMP 4 /* set if non-persistent bat has image on disk
*/
-#define BBPDELETED 16 /* set if bat persistent at last commit is now
transient */
-#define BBPEXISTING 32 /* set if bat was already persistent at end of
last commit */
-#define BBPNEW 64 /* set if bat has become persistent
since last commit */
-#define BBPPERSISTENT (BBPEXISTING|BBPNEW) /* mask for currently
persistent bats */
-#define BBPSTATUS 127
-
-#define BBPUNLOADING 128 /* set while we are unloading */
-#define BBPLOADING 256 /* set while we are loading */
-#define BBPSAVING 512 /* set while we are saving */
-#define BBPRENAMED 1024 /* set when bat is renamed in this transaction
*/
-#define BBPDELETING 2048 /* set while we are deleting (special case in
module unload) */
-#define BBPUNSTABLE (BBPUNLOADING|BBPDELETING) /* set while we are
unloading */
-#define BBPWAITING (BBPUNLOADING|BBPLOADING|BBPSAVING|BBPDELETING)
-
-#define BBPTRIM_ALL (((size_t)1) << (sizeof(size_t)*8 - 2)) /* very large
positive size_t */
-#define BBPLASTUSED(x) ((x) & 0x7fffffff) /* stamp is always a positive
int */
-
-gdk_export int BBPin; /* BATs swapped into BBP */
-gdk_export int BBPout; /* BATs swapped out of BBP */
-gdk_export int BBPsize; /* current occupied size of BBP array */
-
-/* global calls */
-gdk_export void BBPinit(void);
-gdk_export bat BBPimportEntry(char *nme);
-gdk_export void BBPexit(void);
-gdk_export int BBPdir(int cnt, bat *subcommit);
-
-/* update interface */
-gdk_export void BBPclear(bat bid);
-#ifdef LIBGDK /* only used within GDK */
-extern bat BBPinsert(BATstore *bs);
-#endif
-gdk_export void BBPcacheit(BATstore *bs, int lock);
-gdk_export void BBPuncacheit(bat bid);
-gdk_export int BBPreclaim(BAT *b);
-gdk_export int BBPsave(BAT *b);
-gdk_export int BBPrename(bat bid, const char *nme);
-gdk_export BATstore *BBPrecycle(int ht, int tt, size_t cap);
-gdk_export wrd BBPrecycle_minsize(wrd);
-
-/* query interface */
-gdk_export bat BBPindex(const char *nme);
-gdk_export BAT *BBPdescriptor(bat b);
-
-/* swapping interface */
-gdk_export int BBPrecover(void);
-gdk_export int BBPsync(int cnt, bat *subcommit);
-gdk_export int BBPincref(bat b, int logical);
-gdk_export void BBPkeepref(bat i);
-gdk_export void BBPreleaseref(bat i);
-gdk_export void BBPreleaselref(bat i);
-gdk_export int BBPdecref(bat b, int logical);
-gdk_export void BBPshare(bat b);
-gdk_export void BBPunshare(bat b);
-gdk_export void BBPextend(dbl factor, int buildhash);
-
-gdk_export void BBPatom_drop(int atom);
-gdk_export void BBPatom_load(int atom);
-
-gdk_export int BBPbackup(BAT *b, bit subcommit);
-
-@
-@c
+/*
+ * 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.
+ * @
+ *
+ * @f gdk_bbp
+ * @a M. L. Kersten, P. Boncz, N. J. Nes
+ * @* BAT Buffer Pool (BBP)
+ * The BATs created and loaded are collected in a BAT buffer pool.
+ * The Bat Buffer Pool has a number of functions:
+ * @table @code
+ *
+ * @item administration and lookup
+ * The BBP is a directory which contains status information about all known
BATs.
+ * This interface may be used very heavily, by data-intensive applications.
+ * To eliminate all overhead, read-only access to the BBP may be done by
+ * table-lookups. The integer index type for these lookups is @emph{bat}, as
+ * retrieved by @emph{BBPcacheid(b)}. The @emph{bat} zero is reserved for the
nil bat.
+ *
+ * @item persistence
+ * The BBP is made persistent by saving it to the dictionary file
+ * called @emph{BBP.dir} in the database.
+ *
+ * When the number of BATs rises, having all files in one directory
+ * becomes a bottleneck. The BBP therefore implements a scheme that
distributes
+ * all BATs in a growing directory tree with at most 64 BATs stored in one
node.
+ *
+ * @item buffer management
+ * The BBP is responsible for loading and saving of BATs to disk. It also
+ * contains routines to unload BATs from memory when memory resources
+ * get scarce. For this purpose, it administers BAT memory reference
+ * counts (to know which BATs can be unloaded) and BAT usage statistics
+ * (it unloads the least recently used BATs).
+ *
+ * @item recovery
+ * When the database is closed or during a run-time syncpoint, the system
+ * tables must be written to disk in a safe way, that is immune for system
+ * failures (like disk full). To do so, the BBP implements an atomic commit and
+ * recovery protocol: first all files to be overwritten are moved to a BACKUP/
+ * dir. If that succeeds, the writes are done. If that also fully succeeds
+ * the BACKUP/ dir is renamed to DELETE_ME/ and subsequently deleted.
+ * If not, all files in BACKUP/ are moved back to their original location.
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list