Changeset: bea23889c724 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/bea23889c724
Modified Files:
        gdk/gdk.h
        gdk/gdk_aggr.c
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        gdk/gdk_bbp.c
        gdk/gdk_delta.c
        gdk/gdk_hash.c
        gdk/gdk_orderidx.c
        gdk/gdk_storage.c
        gdk/gdk_unique.c
        monetdb5/extras/rapi/rapi.c
        monetdb5/mal/mal_debugger.c
        monetdb5/modules/kernel/bat5.c
        monetdb5/modules/mal/tablet.c
        sql/backends/monet5/UDF/pyapi3/conversion3.c
        sql/backends/monet5/UDF/pyapi3/convert_loops.h
        sql/storage/bat/bat_storage.c
Branch: default
Log Message:

Removed batDirtydesc bit.
The bit recorded whether any value that was to be saved in the BBP.dir
file for a bat was changed, but that is not needed since all of those
values get saved when the bat gets committed, whether changed or not.


diffs (truncated from 620 to 300 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -681,7 +681,6 @@ gdk_export bool VALisnil(const ValRecord
  *           bool   batCopiedtodisk;  // BAT is saved on disk?
  *           // dynamic BAT properties
  *           int    batHeat;          // heat of BAT in the BBP
- *           bool   batDirtydesc;     // BAT descriptor specific dirty flag
  *           Heap*  batBuns;          // Heap where the buns are stored
  *           // DELTA status
  *           BUN    batInserted;      // first inserted BUN
@@ -772,20 +771,17 @@ typedef enum {
        BAT_APPEND,               /* only reads and appends allowed */
 } restrict_t;
 
-/* batDirtydesc: should be set (true) if any of the following fields
- * have changed since the bat was last saved: hseqbase, batRestricted,
- * batTransient, batCount, and the theap properties tkey, tseqbase,
- * tsorted, trevsorted, twidth, tshift, tnonil, tnil, tnokey, tnosorted,
- * tnorevsorted, tminpos, tmaxpos, and tunique_est; in addition, the
- * value should be set if the BBP field BBP_logical(bid) is changed.
- * This corresponds with any field that gets saved in the BBP.dir file.
- *
- * theaplock: this lock should be held when reading or writing any of
- * the fields mentioned above for batDirtydesc, and also when reading or
- * writing any of the following fields: batDirtydesc, theap, tvheap,
- * batInserted, batCapacity.  There is no need for the lock if the bat
- * cannot possibly be modified concurrently, e.g. when it is new and not
- * yet returned to the interpreter or during system initialization. */
+/* theaplock: this lock should be held when reading or writing any of
+ * the fields that are saved in the BBP.dir file (plus any, if any, that
+ * share bitfields with any of the fields), i.e. hseqbase,
+ * batRestricted, batTransient, batCount, and the theap properties tkey,
+ * tseqbase, tsorted, trevsorted, twidth, tshift, tnonil, tnil, tnokey,
+ * tnosorted, tnorevsorted, tminpos, tmaxpos, and tunique_est, also when
+ * BBP_logical(bid) is changed, and also when reading or writing any of
+ * the following fields: theap, tvheap, batInserted, batCapacity.  There
+ * is no need for the lock if the bat cannot possibly be modified
+ * concurrently, e.g. when it is new and not yet returned to the
+ * interpreter or during system initialization. */
 typedef struct BAT {
        /* static bat properties */
        oid hseqbase;           /* head seq base */
@@ -797,8 +793,7 @@ typedef struct BAT {
        restrict_t batRestricted:2; /* access privileges */
        bool
         batTransient:1,        /* should the BAT persist on disk? */
-        batCopiedtodisk:1,     /* once written */
-        batDirtydesc:1;        /* bat descriptor dirty marker */
+        batCopiedtodisk:1;     /* once written */
        /* not part of bitfields since not in BATiter */
        bool batDirtyflushed;   /* was dirty before commit started? */
        uint16_t selcnt;        /* how often used in equi select without hash */
@@ -975,7 +970,6 @@ typedef struct BATiter {
                revsorted:1,
                hdirty:1,
                vhdirty:1,
-               dirtydesc:1,
                copiedtodisk:1,
                transient:1;
        restrict_t restricted:2;
@@ -1028,7 +1022,6 @@ bat_iterator_nolock(BAT *b)
                        .hdirty = b->theap->parentid == b->batCacheid && 
b->theap->dirty,
                        /* also, if there is no vheap, it's not dirty */
                        .vhdirty = b->tvheap && b->tvheap->parentid == 
b->batCacheid && b->tvheap->dirty,
-                       .dirtydesc = b->batDirtydesc,
                        .copiedtodisk = b->batCopiedtodisk,
                        .transient = b->batTransient,
                        .restricted = b->batRestricted,
@@ -1305,15 +1298,10 @@ gdk_export BAT *BATsetaccess(BAT *b, res
 gdk_export restrict_t BATgetaccess(BAT *b);
 
 
-#define BATdirtydata(b)        (!(b)->batCopiedtodisk ||                       
\
+#define BATdirty(b)    (!(b)->batCopiedtodisk ||                       \
                         (b)->theap->dirty ||                           \
                         ((b)->tvheap != NULL && (b)->tvheap->dirty))
-#define BATdirty(b)    (BATdirtydata(b) ||     \
-                        (b)->batDirtydesc)
-#define BATdirtybi(bi) (!(bi).copiedtodisk ||  \
-                        (bi).dirtydesc ||      \
-                        (bi).hdirty ||         \
-                        (bi).vhdirty)
+#define BATdirtybi(bi) (!(bi).copiedtodisk || (bi).hdirty || (bi).vhdirty)
 
 #define BATcapacity(b) (b)->batCapacity
 /*
@@ -1434,8 +1422,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;
@@ -1450,23 +1436,29 @@ BATsettrivprop(BAT *b)
                }
                b->tsorted = true;
        } else if (b->batCount <= 1) {
+               b->tnosorted = b->tnorevsorted = 0;
+               b->tnokey[0] = b->tnokey[1] = 0;
+               b->tunique_est = b->batCount;
                if (ATOMlinear(b->ttype)) {
                        b->tsorted = true;
                        b->trevsorted = true;
                }
                b->tkey = true;
                if (b->batCount == 0) {
+                       b->tminpos = BUN_NONE;
+                       b->tmaxpos = BUN_NONE;
                        b->tnonil = true;
                        b->tnil = false;
                        if (b->ttype == TYPE_oid) {
                                b->tseqbase = 0;
                        }
                } else if (b->ttype == TYPE_oid) {
-                       /* b->batCount == 1 */
                        oid sqbs = ((const oid *) b->theap->base)[b->tbaseoff];
                        if (is_oid_nil(sqbs)) {
                                b->tnonil = false;
                                b->tnil = true;
+                               b->tminpos = BUN_NONE;
+                               b->tmaxpos = BUN_NONE;
                        } else {
                                b->tnonil = true;
                                b->tnil = false;
@@ -1474,6 +1466,19 @@ BATsettrivprop(BAT *b)
                                b->tmaxpos = 0;
                        }
                        b->tseqbase = sqbs;
+               } else if ((b->tvheap
+                           ? ATOMcmp(b->ttype,
+                                     b->tvheap->base + VarHeapVal(Tloc(b, 0), 
0, b->twidth),
+                                     ATOMnilptr(b->ttype))
+                           : ATOMcmp(b->ttype, Tloc(b, 0),
+                                     ATOMnilptr(b->ttype))) == 0) {
+                       /* the only value is NIL */
+                       b->tminpos = BUN_NONE;
+                       b->tmaxpos = BUN_NONE;
+               } else {
+                       /* the only value is both min and max */
+                       b->tminpos = 0;
+                       b->tmaxpos = 0;
                }
        } else if (b->batCount == 2 && ATOMlinear(b->ttype)) {
                int c;
@@ -1490,6 +1495,7 @@ BATsettrivprop(BAT *b)
                b->tkey = c != 0;
                b->tnokey[0] = 0;
                b->tnokey[1] = !b->tkey;
+               b->tunique_est = 1 + b->tkey;
        } else if (!ATOMlinear(b->ttype)) {
                b->tsorted = false;
                b->trevsorted = false;
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -3644,7 +3644,6 @@ BATmin_skipnil(BAT *b, void *aggr, bit s
                                        /* there are no nils, record that */
                                        MT_lock_set(&b->theaplock);
                                        b->tnonil = true;
-                                       b->batDirtydesc = true;
                                        MT_lock_unset(&b->theaplock);
                                }
                        } else {
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);
@@ -642,14 +641,8 @@ 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;
-       b->tnokey[0] = b->tnokey[1] = 0;
-       b->tminpos = BUN_NONE;
-       b->tmaxpos = BUN_NONE;
-       b->tunique_est = 0.0;
        MT_lock_unset(&b->theaplock);
        return GDK_SUCCEED;
 }
@@ -934,7 +927,6 @@ COLcopy(BAT *b, int tt, bool writable, r
                BATkey(bn, BATtkey(b));
                bn->tsorted = bi.sorted;
                bn->trevsorted = bi.revsorted;
-               bn->batDirtydesc = true;
                bn->tnorevsorted = bi.norevsorted;
                if (bi.nokey[0] != bi.nokey[1]) {
                        bn->tnokey[0] = bi.nokey[0];
@@ -1326,7 +1318,6 @@ BUNdelete(BAT *b, oid o)
         * unlocked (since we're the only thread that should be changing
         * anything) */
        MT_lock_set(&b->theaplock);
-       b->batDirtydesc = true;
        if (b->tmaxpos == p)
                b->tmaxpos = BUN_NONE;
        if (b->tminpos == p)
@@ -1895,7 +1886,6 @@ BATsetcount(BAT *b, BUN cnt)
        assert(cnt <= BUN_MAX);
 
        b->batCount = cnt;
-       b->batDirtydesc = true;
        if (b->theap->parentid == b->batCacheid) {
                b->theap->dirty |= b->ttype != TYPE_void && cnt > 0;
                b->theap->free = tailsize(b, cnt);
@@ -1954,8 +1944,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;
@@ -1984,10 +1972,7 @@ BAThseqbase(BAT *b, oid o)
        if (b != NULL) {
                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;
-               }
+               b->hseqbase = o;
        }
 }
 
@@ -1998,9 +1983,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;
 
@@ -2290,7 +2272,6 @@ BAT *
 BATsetaccess(BAT *b, restrict_t newmode)
 {
        restrict_t bakmode;
-       bool bakdirty;
 
        BATcheck(b, NULL);
        if (newmode != BAT_READ && (isVIEW(b) || b->batSharecnt)) {
@@ -2302,7 +2283,6 @@ BATsetaccess(BAT *b, restrict_t newmode)
        }
        MT_lock_set(&b->theaplock);
        bakmode = b->batRestricted;
-       bakdirty = b->batDirtydesc;
        if (bakmode != newmode) {
                bool existing = (BBP_status(b->batCacheid) & BBPEXISTING) != 0;
                bool wr = (newmode == BAT_WRITE);
@@ -2327,7 +2307,6 @@ BATsetaccess(BAT *b, restrict_t newmode)
 
                /* set new access mode and mmap modes */
                b->batRestricted = newmode;
-               b->batDirtydesc = true;
                if (b->theap->parentid == b->batCacheid)
                        b->theap->newstorage = m1;
                if (b->tvheap && b->tvheap->parentid == b->batCacheid)
@@ -2338,7 +2317,6 @@ BATsetaccess(BAT *b, restrict_t newmode)
                        /* roll back all changes */
                        MT_lock_set(&b->theaplock);
                        b->batRestricted = bakmode;
-                       b->batDirtydesc = bakdirty;
                        b->theap->newstorage = b1;
                        if (b->tvheap)
                                b->tvheap->newstorage = b3;
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -704,8 +704,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);
@@ -1934,7 +1932,6 @@ BATordered(BAT *b)
         * changes to the bat descriptor. */
        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);
@@ -2087,7 +2084,6 @@ BATordered_rev(BAT *b)
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to