Changeset: a1218081c3c6 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a1218081c3c6
Added Files:
        gdk/gdk_bat.c
        gdk/gdk_bat.h
Removed Files:
        gdk/gdk_bat.mx
Modified Files:
        gdk/Makefile.ag
Branch: default
Log Message:

Converted gdk_bat.mx to .c/.h files.


diffs (truncated from 1457 to 300 lines):

diff --git a/gdk/Makefile.ag b/gdk/Makefile.ag
--- a/gdk/Makefile.ag
+++ b/gdk/Makefile.ag
@@ -37,7 +37,7 @@ lib_gdk = {
                gdk_scanselect.mx gdk.h gdk_batop.mx \
                gdk_search.mx gdk_tm.c gdk_align.c gdk_bbp.mx \
                gdk_heap.c gdk_setop.mx gdk_utils.mx gdk_atoms.mx \
-               gdk_qsort.mx gdk_ssort.mx gdk_storage.c gdk_bat.mx \
+               gdk_qsort.mx gdk_ssort.mx gdk_storage.c gdk_bat.c gdk_bat.h \
                gdk_delta.c gdk_relop.mx gdk_system.c gdk_value.mx \
                gdk_rangejoin.mx \
                gdk_posix.c gdk_logger.c gdk_sample.c \
diff --git a/gdk/gdk_bat.mx b/gdk/gdk_bat.c
rename from gdk/gdk_bat.mx
rename to gdk/gdk_bat.c
--- a/gdk/gdk_bat.mx
+++ b/gdk/gdk_bat.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
+/*
+ * 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.
+ */
 
-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_bat
-
-@c
 /*
  * @a M. L. Kersten, P. Boncz, N. Nes
  * @* BAT Module
@@ -32,40 +29,27 @@ All Rights Reserved.
  * storage and easy shipment over a network.
  *
  * The BAT starts with a descriptor, which indicates the required BAT
- * library version and the BAT administration details.  In particular, it
- * describes the binary relationship maintained and the location of
+ * library version and the BAT administration details.  In particular,
+ * it describes the binary relationship maintained and the location of
  * fields required for storage.
  *
  * The general layout of the BAT in this implementation is as follows.
  * Each BAT comes with a heap for the loc-size buns and, optionally,
  * with heaps to manage the variable-sized data items of both
- * dimensions.  The buns are assumed to be stored as loc-size
- * objects.  This is essentially an array of structs to store the
- * associations.  The size is determined at BAT creation time using an
- * upper bound on the number of elements to be accommodated.  In case of
- * overflow, its storage space is extended automatically.
+ * dimensions.  The buns are assumed to be stored as loc-size objects.
+ * This is essentially an array of structs to store the associations.
+ * The size is determined at BAT creation time using an upper bound on
+ * the number of elements to be accommodated.  In case of overflow,
+ * its storage space is extended automatically.
  *
- * The capacity of a BAT places an upper limit on the number of BUNs to
- * be stored initially. The actual space set aside may be quite large.
- * Moreover, the size is aligned to int boundaries to speedup access and
- * avoid some machine limitations.
+ * The capacity of a BAT places an upper limit on the number of BUNs
+ * to be stored initially. The actual space set aside may be quite
+ * large.  Moreover, the size is aligned to int boundaries to speedup
+ * access and avoid some machine limitations.
  *
  * Initialization of the variable parts rely on type specific routines
  * called atomHeap.
  */
-@h
-#ifndef _GDK_BAT_H_
-#define _GDK_BAT_H_
-
-gdk_export BUN void_replace_bat(BAT *b, BAT *u, bit force);
-gdk_export int void_inplace(BAT *b, oid id, ptr val, bit force);
-gdk_export BAT *BATattach(int tt, const char *heapfile);
-
-extern int default_ident(char *s);
-extern oid MAXoid(BAT *i);
-
-#endif /* _GDK_BAT_H_ */
-@c
 #include "monetdb_config.h"
 #include "gdk.h"
 #include "gdk_private.h"
@@ -99,7 +83,6 @@ BATcreatedesc(int ht, int tt, int heapna
        BAT *bn;
 
        /*
-        * @-
         * Alloc space for the BAT and its dependent records.
         */
        BATstore *bs = (BATstore *) GDKzalloc(sizeof(BATstore));
@@ -107,7 +90,6 @@ BATcreatedesc(int ht, int tt, int heapna
        if (bs == NULL)
                return NULL;
        /*
-        * @-
         * assert needed in the kernel to get symbol eprintf resolved.
         * Else modules using assert fail to load.
         */
@@ -124,7 +106,6 @@ BATcreatedesc(int ht, int tt, int heapna
        bn = &bs->B;
 
        /*
-        * @-
         * Fill in basic column info
         */
        bn->htype = ht;
@@ -145,13 +126,12 @@ BATcreatedesc(int ht, int tt, int heapna
        bn->batPersistence = TRANSIENT;
        bn->H->props = bn->T->props = NULL;
        /*
-        * @-
         * add to BBP
         */
        BBPinsert(bs);
        /*
-        * @-
-        * fill in heap names, so HEAPallocs can resort to disk for very large 
writes.
+        * fill in heap names, so HEAPallocs can resort to disk for
+        * very large writes.
         */
        assert(bn->batCacheid > 0);
        bn->H->heap.filename = NULL;
@@ -245,12 +225,13 @@ BATsetdims(BAT *b)
 /*
  * @- BAT allocation
  * Allocate BUN heap and variable-size atomheaps (see e.g. strHeap).
- * We now initialize new BATs with their heapname such that the modified
- * HEAPalloc/HEAPextend primitives can possibly use memory mapped files
- * as temporary heap storage.
+ * We now initialize new BATs with their heapname such that the
+ * modified HEAPalloc/HEAPextend primitives can possibly use memory
+ * mapped files as temporary heap storage.
  *
- * In case of huge bats, we want HEAPalloc to write a file to disk, and memory 
map
- * it. To make this possible, we must provide it with filenames.
+ * In case of huge bats, we want HEAPalloc to write a file to disk,
+ * and memory map it. To make this possible, we must provide it with
+ * filenames.
  */
 static BATstore *
 BATnewstorage(int ht, int tt, BUN cap)
@@ -387,7 +368,6 @@ BATattach(int tt, const char *heapfile)
 }
 
 /*
- * @-
  * The routine BATclone creates a bat with the same types as b.
  */
 BAT *
@@ -403,19 +383,18 @@ BATclone(BAT *b, BUN cap)
 }
 
 /*
- * @-
  * If the BAT runs out of storage for BUNS it will reallocate space.
  * For memory mapped BATs we simple extend the administration after
  * having an assurance that the BAT still can be safely stored away.
  *
- * @-
- * Most BAT operations use a BAT to assemble the result. In several cases
- * it is rather difficult to give a precise estimate of the required space.
- * The routine BATguess is used internally for this purpose.
- * It balances the cost of small BATs with their probability of occurrence.
- * Small results BATs are more likely than 100M BATs.
+ * Most BAT operations use a BAT to assemble the result. In several
+ * cases it is rather difficult to give a precise estimate of the
+ * required space.  The routine BATguess is used internally for this
+ * purpose.  It balances the cost of small BATs with their probability
+ * of occurrence.  Small results BATs are more likely than 100M BATs.
  *
- * Likewise, the routines Hgrows and Tgrows  provides a heuristic to enlarge 
the space.
+ * Likewise, the routines Hgrows and Tgrows provides a heuristic to
+ * enlarge the space.
  */
 BUN
 BATguess(BAT *b)
@@ -461,12 +440,12 @@ BATgrows(BAT *b)
 }
 
 /*
- * @-
- * The routine should ensure that the BAT keeps its location
- * in the BAT buffer.
+ * The routine should ensure that the BAT keeps its location in the
+ * BAT buffer.
  *
- * Overflow in the other heaps are dealt with in the atom  routines.
- * Here we merely copy their references into the new administration space.
+ * Overflow in the other heaps are dealt with in the atom routines.
+ * Here we merely copy their references into the new administration
+ * space.
  */
 BAT *
 BATextend(BAT *b, BUN newcap)
@@ -476,13 +455,12 @@ BATextend(BAT *b, BUN newcap)
        assert(newcap <= BUN_MAX);
        BATcheck(b, "BATextend");
        /*
-        * @-
         * The main issue is to properly predict the new BAT size.
         * storage overflow. The assumption taken is that capacity
-        * overflow is rare. It is changed only when the position
-        * of the next available BUN surpasses the free area marker.
-        * Be aware that the newcap should be greater than the old
-        * value, otherwise you may easily corrupt the administration of
+        * overflow is rare. It is changed only when the position of
+        * the next available BUN surpasses the free area marker.  Be
+        * aware that the newcap should be greater than the old value,
+        * otherwise you may easily corrupt the administration of
         * malloc.
         */
        if (newcap <= BATcapacity(b)) {
@@ -509,18 +487,17 @@ BATextend(BAT *b, BUN newcap)
 
 /*
  * @+ BAT destruction
- * @-
- * BATclear quickly removes all elements from a BAT. It must respect the
- * transaction rules; so stable elements must be moved to the "deleted"
- * section of the BAT (they cannot be fully deleted yet). For the elements
- * that really disappear, we must free heapspace and unfix the atoms if
- * they have fix/unfix handles. As an optimization, in the case of no stable
- * elements, we quickly empty the heaps by copying a standard small empty image
- * over them.
+ * BATclear quickly removes all elements from a BAT. It must respect
+ * the transaction rules; so stable elements must be moved to the
+ * "deleted" section of the BAT (they cannot be fully deleted
+ * yet). For the elements that really disappear, we must free
+ * heapspace and unfix the atoms if they have fix/unfix handles. As an
+ * optimization, in the case of no stable elements, we quickly empty
+ * the heaps by copying a standard small empty image over them.
  */
 BAT *
 BATclear(BAT *b)
-{      
+{
        BUN p, q;
        int voidbat;
        BAT *bm;
@@ -554,8 +531,8 @@ BATclear(BAT *b)
        }
 
        /* we must dispose of all inserted atoms */
-       if (b->batDeleted == b->batInserted && 
-           BATatoms[b->htype].atomDel == NULL && 
+       if (b->batDeleted == b->batInserted &&
+           BATatoms[b->htype].atomDel == NULL &&
            BATatoms[b->ttype].atomDel == NULL) {
                Heap hh, th;
 
@@ -616,7 +593,7 @@ BATclear(BAT *b)
        BATsetcount(b,0);
        b->batDirty = TRUE;
        BATsettrivprop(b);
-       return b; 
+       return b;
 }
 
 /* free a cached BAT; leave the bat descriptor cached */
@@ -628,10 +605,10 @@ BATfree(BAT *b)
        /* deallocate all memory for a bat */
        if (b->batCacheid < 0)
                b = BBP_cache(-(b->batCacheid));
-       if (b->hident && !default_ident(b->hident)) 
+       if (b->hident && !default_ident(b->hident))
                GDKfree(b->hident);
        b->hident = BATstring_h;
-       if (b->tident && !default_ident(b->tident)) 
+       if (b->tident && !default_ident(b->tident))
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to