Changeset: eaadaa9862ba for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/eaadaa9862ba
Modified Files:
        gdk/gdk_align.c
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        gdk/gdk_bbp.c
        gdk/gdk_orderidx.c
Branch: Jul2021
Log Message:

Some cleanup.


diffs (128 lines):

diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c
--- a/gdk/gdk_align.c
+++ b/gdk/gdk_align.c
@@ -193,8 +193,7 @@ BATmaterialize(BAT *b)
                .parentid = b->batCacheid,
                .dirty = true,
        };
-       strconcat_len(tail->filename, sizeof(tail->filename),
-                     BBP_physical(b->batCacheid), ".tail", NULL);
+       settailname(tail, BBP_physical(b->batCacheid), TYPE_oid, 0);
        if (HEAPalloc(tail, cnt, sizeof(oid), 0) != GDK_SUCCEED) {
                GDKfree(tail);
                return GDK_FAIL;
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -179,20 +179,21 @@ BATsetdims(BAT *b)
 const char *
 gettailname(const BAT *b)
 {
-       if (b->ttype != TYPE_str)
-               return "tail";
-       switch (b->twidth) {
-       case 1:
-               return "tail1";
-       case 2:
-               return "tail2";
+       if (b->ttype == TYPE_str) {
+               switch (b->twidth) {
+               case 1:
+                       return "tail1";
+               case 2:
+                       return "tail2";
 #if SIZEOF_VAR_T == 8
-       case 4:
-               return "tail4";
+               case 4:
+                       return "tail4";
 #endif
-       default:
-               return "tail";
+               default:
+                       break;
+               }
        }
+       return "tail";
 }
 
 void
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -23,12 +23,14 @@ unshare_varsized_heap(BAT *b)
 {
        if (ATOMvarsized(b->ttype) &&
            b->tvheap->parentid != b->batCacheid) {
-               Heap *h = GDKzalloc(sizeof(Heap));
+               Heap *h = GDKmalloc(sizeof(Heap));
                if (h == NULL)
                        return GDK_FAIL;
                MT_thread_setalgorithm("unshare vheap");
-               h->parentid = b->batCacheid;
-               h->farmid = BBPselectfarm(b->batRole, TYPE_str, varheap);
+               *h = (Heap) {
+                       .parentid = b->batCacheid,
+                       .farmid = BBPselectfarm(b->batRole, TYPE_str, varheap),
+               };
                strconcat_len(h->filename, sizeof(h->filename),
                              BBP_physical(b->batCacheid), ".theap", NULL);
                if (HEAPcopy(h, b->tvheap, 0) != GDK_SUCCEED) {
@@ -418,13 +420,15 @@ append_varsized_bat(BAT *b, BAT *n, stru
        /* b and n do not share their vheap, so we need to copy data */
        if (b->tvheap->parentid != b->batCacheid) {
                /* if b shares its vheap with some other bat, unshare it */
-               Heap *h = GDKzalloc(sizeof(Heap));
+               Heap *h = GDKmalloc(sizeof(Heap));
                if (h == NULL) {
                        bat_iterator_end(&ni);
                        return GDK_FAIL;
                }
-               h->parentid = b->batCacheid;
-               h->farmid = BBPselectfarm(b->batRole, b->ttype, varheap);
+               *h = (Heap) {
+                       .parentid = b->batCacheid,
+                       .farmid = BBPselectfarm(b->batRole, b->ttype, varheap),
+               };
                strconcat_len(h->filename, sizeof(h->filename),
                              BBP_physical(b->batCacheid), ".theap", NULL);
                if (HEAPcopy(h, b->tvheap, 0) != GDK_SUCCEED) {
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -2387,6 +2387,7 @@ decref(bat i, bool logical, bool release
        if (lock)
                MT_lock_set(&GDKswapLock(i));
        if (releaseShare) {
+               assert(BBP_lrefs(i) > 0);
                if (BBP_desc(i)->batSharecnt == 0) {
                        GDKerror("%s: %s does not have any shares.\n", func, 
BBP_logical(i));
                        assert(0);
@@ -2416,6 +2417,8 @@ decref(bat i, bool logical, bool release
                } else {
                        refs = --BBP_lrefs(i);
                }
+               /* cannot release last logical ref if still shared */
+               assert(BBP_desc(i)->batSharecnt == 0 || refs > 0);
        } else {
                if (BBP_refs(i) == 0) {
                        GDKerror("%s: %s does not have pointer fixes.\n", func, 
BBP_logical(i));
diff --git a/gdk/gdk_orderidx.c b/gdk/gdk_orderidx.c
--- a/gdk/gdk_orderidx.c
+++ b/gdk/gdk_orderidx.c
@@ -139,13 +139,12 @@ createOIDXheap(BAT *b, bool stable)
 {
        Heap *m;
        oid *restrict mv;
-       const char *nme;
 
-       nme = GDKinmemory(b->theap->farmid) ? ":memory:" : 
BBP_physical(b->batCacheid);
        if ((m = GDKzalloc(sizeof(Heap))) == NULL ||
            (m->farmid = BBPselectfarm(b->batRole, b->ttype, orderidxheap)) < 0 
||
            strconcat_len(m->filename, sizeof(m->filename),
-                         nme, ".torderidx", NULL) >= sizeof(m->filename) ||
+                         BBP_physical(b->batCacheid), ".torderidx",
+                         NULL) >= sizeof(m->filename) ||
            HEAPalloc(m, BATcount(b) + ORDERIDXOFF, SIZEOF_OID, 0) != 
GDK_SUCCEED) {
                GDKfree(m);
                return NULL;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to