Changeset: 30366dbf2104 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=30366dbf2104
Added Files:
gdk/gdk_bbp.c
gdk/gdk_bbp.h
Removed Files:
gdk/gdk_bbp.mx
Modified Files:
gdk/Makefile.ag
Branch: default
Log Message:
Converted gdk_bbp.mx to .c.
diffs (truncated from 856 to 300 lines):
diff --git a/gdk/Makefile.ag b/gdk/Makefile.ag
--- a/gdk/Makefile.ag
+++ b/gdk/Makefile.ag
@@ -35,7 +35,7 @@ lib_gdk = {
gdk_scanselect_defs_fix.mx \
gdk_scanselect_defs_var.mx \
gdk_scanselect.mx gdk.h gdk_batop.mx \
- gdk_search.mx gdk_tm.c gdk_align.c gdk_bbp.mx \
+ gdk_search.mx gdk_tm.c gdk_align.c gdk_bbp.c gdk_bbp.h \
gdk_heap.c gdk_setop.mx gdk_utils.c gdk_utils.h gdk_atoms.c
gdk_atoms.h \
gdk_qsort.c gdk_qsort_impl.h gdk_ssort.c gdk_ssort_impl.h \
gdk_storage.c gdk_bat.c gdk_bat.h \
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,25 +1,22 @@
-@/
-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://www.monetdb.org/Legal/MonetDBLicense
-
-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-2012 MonetDB B.V.
-All Rights Reserved.
-@
-
-@f gdk_bbp
-
-@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://www.monetdb.org/Legal/MonetDBLicense
+ *
+ * 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-2012 MonetDB B.V.
+ * All Rights Reserved.
+ */
+
/*
* @a M. L. Kersten, P. Boncz, N. J. Nes
* @* BAT Buffer Pool (BBP)
@@ -84,63 +81,7 @@ All Rights Reserved.
* is memory resident as required because of the 'pointer' sharing.
* @end table
*/
-@h
-#ifndef _GDK_BBP_H_
-#define _GDK_BBP_H_
-
-#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 bat BBPsize; /* current occupied size of BBP array */
-
-/* global calls */
-gdk_export bat BBPimportEntry(char *nme);
-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 int BBPreclaim(BAT *b);
-gdk_export int BBPsave(BAT *b);
-gdk_export int BBPrename(bat bid, const char *nme);
-
-/* query interface */
-gdk_export bat BBPindex(const char *nme);
-gdk_export BAT *BBPdescriptor(bat b);
-
-/* swapping interface */
-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 int BBPdecref(bat b, int logical);
-gdk_export void BBPshare(bat b);
-
-@c
-/*
- * @
- */
+
#include "monetdb_config.h"
#include "gdk.h"
#include "gdk_private.h"
@@ -165,11 +106,6 @@ bat BBPsize = 0; /* current used size o
* tuned for perfect hashing (1 lookup). The bucket chain uses the
* 'next' field in the BBPrec records.
*/
-@h
-#define BBPtmpcheck(s) ((s)[0] == 't' && (s)[1] == 'm' && (s)[2] == 'p' &&
((s)[3] == '_' || ((s)[3] == 'r' && (s)[4] == '_'))) /* (strncmp((s),
"tmp_", 4) == 0) */
-#define BBPnamecheck(s) (BBPtmpcheck(s) ? ((s)[3] == '_' ? strtol((s) + 4,
NULL, 8) : -strtol((s) + 5, NULL, 8)) : 0)
-
-@c
bat *BBP_hash = NULL; /* BBP logical name hash buckets */
bat BBP_mask = 0; /* number of buckets = & mask */
@@ -221,7 +157,6 @@ BBP_delete(bat i)
}
/*
- * @-
* other globals
*/
int BBP_curstamp = 0; /* unique stamp for creation of a bat */
@@ -231,7 +166,6 @@ int BBPin = 0; /* bats loaded statisti
int BBPout = 0; /* bats saved statistic */
/*
-
* @+ BBP Consistency and Concurrency
* While GDK provides the basic building blocks for an ACID system, in
* itself it is not such a system, as we this would entail too much
@@ -290,33 +224,6 @@ int BBPout = 0; /* bats saved statisti
* read actions are to go on unlocked while other entries in the BBP
* may be modified).
*/
-@h
-#define BBP_status_set(bid, mode, nme) \
- do { \
- BBP_status(bid) = mode; \
- } while (0)
-
-#define BBP_status_on(bid, flags, nme) \
- BBP_status_set(bid, BBP_status(bid) | flags, nme);
-
-#define BBP_status_off(bid, flags, nme)
\
- BBP_status_set(bid, BBP_status(bid) & ~(flags), nme);
-
-#define BBP_unload_inc(bid, nme) \
- do { \
- gdk_set_lock(GDKunloadLock, nme); \
- BBPunloadCnt++; \
- gdk_unset_lock(GDKunloadLock, nme); \
- } while (0)
-
-#define BBP_unload_dec(bid, nme) \
- do { \
- gdk_set_lock(GDKunloadLock, nme); \
- if (--BBPunloadCnt == 0) gdk_signal_cond(GDKunloadCond, nme); \
- assert(BBPunloadCnt >= 0); \
- gdk_unset_lock(GDKunloadLock, nme); \
- } while (0)
-@c
static MT_Id locked_by = 0;
static inline MT_Id
@@ -749,6 +656,128 @@ fixoidheap(void)
* descriptor separately. The default src=0 is to read the full
* BBPdir file.
*/
+static int
+heapinit(COLrec *col, const char *buf, int *hashash, const char *HT, int
oidsize, int bbpversion, lng batid)
+{
+ int t;
+ char type[11];
+ unsigned short width;
+ unsigned short var;
+ unsigned short properties;
+ lng nokey0;
+ lng nokey1;
+ lng nosorted;
+ lng norevsorted;
+ lng base;
+ lng align;
+ lng free;
+ lng size;
+ unsigned short storage;
+ int n;
+
+ (void) oidsize; /* only used when SIZEOF_OID==8 */
+
+ norevsorted = 0; /* default for first case */
+ if (bbpversion <= GDKLIBRARY_SORTED_BYTE ?
+ sscanf(buf,
+ " %10s %hu %hu %hu %lld %lld %lld %lld %lld %lld %lld %hu"
+ "%n",
+ type, &width, &var, &properties, &nokey0,
+ &nokey1, &nosorted, &base, &align, &free,
+ &size, &storage,
+ &n) < 12
+ :
+ sscanf(buf,
+ " %10s %hu %hu %hu %lld %lld %lld %lld %lld %lld %lld %lld
%hu"
+ "%n",
+ type, &width, &var, &properties, &nokey0,
+ &nokey1, &nosorted, &norevsorted, &base,
+ &align, &free, &size, &storage,
+ &n) < 13)
+ GDKfatal("BBPinit: invalid format for BBP.dir\n%s", buf);
+
+ *hashash = var & 2;
+ var &= ~2;
+ /* silently convert chr columns to bte */
+ if (strcmp(type, "chr") == 0)
+ strcpy(type, "bte");
+ if ((t = ATOMindex(type)) < 0)
+ t = ATOMunknown_find(type);
+ else if (BATatoms[t].varsized != var)
+ GDKfatal("BBPinit: inconsistent entry in BBP.dir: %s.varsized
mismatch for BAT " LLFMT "\n", HT, batid);
+ else if (var && t != 0 ?
+ BATatoms[t].size < width ||
+ (width != 1 && width != 2 && width != 4
+#if SIZEOF_VAR_T == 8
+ && width != 8
+#endif
+ ) :
+ BATatoms[t].size != width
+#if SIZEOF_SIZE_T == 8 && SIZEOF_OID == 8
+ && (t != TYPE_oid || oidsize == 0 || width != oidsize)
+#endif
+ )
+ GDKfatal("BBPinit: inconsistent entry in BBP.dir: %s.size
mismatch for BAT " LLFMT "\n", HT, batid);
+ col->type = t;
+ col->width = width;
+ col->varsized = var != 0;
+ col->shift = ATOMelmshift(width);
+ assert_shift_width(col->shift,col->width);
+ col->nokey[0] = (BUN) nokey0;
+ col->nokey[1] = (BUN) nokey1;
+ col->sorted = (bit) ((properties & 0x0001) != 0);
+ col->revsorted = (bit) ((properties & 0x0080) != 0);
+ col->key = (properties & 0x0100) != 0;
+ col->dense = (properties & 0x0200) != 0;
+ col->nonil = (properties & 0x0400) != 0;
+ col->nil = (properties & 0x0800) != 0;
+ col->nosorted = (BUN) nosorted;
+ col->norevsorted = (BUN) norevsorted;
+ col->seq = base < 0 ? oid_nil : (oid) base;
+ col->align = (oid) align;
+ col->heap.maxsize = (size_t) size;
+ col->heap.free = (size_t) free;
+ col->heap.size = (size_t) size;
+ col->heap.base = NULL;
+ col->heap.filename = NULL;
+ col->heap.storage = (storage_t) storage;
+ col->heap.copied = 0;
+ col->heap.newstorage = (storage_t) storage;
+ col->heap.dirty = 0;
+ return n;
+}
+
+static int
+vheapinit(COLrec *col, const char *buf, int hashash, bat bid)
+{
+ int n = 0;
+ lng free, size;
+ unsigned short storage;
+
+ if (col->varsized && col->type != TYPE_void) {
+ col->vheap = GDKzalloc(sizeof(Heap));
+ if (col->vheap == NULL)
+ GDKfatal("BBPinit: cannot allocate memory for heap.");
+ if (sscanf(buf,
+ " %lld %lld %hu"
+ "%n",
+ &free, &size, &storage, &n) < 3)
+ GDKfatal("BBPinit: invalid format for BBP.dir\n%s",
buf);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list