Changeset: de96ad676406 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/de96ad676406
Modified Files:
        gdk/gdk.h
        gdk/gdk_align.c
        gdk/gdk_bbp.c
        gdk/gdk_string.c
Branch: ustr
Log Message:

Introduced tvkey property, set if the vheap does not contain duplicates.


diffs (125 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -398,6 +398,7 @@ typedef struct BAT {
        /* see also comment near BATassertProps() for more information
         * about the properties */
        bool tkey:1;            /* no duplicate values present */
+       bool tvkey:1;           /* no duplicate values in tvheap */
        bool tnonil:1;          /* there are no nils in the column */
        bool tnil:1;            /* there is a nil in the column */
        bool tsorted:1;         /* column is sorted in ascending order */
@@ -603,6 +604,7 @@ typedef struct BATiter {
        uint8_t shift;
        int8_t type;
        bool key:1,
+               vkey:1,
                nonil:1,
                nil:1,
                sorted:1,
@@ -655,6 +657,7 @@ bat_iterator_nolock(BAT *b)
                        .maxpos = isview ? BUN_NONE : b->tmaxpos,
                        .unique_est = b->tunique_est,
                        .key = b->tkey,
+                       .vkey = b->tvkey,
                        .nonil = b->tnonil,
                        .nil = b->tnil,
                        .sorted = b->tsorted,
diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c
--- a/gdk/gdk_align.c
+++ b/gdk/gdk_align.c
@@ -170,6 +170,7 @@ VIEWcreate(oid seq, BAT *b, BUN l, BUN h
         * accelerator data. We need copies because in case of a mark,
         * we are going to override a column with a void. */
        bn->tkey = bi.key;
+       bn->tvkey = bi.vkey;
        bn->tseqbase = bi.tseq;
        bn->tsorted = bi.sorted;
        bn->trevsorted = bi.revsorted;
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -519,7 +519,7 @@ heapinit(BAT *b, const char *buf,
 #endif
 #endif
 
-       if (properties & (bbpversion <= GDKLIBRARY_USTR ? ~0x1F81 : ~0x3F81)) {
+       if (properties & (bbpversion <= GDKLIBRARY_USTR ? ~0x1F81 : ~0x7F81)) {
                TRC_CRITICAL(GDK, "unknown properties are set: incompatible 
database on line %d of BBP.dir\n", lineno);
                return -1;
        }
@@ -560,6 +560,7 @@ heapinit(BAT *b, const char *buf,
        b->tnil = (properties & 0x0800) != 0;
        b->tascii = (properties & 0x1000) != 0;
        b->ustr = (bbpversion <= GDKLIBRARY_USTR) ? false : (properties & 
0x2000) != 0;
+       b->tvkey = (bbpversion <= GDKLIBRARY_USTR) ? false : (properties & 
0x4000) != 0;
        b->tnosorted = (BUN) nosorted;
        b->tnorevsorted = (BUN) norevsorted;
        b->tunique_est = 0.0;
@@ -2096,19 +2097,20 @@ heap_entry(FILE *fp, BATiter *bi, BUN si
                        free = 0;
        }
 
-       return fprintf(fp, " %s %d %d %d " BUNFMT " " BUNFMT " " BUNFMT " "
+       return fprintf(fp, " %s %" PRIu16 " %d %d " BUNFMT " " BUNFMT " " 
BUNFMT " "
                       BUNFMT " " OIDFMT " %zu %" PRIu64" %" PRIu64,
                       bi->type >= 0 ? BATatoms[bi->type].name : 
ATOMunknown_name(bi->type),
                       bi->width,
                       bi->type == TYPE_void || bi->vh != NULL || bi->ustr,
-                      (((unsigned short) bi->sorted << 0) |
-                       ((unsigned short) bi->revsorted << 7) |
-                       ((unsigned short) bi->key << 8) |
-                       ((unsigned short) BATtdensebi(bi) << 9) |
-                       ((unsigned short) bi->nonil << 10) |
-                       ((unsigned short) bi->nil << 11) |
-                       ((unsigned short) bi->ascii << 12) |
-                       ((unsigned short) bi->ustr << 13)),
+                      (((uint16_t) bi->sorted << 0) |
+                       ((uint16_t) bi->revsorted << 7) |
+                       ((uint16_t) bi->key << 8) |
+                       ((uint16_t) BATtdensebi(bi) << 9) |
+                       ((uint16_t) bi->nonil << 10) |
+                       ((uint16_t) bi->nil << 11) |
+                       ((uint16_t) bi->ascii << 12) |
+                       ((uint16_t) bi->ustr << 13) |
+                       ((uint16_t) bi->vkey << 14)),
                       bi->nokey[0] >= size || bi->nokey[1] >= size ? 0 : 
bi->nokey[0],
                       bi->nokey[0] >= size || bi->nokey[1] >= size ? 0 : 
bi->nokey[1],
                       bi->nosorted >= size ? 0 : bi->nosorted,
diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c
--- a/gdk/gdk_string.c
+++ b/gdk/gdk_string.c
@@ -249,6 +249,7 @@ ustrPut(BAT *b, var_t *dst, const char *
                        return (var_t) -1;
                }
        }
+       assert(ustrbat->tvkey);
        BUN p = BUNfnd(ustrbat, v);
        if (p == BUN_NONE) {
                /* string does not yet occur in ustrbat */
@@ -278,6 +279,7 @@ ustrPut(BAT *b, var_t *dst, const char *
                MT_rwlock_wrunlock(&ustrbat->thashlock);
                ustrbat->tunique_est = (double) ustrbat->batCount;
                ustrbat->tkey = true;
+               ustrbat->tvkey = true;
                MT_lock_unset(&ustrbat->theaplock);
        }
        var_t d = VarHeapVal(ustrbat->theap->base, p, ustrbat->twidth);
@@ -403,6 +405,7 @@ strPut(BAT *b, var_t *dst, const void *V
 #endif
                h->dirty = true;
                b->tascii = true;
+               b->tvkey = true;
        }
 
        off = strHash(v);
@@ -505,7 +508,8 @@ strPut(BAT *b, var_t *dst, const void *V
                 * string */
                pos -= sizeof(stridx_t);
                *(stridx_t *) (h->base + pos) = *bucket;
-       }
+       } else if (*bucket != 0)
+               b->tvkey = false;       /* we no longer know for sure */
        *bucket = (stridx_t) pos;       /* set bucket to the new string */
        h->dirty = true;
 
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to