Changeset: 0d0ecbfe9a50 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0d0ecbfe9a50
Modified Files:
        gdk/gdk.h
        gdk/gdk_aggr.c
        gdk/gdk_align.c
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        gdk/gdk_bbp.c
        gdk/gdk_cand.c
        gdk/gdk_delta.c
        gdk/gdk_hash.c
        gdk/gdk_heap.c
        gdk/gdk_orderidx.c
        gdk/gdk_storage.c
        gdk/gdk_strimps.c
        gdk/gdk_tm.c
        gdk/gdk_unique.c
        monetdb5/mal/mal_client.c
        monetdb5/mal/mal_dataflow.c
        monetdb5/mal/mal_debugger.c
        monetdb5/modules/mal/tablet.c
        sql/storage/bat/bat_storage.c
Branch: Jan2022
Log Message:

Merge with Jul2021 branch.


diffs (truncated from 758 to 300 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -762,8 +762,8 @@ typedef struct BAT {
        /* dynamic bat properties */
        bool
         batCopiedtodisk:1,     /* once written */
-        batDirtyflushed:1,     /* was dirty before commit started? */
-        batDirtydesc:1,        /* bat descriptor dirty marker */
+        batDirtyflushed:1,     /* was dirty before commit started? (not used) 
*/
+        batDirtydesc:1,        /* bat descriptor dirty marker (not used) */
         batTransient:1;        /* should the BAT persist on disk? */
        uint8_t /* adjacent bit fields are packed together (if they fit) */
         batRestricted:2;       /* access privileges */
@@ -1369,8 +1369,6 @@ BATsettrivprop(BAT *b)
 {
        assert(!is_oid_nil(b->hseqbase));
        assert(is_oid_nil(b->tseqbase) || ATOMtype(b->ttype) == TYPE_oid);
-       if (!b->batDirtydesc)
-               return;
        if (b->ttype == TYPE_void) {
                if (is_oid_nil(b->tseqbase)) {
                        b->tnonil = b->batCount == 0;
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -3779,7 +3779,6 @@ BATmin_skipnil(BAT *b, void *aggr, bit s
                                        MT_lock_set(&b->theaplock);
                                        if (b->batCount == bi.count) {
                                                b->tnonil = true;
-                                               b->batDirtydesc = true;
                                        }
                                        MT_lock_unset(&b->theaplock);
                                }
diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c
--- a/gdk/gdk_align.c
+++ b/gdk/gdk_align.c
@@ -255,7 +255,6 @@ BATmaterialize(BAT *b)
        b->tunique_est = is_oid_nil(t) ? 1.0 : (double) b->batCount;
        b->ttype = TYPE_oid;
        BATsetdims(b, 0);
-       b->batDirtydesc = true;
        BATsetcount(b, b->batCount);
        MT_lock_unset(&b->theaplock);
 
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -97,7 +97,6 @@ BATcreatedesc(oid hseq, int tt, bool hea
                .batRole = role,
                .batTransient = true,
                .batRestricted = BAT_WRITE,
-               .batDirtydesc = true,
        };
        if (heapnames && (bn->theap = GDKmalloc(sizeof(Heap))) == NULL) {
                GDKfree(bn);
@@ -635,7 +634,6 @@ BATclear(BAT *b, bool force)
        b->theap->free = 0;
        BAThseqbase(b, 0);
        BATtseqbase(b, ATOMtype(b->ttype) == TYPE_oid ? 0 : oid_nil);
-       b->batDirtydesc = true;
        b->theap->dirty = true;
        BATsettrivprop(b);
        b->tnosorted = b->tnorevsorted = 0;
@@ -924,7 +922,6 @@ COLcopy(BAT *b, int tt, bool writable, r
                BATkey(bn, BATtkey(b));
                bn->tsorted = BATtordered(b);
                bn->trevsorted = BATtrevordered(b);
-               bn->batDirtydesc = true;
                bn->tnorevsorted = b->tnorevsorted;
                if (b->tnokey[0] != b->tnokey[1]) {
                        bn->tnokey[0] = b->tnokey[0];
@@ -1058,7 +1055,6 @@ BUNappendmulti(BAT *b, const void *value
        }
 
        MT_lock_set(&b->theaplock);
-       b->batDirtydesc = true;
        if (count > BATcount(b) / GDK_UNIQUE_ESTIMATE_KEEP_FRACTION)
                b->tunique_est = 0;
        b->theap->dirty = true;
@@ -1363,7 +1359,6 @@ BUNdelete(BAT *b, oid o)
        }
        if (!locked)
                MT_lock_set(&b->theaplock);
-       b->batDirtydesc = true;
        if (b->tnosorted >= p)
                b->tnosorted = 0;
        if (b->tnorevsorted >= p)
@@ -1673,7 +1668,6 @@ BUNinplacemulti(BAT *b, const oid *posit
        MT_lock_set(&b->theaplock);
        b->tminpos = bi.minpos;
        b->tmaxpos = bi.maxpos;
-       b->batDirtydesc = true;
        b->theap->dirty = true;
        if (b->tvheap)
                b->tvheap->dirty = true;
@@ -1888,10 +1882,10 @@ BATsetcount(BAT *b, BUN cnt)
        assert(cnt <= BUN_MAX);
 
        b->batCount = cnt;
-       b->batDirtydesc = true;
-       b->theap->dirty |= b->ttype != TYPE_void && b->theap->parentid == 
b->batCacheid && cnt > 0;
-       if (b->theap->parentid == b->batCacheid)
+       if (b->theap->parentid == b->batCacheid) {
+               b->theap->dirty |= b->ttype != TYPE_void && cnt > 0;
                b->theap->free = tailsize(b, cnt);
+       }
        if (b->ttype == TYPE_void)
                b->batCapacity = cnt;
        if (cnt <= 1) {
@@ -1946,8 +1940,6 @@ BATkey(BAT *b, bool flag)
                        return GDK_FAIL;
                }
        }
-       if (b->tkey != flag)
-               b->batDirtydesc = true;
        b->tkey = flag;
        if (!flag) {
                b->tseqbase = oid_nil;
@@ -1977,7 +1969,6 @@ BAThseqbase(BAT *b, oid o)
                assert(o <= GDK_oid_max);       /* i.e., not oid_nil */
                assert(o + BATcount(b) <= GDK_oid_max);
                if (b->hseqbase != o) {
-                       b->batDirtydesc = true;
                        b->hseqbase = o;
                }
        }
@@ -1990,9 +1981,6 @@ BATtseqbase(BAT *b, oid o)
        if (b == NULL)
                return;
        assert(is_oid_nil(o) || o + BATcount(b) <= GDK_oid_max);
-       if (b->tseqbase != o) {
-               b->batDirtydesc = true;
-       }
        if (ATOMtype(b->ttype) == TYPE_oid) {
                b->tseqbase = o;
 
@@ -2271,7 +2259,6 @@ BATcheckmodes(BAT *b, bool existing)
                return GDK_FAIL;
 
        if (dirty) {
-               b->batDirtydesc = true;
                b->theap->newstorage = m1;
                if (b->tvheap)
                        b->tvheap->newstorage = m3;
@@ -2283,7 +2270,6 @@ BAT *
 BATsetaccess(BAT *b, restrict_t newmode)
 {
        restrict_t bakmode;
-       bool bakdirty;
 
        BATcheck(b, NULL);
        if ((isVIEW(b) || b->batSharecnt) && newmode != BAT_READ) {
@@ -2294,7 +2280,6 @@ BATsetaccess(BAT *b, restrict_t newmode)
                b = bn;
        }
        bakmode = (restrict_t) b->batRestricted;
-       bakdirty = b->batDirtydesc;
        if (bakmode != newmode) {
                bool existing = (BBP_status(b->batCacheid) & BBPEXISTING) != 0;
                bool wr = (newmode == BAT_WRITE);
@@ -2316,7 +2301,6 @@ BATsetaccess(BAT *b, restrict_t newmode)
 
                /* set new access mode and mmap modes */
                b->batRestricted = (unsigned int) newmode;
-               b->batDirtydesc = true;
                b->theap->newstorage = m1;
                if (b->tvheap)
                        b->tvheap->newstorage = m3;
@@ -2324,7 +2308,6 @@ BATsetaccess(BAT *b, restrict_t newmode)
                if (existing && BBPsave(b) != GDK_SUCCEED) {
                        /* roll back all changes */
                        b->batRestricted = (unsigned int) bakmode;
-                       b->batDirtydesc = bakdirty;
                        b->theap->newstorage = b1;
                        if (b->tvheap)
                                b->tvheap->newstorage = b3;
@@ -2506,6 +2489,8 @@ BATassertProps(BAT *b)
 
        /* general BAT sanity */
        assert(b != NULL);
+       assert(!b->batDirtydesc); /* not used anymore, must always be false */
+       assert(!b->batDirtyflushed); /* not used anymore, must always be false 
*/
        assert(b->batCacheid > 0);
        assert(b->batCount >= b->batInserted);
 
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -97,7 +97,6 @@ insert_string_bat(BAT *b, BAT *n, struct
                HEAPincref(ni.vh);
                b->tvheap = ni.vh;
                BBPshare(ni.vh->parentid);
-               b->batDirtydesc = true;
                MT_lock_unset(&b->theaplock);
                toff = 0;
                MT_thread_setalgorithm("share vheap");
@@ -381,7 +380,6 @@ append_varsized_bat(BAT *b, BAT *n, stru
                HEAPdecref(b->tvheap, true);
                HEAPincref(ni.vh);
                b->tvheap = ni.vh;
-               b->batDirtydesc = true;
                MT_lock_unset(&b->theaplock);
        }
        if (b->tvheap == ni.vh) {
@@ -736,8 +734,6 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool 
 
        MT_lock_set(&b->theaplock);
 
-       b->batDirtydesc = true;
-
        if (BATcount(b) == 0 || b->tmaxpos != BUN_NONE) {
                if (ni.maxpos != BUN_NONE) {
                        BATiter bi = bat_iterator_nolock(b);
@@ -1883,17 +1879,23 @@ BATslice(BAT *b, BUN l, BUN h)
                const TPE *restrict vals = Tloc(b, 0);                  \
                for (BUN q = BUNlast(b), p = 1; p < q; p++) {           \
                        if (vals[p - 1] > vals[p]) {                    \
+                               MT_lock_set(&b->theaplock);             \
                                b->tnosorted = p;                       \
+                               MT_lock_unset(&b->theaplock);           \
                                TRC_DEBUG(ALGO, "Fixed nosorted(" BUNFMT ") for 
" ALGOBATFMT " (" LLFMT " usec)\n", p, ALGOBATPAR(b), GDKusec() - t0); \
                                goto doreturn;                          \
                        } else if (vals[p - 1] < vals[p]) {             \
+                               MT_lock_set(&b->theaplock);             \
                                if (!b->trevsorted && b->tnorevsorted == 0) { \
                                        b->tnorevsorted = p;            \
                                        TRC_DEBUG(ALGO, "Fixed norevsorted(" 
BUNFMT ") for " ALGOBATFMT "\n", p, ALGOBATPAR(b)); \
                                }                                       \
+                               MT_lock_unset(&b->theaplock);           \
                        } else if (!b->tkey && b->tnokey[1] == 0) {     \
+                               MT_lock_set(&b->theaplock);             \
                                b->tnokey[0] = p - 1;                   \
                                b->tnokey[1] = p;                       \
+                               MT_lock_unset(&b->theaplock);           \
                                TRC_DEBUG(ALGO, "Fixed nokey(" BUNFMT "," 
BUNFMT") for " ALGOBATFMT "\n", p - 1, p, ALGOBATPAR(b)); \
                        }                                               \
                }                                                       \
@@ -1909,17 +1911,23 @@ BATslice(BAT *b, BUN l, BUN h)
                        int cmp = prevnil ? -!(prevnil = is_##TPE##_nil(next)) 
: (prevnil = is_##TPE##_nil(next)) ? 1 : (prev > next) - (prev < next); \
                        prev = next;                                    \
                        if (cmp > 0) {                                  \
+                               MT_lock_set(&b->theaplock);             \
                                b->tnosorted = p;                       \
+                               MT_lock_unset(&b->theaplock);           \
                                TRC_DEBUG(ALGO, "Fixed nosorted(" BUNFMT ") for 
" ALGOBATFMT " (" LLFMT " usec)\n", p, ALGOBATPAR(b), GDKusec() - t0); \
                                goto doreturn;                          \
                        } else if (cmp < 0) {                           \
+                               MT_lock_set(&b->theaplock);             \
                                if (!b->trevsorted && b->tnorevsorted == 0) { \
                                        b->tnorevsorted = p;            \
                                        TRC_DEBUG(ALGO, "Fixed norevsorted(" 
BUNFMT ") for " ALGOBATFMT "\n", p, ALGOBATPAR(b)); \
                                }                                       \
+                               MT_lock_unset(&b->theaplock);           \
                        } else if (!b->tkey && b->tnokey[1] == 0) {     \
+                               MT_lock_set(&b->theaplock);             \
                                b->tnokey[0] = p - 1;                   \
                                b->tnokey[1] = p;                       \
+                               MT_lock_unset(&b->theaplock);           \
                                TRC_DEBUG(ALGO, "Fixed nokey(" BUNFMT "," 
BUNFMT") for " ALGOBATFMT "\n", p - 1, p, ALGOBATPAR(b)); \
                        }                                               \
                }                                                       \
@@ -1947,7 +1955,6 @@ BATordered(BAT *b)
        MT_lock_set(&b->batIdxLock);
        BATiter bi = bat_iterator_nolock(b);
        if (!b->tsorted && b->tnosorted == 0) {
-               b->batDirtydesc = true;
                switch (ATOMbasetype(b->ttype)) {
                case TYPE_bte:
                        BAT_ORDERED(bte);
@@ -1989,19 +1996,25 @@ BATordered(BAT *b)
                                else
                                        c = strcmp(p1, p2);
                                if (c > 0) {
+                                       MT_lock_set(&b->theaplock);
                                        b->tnosorted = p;
+                                       MT_lock_unset(&b->theaplock);
                                        TRC_DEBUG(ALGO, "Fixed nosorted(" 
BUNFMT ") for " ALGOBATFMT " (" LLFMT " usec)\n", p, ALGOBATPAR(b), GDKusec() - 
t0);
                                        goto doreturn;
                                } else if (c < 0) {
+                                       MT_lock_set(&b->theaplock);
                                        assert(!b->trevsorted);
                                        if (b->tnorevsorted == 0) {
                                                b->tnorevsorted = p;
                                                TRC_DEBUG(ALGO, "Fixed 
norevsorted(" BUNFMT ") for " ALGOBATFMT "\n", p, ALGOBATPAR(b));
                                        }
+                                       MT_lock_unset(&b->theaplock);
                                } else if (b->tnokey[1] == 0) {
+                                       MT_lock_set(&b->theaplock);
                                        assert(!b->tkey);
                                        b->tnokey[0] = p - 1;
                                        b->tnokey[1] = p;
+                                       MT_lock_unset(&b->theaplock);
                                        TRC_DEBUG(ALGO, "Fixed nokey(" BUNFMT 
"," BUNFMT") for " ALGOBATFMT "\n", p - 1, p, ALGOBATPAR(b));
                                }
                        }
@@ -2011,17 +2024,23 @@ BATordered(BAT *b)
                        for (BUN q = BUNlast(b), p = 1; p < q; p++) {
                                int c;
                                if ((c = cmpf(BUNtail(bi, p - 1), BUNtail(bi, 
p))) > 0) {
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to