Changeset: 2c4cce885767 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2c4cce885767
Modified Files:
        gdk/gdk.h
        gdk/gdk_aggr.c
        gdk/gdk_align.c
        gdk/gdk_bat.c
        gdk/gdk_bbp.c
        gdk/gdk_group.c
        gdk/gdk_hash.c
        gdk/gdk_imprints.c
        gdk/gdk_join.c
        gdk/gdk_orderidx.c
        gdk/gdk_select.c
        gdk/gdk_storage.c
        gdk/gdk_unique.c
        monetdb5/mal/mal_profiler.c
        sql/storage/bat/bat_storage.c
Branch: default
Log Message:

Store parent BAT id as a positive value.


diffs (truncated from 391 to 300 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -2721,7 +2721,7 @@ gdk_export void ALIGNsetT(BAT *b1, BAT *
 #define ALIGNapp(x,y,f,e)      do {if (!(f)) 
VIEWchk(x,y,BAT_READ,e);(x)->talign=0; } while (0)
 
 #define BAThrestricted(b) ((b)->batRestricted)
-#define BATtrestricted(b) (VIEWtparent(b) ? 
BBP_cache(-VIEWtparent(b))->batRestricted : (b)->batRestricted)
+#define BATtrestricted(b) (VIEWtparent(b) ? 
BBP_cache(VIEWtparent(b))->batRestricted : (b)->batRestricted)
 
 /* The batRestricted field indicates whether a BAT is readonly.
  * we have modes: BAT_WRITE  = all permitted
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -2284,9 +2284,9 @@ BATminmax(BAT *b, void *aggr,
        BATiter bi;
 
        if ((VIEWtparent(b) == 0 ||
-            BATcount(b) == BATcount(BBPdescriptor(-VIEWtparent(b)))) &&
+            BATcount(b) == BATcount(BBPdescriptor(VIEWtparent(b)))) &&
            BATcheckimprints(b)) {
-               Imprints *imprints = VIEWtparent(b) ? 
BBPdescriptor(-VIEWtparent(b))->timprints : b->timprints;
+               Imprints *imprints = VIEWtparent(b) ? 
BBPdescriptor(VIEWtparent(b))->timprints : b->timprints;
                pos = oid_nil;
                if (minmax == do_groupmin) {
                        /* find first non-empty bin */
diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c
--- a/gdk/gdk_align.c
+++ b/gdk/gdk_align.c
@@ -179,7 +179,7 @@ VIEWcreate_(oid seq, BAT *b, int slice_v
        if (bn == NULL)
                return NULL;
 
-       tp = -VIEWtparent(b);
+       tp = VIEWtparent(b);
        if ((tp == 0 && b->ttype != TYPE_void) || b->theap.copied)
                tp = b->batCacheid;
        assert(b->ttype != TYPE_void || !tp);
@@ -215,7 +215,7 @@ VIEWcreate_(oid seq, BAT *b, int slice_v
 
        /* correct values after copy of head and tail info */
        if (tp)
-               bn->theap.parentid = -tp;
+               bn->theap.parentid = tp;
        BATinit_idents(bn);
        /* Some bits must be copied individually. */
        bn->batDirty = BATdirty(b);
@@ -312,7 +312,7 @@ static void
 VIEWunlink(BAT *b)
 {
        if (b) {
-               bat tp = -VIEWtparent(b);
+               bat tp = VIEWtparent(b);
                bat vtp = VIEWvtparent(b);
                BAT *tpb = NULL;
                BAT *vtpb = NULL;
@@ -361,7 +361,7 @@ VIEWreset(BAT *b)
        if (b == NULL)
                return GDK_FAIL;
        assert(b->batCacheid > 0);
-       tp = -VIEWtparent(b);
+       tp = VIEWtparent(b);
        tvp = VIEWvtparent(b);
        if (tp || tvp) {
                BUN cnt;
@@ -440,7 +440,7 @@ VIEWreset(BAT *b)
                        b->tvheap->parentid = b->batCacheid;
                }
 
-               if (-v->theap.parentid == b->batCacheid) {
+               if (v->theap.parentid == b->batCacheid) {
                        assert(tp == 0);
                        assert(b->batSharecnt > 0);
                        BBPunshare(b->batCacheid);
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -629,7 +629,7 @@ COLcopy(BAT *b, int tt, int writable, in
                        bunstocopy = cnt;
                } else if (isVIEW(b)) {
                        /* extra checks needed for views */
-                       bat tp = -VIEWtparent(b);
+                       bat tp = VIEWtparent(b);
 
                        if (tp != 0 && BATcapacity(BBP_cache(tp)) > cnt + cnt)
                                /* reduced slice view: do not copy too
@@ -1376,7 +1376,7 @@ BATkey(BAT *b, int flag)
        if (flag && VIEWtparent(b)) {
                /* if a view is key, then so is the parent if the two
                 * are aligned */
-               BAT *bp = BBP_cache(-VIEWtparent(b));
+               BAT *bp = BBP_cache(VIEWtparent(b));
                if (BATcount(b) == BATcount(bp) &&
                    ATOMtype(BATttype(b)) == ATOMtype(BATttype(bp)) &&
                    !BATtkey(bp) &&
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -1469,7 +1469,7 @@ BBPexit(void)
                                                 * VIEWdestroy doesn't
                                                 * (and can't here due
                                                 * to locks) do it */
-                                               bat tp = -VIEWtparent(b);
+                                               bat tp = VIEWtparent(b);
                                                bat vtp = VIEWvtparent(b);
                                                if (tp) {
                                                        
BBP_cache(tp)->batSharecnt--;
@@ -2385,7 +2385,7 @@ incref(bat i, int logical, int lock)
                tp = tvp = 0;
                refs = ++BBP_lrefs(i);
        } else {
-               tp = -b->theap.parentid;
+               tp = b->theap.parentid;
                assert(tp >= 0);
                tvp = b->tvheap == 0 || b->tvheap->parentid == i ? 0 : 
b->tvheap->parentid;
                refs = ++BBP_refs(i);
@@ -2492,11 +2492,11 @@ decref(bat i, int logical, int releaseSh
                        GDKerror("BBPdecref: %s does not have pointer 
fixes.\n", BBPname(i));
                        assert(0);
                } else {
-                       assert(b == NULL || b->theap.parentid == 0 || 
BBP_refs(-b->theap.parentid) > 0);
+                       assert(b == NULL || b->theap.parentid == 0 || 
BBP_refs(b->theap.parentid) > 0);
                        assert(b == NULL || b->tvheap == NULL || 
b->tvheap->parentid == 0 || BBP_refs(b->tvheap->parentid) > 0);
                        refs = --BBP_refs(i);
                        if (b && refs == 0) {
-                               if ((tp = -b->theap.parentid) != 0)
+                               if ((tp = b->theap.parentid) != 0)
                                        b->theap.base = (char *) (b->theap.base 
- BBP_cache(tp)->theap.base);
                                /* if a view shared the hash with its
                                 * parent, indicate this, but only if
@@ -2759,7 +2759,7 @@ BBPsave(BAT *b)
 static void
 BBPdestroy(BAT *b)
 {
-       bat tp = -b->theap.parentid;
+       bat tp = b->theap.parentid;
        bat vtp = VIEWvtparent(b);
 
        if (isVIEW(b)) {        /* a physical view */
@@ -2793,7 +2793,7 @@ BBPdestroy(BAT *b)
 static gdk_return
 BBPfree(BAT *b, const char *calledFrom)
 {
-       bat bid = b->batCacheid, tp = -VIEWtparent(b), vtp = VIEWvtparent(b);
+       bat bid = b->batCacheid, tp = VIEWtparent(b), vtp = VIEWvtparent(b);
        gdk_return ret;
 
        assert(bid > 0);
diff --git a/gdk/gdk_group.c b/gdk/gdk_group.c
--- a/gdk/gdk_group.c
+++ b/gdk/gdk_group.c
@@ -757,7 +757,7 @@ BATgroup_internal(BAT **groups, BAT **ex
                   (b->batPersistence == PERSISTENT &&
                    BAThash(b, 0) == GDK_SUCCEED)
 #ifndef DISABLE_PARENT_HASH
-                  || ((parent = -VIEWtparent(b)) != 0 &&
+                  || ((parent = VIEWtparent(b)) != 0 &&
                       BATcheckhash(BBPdescriptor(parent)))
 #endif
                ) {
@@ -777,7 +777,7 @@ BATgroup_internal(BAT **groups, BAT **ex
                                  h ? BATgetId(h) : "NULL", h ? BATcount(h) : 0,
                                  subsorted);
 #ifndef DISABLE_PARENT_HASH
-               if (b->thash == NULL && (parent = -VIEWtparent(b)) != 0) {
+               if (b->thash == NULL && (parent = VIEWtparent(b)) != 0) {
                        /* b is a view on another bat (b2 for now).
                         * calculate the bounds [lo, hi) in the parent
                         * that b uses */
diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c
--- a/gdk/gdk_hash.c
+++ b/gdk/gdk_hash.c
@@ -575,7 +575,7 @@ HASHdestroy(BAT *b)
                                  BBP_physical(b->batCacheid),
                                  b->batCacheid > 0 ? "thash" : "hhash");
                } else if (b->thash) {
-                       bat p = -VIEWtparent(b);
+                       bat p = VIEWtparent(b);
                        BAT *hp = NULL;
 
                        if (p)
diff --git a/gdk/gdk_imprints.c b/gdk/gdk_imprints.c
--- a/gdk/gdk_imprints.c
+++ b/gdk/gdk_imprints.c
@@ -189,7 +189,7 @@ BATcheckimprints(BAT *b)
 
        if (VIEWtparent(b)) {
                assert(b->timprints == NULL);
-               b = BBPdescriptor(-VIEWtparent(b));
+               b = BBPdescriptor(VIEWtparent(b));
        }
 
        MT_lock_set(&GDKimprintsLock(b->batCacheid));
@@ -295,7 +295,7 @@ BATimprints(BAT *b)
        assert(b->timprints == NULL);
 
        if (VIEWtparent(b)) {
-               bat p = -VIEWtparent(b);
+               bat p = VIEWtparent(b);
                o = b;
                b = BATdescriptor(p);
                if (BATcheckimprints(b)) {
diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -2698,7 +2698,7 @@ hashjoin(BAT *r1, BAT *r2, BAT *l, BAT *
        rl = BUNfirst(r);
 #ifndef DISABLE_PARENT_HASH
        if (VIEWtparent(r)) {
-               BAT *b = BBPdescriptor(-VIEWtparent(r));
+               BAT *b = BBPdescriptor(VIEWtparent(r));
                if (b->batPersistence == PERSISTENT || BATcheckhash(b)) {
                        /* only use parent's hash if it is persistent
                         * or already has a hash */
@@ -3946,7 +3946,7 @@ BATjoin(BAT **r1p, BAT **r2p, BAT *l, BA
        mem_size = GDK_mem_maxsize / (GDKnr_threads ? GDKnr_threads : 1);
 
 #ifndef DISABLE_PARENT_HASH
-       lparent = -VIEWtparent(l);
+       lparent = VIEWtparent(l);
        if (lparent) {
                lpcount = BATcount(BBPdescriptor(lparent));
                lhash = BATcheckhash(l) || BATcheckhash(BBPdescriptor(lparent));
@@ -3957,7 +3957,7 @@ BATjoin(BAT **r1p, BAT **r2p, BAT *l, BA
                lhash = BATcheckhash(l);
        }
 #ifndef DISABLE_PARENT_HASH
-       rparent = -VIEWtparent(r);
+       rparent = VIEWtparent(r);
        if (rparent) {
                rpcount = BATcount(BBPdescriptor(rparent));
                rhash = BATcheckhash(r) || BATcheckhash(BBPdescriptor(rparent));
diff --git a/gdk/gdk_orderidx.c b/gdk/gdk_orderidx.c
--- a/gdk/gdk_orderidx.c
+++ b/gdk/gdk_orderidx.c
@@ -392,7 +392,7 @@ GDKmergeidx(BAT *b, BAT**a, int n_ar)
                const oid *restrict p, *q;
                /* One oid order bat, nothing to merge */
                assert(BATcount(a[0]) == BATcount(b));
-               assert((-VIEWtparent(a[0]) == b->batCacheid ||
+               assert((VIEWtparent(a[0]) == b->batCacheid ||
                        VIEWtparent(a[0]) == VIEWtparent(b)) &&
                       a[0]->torderidx);
                p = (const oid *) a[0]->torderidx->base + ORDERIDXOFF;
@@ -420,10 +420,10 @@ GDKmergeidx(BAT *b, BAT**a, int n_ar)
                /* sort merge with 1 comparison per BUN */
                const oid *restrict p0, *restrict p1, *q0, *q1;
                assert(BATcount(a[0]) + BATcount(a[1]) == BATcount(b));
-               assert((-VIEWtparent(a[0]) == b->batCacheid ||
+               assert((VIEWtparent(a[0]) == b->batCacheid ||
                        VIEWtparent(a[0]) == VIEWtparent(b)) &&
                       a[0]->torderidx);
-               assert((-VIEWtparent(a[1]) == b->batCacheid ||
+               assert((VIEWtparent(a[1]) == b->batCacheid ||
                        VIEWtparent(a[1]) == VIEWtparent(b)) &&
                       a[1]->torderidx);
                p0 = (const oid *) a[0]->torderidx->base + ORDERIDXOFF;
@@ -467,7 +467,7 @@ GDKmergeidx(BAT *b, BAT**a, int n_ar)
                        return GDK_FAIL;
                }
                for (i = 0; i < n_ar; i++) {
-                       assert((-VIEWtparent(a[i]) == b->batCacheid ||
+                       assert((VIEWtparent(a[i]) == b->batCacheid ||
                                VIEWtparent(a[i]) == VIEWtparent(b)) &&
                               a[i]->torderidx);
                        p[i] = (oid *) a[i]->torderidx->base + ORDERIDXOFF;
diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -172,7 +172,7 @@ BAT_hashselect(BAT *b, BAT *s, BAT *bn, 
 
 #ifndef DISABLE_PARENT_HASH
        if (VIEWtparent(b)) {
-               BAT *b2 = BBPdescriptor(-VIEWtparent(b));
+               BAT *b2 = BBPdescriptor(VIEWtparent(b));
                if (b2->batPersistence == PERSISTENT || BATcheckhash(b2)) {
                        /* only use parent's hash if it is persistent
                         * or already has a hash */
@@ -546,7 +546,7 @@ NAME##_##TYPE(BAT *b, BAT *s, BAT *bn, c
        assert(lval);                                                   \
        assert(hval);                                                   \
        if (use_imprints && VIEWtparent(b)) {                           \
-               BAT *parent = BATdescriptor(-VIEWtparent(b));           \
+               BAT *parent = BATdescriptor(VIEWtparent(b));            \
                basesrc = (const TYPE *) Tloc(parent, BUNfirst(parent)); \
                imprints = parent->timprints;                           \
                pr_off = (BUN) ((TYPE *)Tloc(b,0) -                     \
@@ -1415,12 +1415,12 @@ BATselect(BAT *b, BAT *s, const void *tl
            !(b->tsorted || b->trevsorted) &&
            (!s || (s && BATtdense(s)))    &&
            (BATcheckorderidx(b) ||
-            (VIEWtparent(b) && BATcheckorderidx(BBPquickdesc(-VIEWtparent(b), 
0)))))
+            (VIEWtparent(b) && BATcheckorderidx(BBPquickdesc(VIEWtparent(b), 
0)))))
        {
                BAT *view = NULL;
                if (VIEWtparent(b) && !BATcheckorderidx(b)) {
                        view = b;
-                       b = BBPdescriptor(-VIEWtparent(b));
+                       b = BBPdescriptor(VIEWtparent(b));
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to