Changeset: 8586ef40cf5d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8586ef40cf5d
Modified Files:
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        gdk/gdk_hash.h
Branch: Mar2018
Log Message:

We cannot maintain persistent hashes when appending data.
It would involve first invalidating the persisted hash (write system
call + sync) to clear the sync bit, then adding the value to the hash
table (another write + sync), and finally setting the sync bit again
(third write + sync).  It's not worth it, at least for now.


diffs (53 lines):

diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -1057,8 +1057,10 @@ BUNappend(BAT *b, const void *t, bit for
        OIDXdestroy(b);
        PROPdestroy(b->tprops);
        b->tprops = NULL;
-       if (b->thash == (Hash *) 1) {
-               /* don't bother first loading the hash to then change it */
+       if (b->thash == (Hash *) 1 ||
+           (b->thash && ((size_t *) b->thash->heap.base)[0] & (1 << 24))) {
+               /* don't bother first loading the hash to then change
+                * it, also, cannot maintain persistent hashes */
                HASHdestroy(b);
        }
        if (b->thash) {
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -584,9 +584,11 @@ BATappend(BAT *b, BAT *n, BAT *s, bit fo
        OIDXdestroy(b);
        PROPdestroy(b->tprops);
        b->tprops = NULL;
-       if (b->thash == (Hash *) 1 || BATcount(b) == 0) {
+       if (b->thash == (Hash *) 1 || BATcount(b) == 0 ||
+           (b->thash && ((size_t *) b->thash->heap.base)[0] & (1 << 24))) {
                /* don't bother first loading the hash to then change
-                * it, or updating the hash if we replace the heap */
+                * it, or updating the hash if we replace the heap,
+                * also, we cannot maintain persistent hashes */
                HASHdestroy(b);
        }
 
diff --git a/gdk/gdk_hash.h b/gdk/gdk_hash.h
--- a/gdk/gdk_hash.h
+++ b/gdk/gdk_hash.h
@@ -232,12 +232,13 @@ gdk_export BUN HASHlist(Hash *h, BUN i);
  * a pointer to the value to be stored.
  *
  * HASHins receives a BAT* param and is adaptive, killing wrongly
- * configured hash tables.
- * Use HASHins_any or HASHins_<tpe> instead if you know what you're
- * doing or want to keep the hash. */
+ * configured hash tables.  Also, persistent hashes cannot be
+ * maintained, so must be destroyed before this macro is called. */
 #define HASHins(b,i,v)                                                 \
        do {                                                            \
                if ((b)->thash) {                                       \
+                       assert((b)->thash != (Hash *) 1);               \
+                       assert((((size_t *) (b)->thash->heap.base)[0] & (1 << 
24)) == 0); \
                        if (((i) & 1023) == 1023 && HASHgonebad((b), (v))) { \
                                HASHdestroy(b);                         \
                        } else {                                        \
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to