Changeset: db6c0d7abc6e for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=db6c0d7abc6e
Modified Files:
        clients/Tests/exports.stable.out
        gdk/gdk.h
        gdk/gdk_align.c
        gdk/gdk_atoms.c
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        gdk/gdk_bbp.c
        gdk/gdk_group.c
        gdk/gdk_heap.c
        gdk/gdk_private.h
        gdk/gdk_relop.mx
        gdk/gdk_search.c
        gdk/gdk_storage.c
        geom/monetdb5/geom.c
        monetdb5/modules/atoms/blob.c
        monetdb5/modules/kernel/status.c
        monetdb5/modules/mal/bbp.c
        monetdb5/modules/mal/pcre.c
        monetdb5/modules/mal/remote.c
Branch: default
Log Message:

Extend HEAP functions with context BAT
The default contest for all GDK routines should become a BAT.
The HEAP functions have been mostly changed to accomodate this.
No actions are taken yet within the receiving target low-level
HEAP functions yet
The critical calls have a NULL context BAT


diffs (truncated from 1732 to 300 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -271,14 +271,14 @@ void HASHdestroy(BAT *b);
 BUN HASHlist(Hash *h, BUN i);
 BUN HASHprobe(Hash *h, const void *v);
 void HASHremove(BAT *b);
-void HEAP_free(Heap *heap, var_t block);
-void HEAP_initialize(Heap *heap, size_t nbytes, size_t nprivate, int 
alignment);
-var_t HEAP_malloc(Heap *heap, size_t nbytes);
-int HEAPcopy(Heap *dst, Heap *src);
-int HEAPextend(Heap *h, size_t size);
+void HEAP_free(BAT *b, Heap *heap, var_t block);
+void HEAP_initialize(BAT *b, Heap *heap, size_t nbytes, size_t nprivate, int 
alignment);
+var_t HEAP_malloc(BAT *b, Heap *heap, size_t nbytes);
+int HEAPcopy(BAT *b, Heap *dst, Heap *src);
+int HEAPextend(BAT *b, Heap *h, size_t size);
 int HEAPfree(Heap *h);
-size_t HEAPmemsize(Heap *h);
-size_t HEAPvmsize(Heap *h);
+size_t HEAPmemsize(BAT *b, Heap *h);
+size_t HEAPvmsize(BAT *b, Heap *h);
 int MT_check_nr_cores(void);
 unsigned long long MT_clock(void);
 int MT_create_thread(MT_Id *t, void( *function)(void *), void *arg, enum 
MT_thr_detach d);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -950,39 +950,39 @@ typedef int (*GDKfcn) ();
  * @multitable @columnfractions 0.08 0.7
  * @item int
  * @tab
- *  HEAPalloc (Heap *h, size_t nitems, size_t itemsize);
+ *  HEAPalloc (BAT *b, Heap *h, size_t nitems, size_t itemsize);
  * @item int
  * @tab
- *  HEAPfree (Heap *h);
+ *  HEAPfree (BAT *b, Heap *h);
  * @item int
  * @tab
- *  HEAPextend (Heap *h, size_t size);
+ *  HEAPextend (BAT *b, Heap *h, size_t size);
  * @item int
  * @tab
- *  HEAPload (Heap *h, str nme,ext, int trunc);
+ *  HEAPload (BAT *b, Heap *h, str nme,ext, int trunc);
  * @item int
  * @tab
- *  HEAPsave (Heap *h, str nme,ext);
+ *  HEAPsave (BAT *b, Heap *h, str nme,ext);
  * @item int
  * @tab
- *  HEAPcopy (Heap *dst,*src);
+ *  HEAPcopy (BAT *b, Heap *dst,*src);
  * @item int
  * @tab
- *  HEAPdelete (Heap *dst, str o, str ext);
+ *  HEAPdelete (BAT *b, Heap *dst, str o, str ext);
  * @item int
  * @tab
- *  HEAPwarm (Heap *h);
+ *  HEAPwarm (BAT *b, Heap *h);
  * @end multitable
  *
  *
  * These routines should be used to alloc free or extend heaps; they
  * isolate you from the different ways heaps can be accessed.
  */
-gdk_export int HEAPfree(Heap *h);
-gdk_export int HEAPextend(Heap *h, size_t size);
-gdk_export int HEAPcopy(Heap *dst, Heap *src);
-gdk_export size_t HEAPvmsize(Heap *h);
-gdk_export size_t HEAPmemsize(Heap *h);
+gdk_export int HEAPfree(BAT *b, Heap *h);
+gdk_export int HEAPextend(BAT *b, Heap *h, size_t size);
+gdk_export int HEAPcopy(BAT *b, Heap *dst, Heap *src);
+gdk_export size_t HEAPvmsize(BAT *b, Heap *h);
+gdk_export size_t HEAPmemsize(BAT *b, Heap *h);
 
 /*
  * @- Internal HEAP Chunk Management
@@ -992,13 +992,13 @@ gdk_export size_t HEAPmemsize(Heap *h);
  *
  * @table @code
  * @item void
- * HEAP_initialize  (Heap* h, size_t nbytes, size_t nprivate, int align )
+ * HEAP_initialize  (BAT *b, Heap* h, size_t nbytes, size_t nprivate, int 
align )
  * @item void
  * HEAP_destroy     (Heap* h)
  * @item var_t
- * HEAP_malloc      (Heap* heap, size_t nbytes)
+ * HEAP_malloc      (BAT *b, Heap* heap, size_t nbytes)
  * @item void
- * HEAP_free        (Heap *heap, var_t block)
+ * HEAP_free        (BAT *b, Heap *heap, var_t block)
  * @item int
  * HEAP_private     (Heap* h)
  * @item void
@@ -1026,16 +1026,17 @@ typedef struct {
 } HeapRepair;
 
 gdk_export void HEAP_initialize(
+       BAT *b,
        Heap *heap,             /* nbytes -- Initial size of the heap. */
        size_t nbytes,          /* alignment -- for objects on the heap. */
        size_t nprivate,        /* nprivate -- Size of private space */
        int alignment           /* alignment restriction for allocated chunks */
        );
 
-gdk_export var_t HEAP_malloc(Heap *heap, size_t nbytes);
-gdk_export void HEAP_free(Heap *heap, var_t block);
+gdk_export var_t HEAP_malloc(BAT *b, Heap *heap, size_t nbytes);
+gdk_export void HEAP_free(BAT *b, Heap *heap, var_t block);
 
-#define HEAP_index(HEAP,INDEX,TYPE)    ((TYPE *)((char *) (HEAP)->base + 
(INDEX)))
+#define HEAP_index(BAT, HEAP,INDEX,TYPE)       ((TYPE *)((char *) (HEAP)->base 
+ (INDEX)))
 
 /*
  * @- BAT construction
diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c
--- a/gdk/gdk_align.c
+++ b/gdk/gdk_align.c
@@ -464,7 +464,7 @@ BATmaterializeh(BAT *b)
        HASHdestroy(b);
 
        b->H->heap.filename = NULL;
-       if (HEAPalloc(&b->H->heap, cnt, sizeof(oid)) < 0) {
+       if (HEAPalloc(b, &b->H->heap, cnt, sizeof(oid)) < 0) {
                b->H->heap = head;
                return NULL;
        }
@@ -493,7 +493,7 @@ BATmaterializeh(BAT *b)
        BATsetcount(b, cnt);
 
        /* cleanup the old heaps */
-       HEAPfree(&head);
+       HEAPfree(b, &head);
        return b;
 }
 
@@ -610,7 +610,7 @@ VIEWreset(BAT *b)
                        if (head.filename == NULL)
                                goto bailout;
                        snprintf(head.filename, nmelen + 12, "%s.head", nme);
-                       if (n->htype && HEAPalloc(&head, cnt, Hsize(n)) < 0)
+                       if (n->htype && HEAPalloc(NULL, &head, cnt, Hsize(n)) < 
0)
                                goto bailout;
                }
                if (n->ttype) {
@@ -618,7 +618,7 @@ VIEWreset(BAT *b)
                        if (tail.filename == NULL)
                                goto bailout;
                        snprintf(tail.filename, nmelen + 12, "%s.tail", nme);
-                       if (n->ttype && HEAPalloc(&tail, cnt, Tsize(n)) < 0)
+                       if (n->ttype && HEAPalloc(NULL, &tail, cnt, Tsize(n)) < 
0)
                                goto bailout;
                }
                if (n->H->vheap) {
@@ -732,10 +732,10 @@ VIEWreset(BAT *b)
                BBPreclaim(v);
        if (n != NULL)
                BBPunfix(n->batCacheid);
-       HEAPfree(&head);
-       HEAPfree(&tail);
-       HEAPfree(&hh);
-       HEAPfree(&th);
+       HEAPfree(NULL, &head);
+       HEAPfree(NULL, &tail);
+       HEAPfree(n, &hh);
+       HEAPfree(n, &th);
        return NULL;
 }
 
@@ -785,13 +785,13 @@ VIEWdestroy(BAT *b)
        VIEWunlink(b);
 
        if (b->htype && !b->H->heap.parentid) {
-               HEAPfree(&b->H->heap);
+               HEAPfree(b, &b->H->heap);
        } else {
                b->H->heap.base = NULL;
                b->H->heap.filename = NULL;
        }
        if (b->ttype && !b->T->heap.parentid) {
-               HEAPfree(&b->T->heap);
+               HEAPfree(b, &b->T->heap);
        } else {
                b->T->heap.base = NULL;
                b->T->heap.filename = NULL;
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -1056,7 +1056,7 @@ strHeap(Heap *d, size_t cap)
 
        cap = MAX(cap, BATTINY);
        size = GDK_STRHASHTABLE * sizeof(stridx_t) + MIN(GDK_ELIMLIMIT, cap * 
GDK_VARALIGN);
-       if (HEAPalloc(d, size, 1) >= 0) {
+       if (HEAPalloc(NULL, d, size, 1) >= 0) {
                d->free = GDK_STRHASHTABLE * sizeof(stridx_t);
                memset(d->base, 0, d->free);
                d->hashash = 1; /* new string heaps get the hash value (and 
length) stored */
@@ -1189,7 +1189,7 @@ strPut(Heap *h, var_t *dst, const char *
                        newsize = MIN(newsize, h->maxsize);
                }
                HEAPDEBUG fprintf(stderr, "#HEAPextend in strPut %s " SZFMT " " 
SZFMT "\n", h->filename, h->size, newsize);
-               if (HEAPextend(h, newsize) < 0) {
+               if (HEAPextend(NULL, h, newsize) < 0) {
                        return 0;
                }
 #ifndef NDEBUG
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -180,15 +180,15 @@ BATcreatedesc(int ht, int tt, int heapna
        return bs;
       bailout:
        if (ht)
-               HEAPfree(&bn->H->heap);
+               HEAPfree(bn, &bn->H->heap);
        if (tt)
-               HEAPfree(&bn->T->heap);
+               HEAPfree(bn, &bn->T->heap);
        if (bn->H->vheap) {
-               HEAPfree(bn->H->vheap);
+               HEAPfree(bn, bn->H->vheap);
                GDKfree(bn->H->vheap);
        }
        if (bn->T->vheap) {
-               HEAPfree(bn->T->vheap);
+               HEAPfree(bn, bn->T->vheap);
                GDKfree(bn->T->vheap);
        }
        GDKfree(bs);
@@ -257,20 +257,20 @@ BATnewstorage(int ht, int tt, BUN cap)
        bn->U->capacity = cap;
 
        /* alloc the main heaps */
-       if (ht && HEAPalloc(&bn->H->heap, cap, bn->H->width) < 0) {
+       if (ht && HEAPalloc(bn, &bn->H->heap, cap, bn->H->width) < 0) {
                return NULL;
        }
-       if (tt && HEAPalloc(&bn->T->heap, cap, bn->T->width) < 0) {
+       if (tt && HEAPalloc(bn, &bn->T->heap, cap, bn->T->width) < 0) {
                if (ht)
-                       HEAPfree(&bn->H->heap);
+                       HEAPfree(bn, &bn->H->heap);
                return NULL;
        }
 
        if (ATOMheap(ht, bn->H->vheap, cap) < 0) {
                if (ht)
-                       HEAPfree(&bn->H->heap);
+                       HEAPfree(bn, &bn->H->heap);
                if (tt)
-                       HEAPfree(&bn->T->heap);
+                       HEAPfree(bn, &bn->T->heap);
                GDKfree(bn->H->vheap);
                if (bn->T->vheap)
                        GDKfree(bn->T->vheap);
@@ -278,11 +278,11 @@ BATnewstorage(int ht, int tt, BUN cap)
        }
        if (ATOMheap(tt, bn->T->vheap, cap) < 0) {
                if (ht)
-                       HEAPfree(&bn->H->heap);
+                       HEAPfree(bn, &bn->H->heap);
                if (tt)
-                       HEAPfree(&bn->T->heap);
+                       HEAPfree(bn, &bn->T->heap);
                if (bn->H->vheap) {
-                       HEAPfree(bn->H->vheap);
+                       HEAPfree(bn, bn->H->vheap);
                        GDKfree(bn->H->vheap);
                }
                GDKfree(bn->T->vheap);
@@ -348,7 +348,7 @@ BATattach(int tt, const char *heapfile)
        GDKcreatedir(path);
        if (rename(heapfile, path) < 0) {
                GDKsyserror("BATattach: cannot rename heapfile\n");
-               HEAPfree(&bn->T->heap);
+               HEAPfree(bn, &bn->T->heap);
                GDKfree(bs);
                return NULL;
        }
@@ -365,8 +365,8 @@ BATattach(int tt, const char *heapfile)
        bn->batRestricted = BAT_READ;
        bn->T->heap.size = (size_t) st.st_size;
        bn->T->heap.newstorage = bn->T->heap.storage = (bn->T->heap.size < 
REMAP_PAGE_MAXSIZE) ? STORE_MEM : STORE_MMAP;
-       if (HEAPload(&bn->T->heap, BBP_physical(bn->batCacheid), "tail", TRUE) 
< 0) {
-               HEAPfree(&bn->T->heap);
+       if (HEAPload(bn, &bn->T->heap, BBP_physical(bn->batCacheid), "tail", 
TRUE) < 0) {
+               HEAPfree(bn, &bn->T->heap);
                GDKfree(bs);
                return NULL;
        }
@@ -479,12 +479,12 @@ BATextend(BAT *b, BUN newcap)
        hheap_size *= Hsize(b);
        if (b->H->heap.base && GDKdebug & HEAPMASK)
                fprintf(stderr, "#HEAPextend in BATextend %s " SZFMT " " SZFMT 
"\n", b->H->heap.filename, b->H->heap.size, hheap_size);
-       if (b->H->heap.base && HEAPextend(&b->H->heap, hheap_size) < 0)
+       if (b->H->heap.base && HEAPextend(b, &b->H->heap, hheap_size) < 0)
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to