Changeset: 4a2b07996ead for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4a2b07996ead
Modified Files:
        gdk/gdk.h
        gdk/gdk_bbp.c
        sql/backends/monet5/sql_upgrades.c
        sql/storage/bat/bat_logger.c
Branch: Apr2019
Log Message:

Removed old (pre-Jul2017) upgrade code.


diffs (truncated from 950 to 300 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -767,9 +767,6 @@ typedef struct {
 /* assert that atom width is power of 2, i.e., width == 1<<shift */
 #define assert_shift_width(shift,width) assert(((shift) == 0 && (width) == 0) 
|| ((unsigned)1<<(shift)) == (unsigned)(width))
 
-#define GDKLIBRARY_HEADED      061033U /* head properties are stored */
-#define GDKLIBRARY_NOKEY       061034U /* nokey values can't be trusted */
-#define GDKLIBRARY_BADEMPTY    061035U /* possibility of duplicate empty str */
 #define GDKLIBRARY_TALIGN      061036U /* talign field in BBP.dir */
 #define GDKLIBRARY_NIL_NAN     061037U /* flt/dbl NIL not represented by NaN */
 #define GDKLIBRARY             061040U
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -394,285 +394,6 @@ static gdk_return BBPrecover(int farmid)
 static gdk_return BBPrecover_subdir(void);
 static bool BBPdiskscan(const char *, size_t);
 
-#ifdef GDKLIBRARY_BADEMPTY
-/* There was a bug (fixed in changeset 1f5498568a24) which could
- * result in empty strings not being double-eliminated.  This code
- * fixes the affected bats.
- * Note that we only fix BATs whose string heap is still fully double
- * eliminated. */
-static inline bool
-offsearch(const int *restrict offsets, int noffsets, int val)
-{
-       /* binary search on offsets for val, return whether present */
-       int lo = 0, hi = noffsets - 1, mid;
-
-       while (hi > lo) {
-               mid = (lo + hi) / 2;
-               if (offsets[mid] == val)
-                       return 1;
-               if (offsets[mid] < val)
-                       lo = mid + 1;
-               else
-                       hi = mid - 1;
-       }
-       return offsets[lo] == val;
-}
-
-static void
-fixstroffheap(BAT *b, int *restrict offsets)
-{
-       long_str filename;
-       Heap h1;                /* old offset heap */
-       Heap h2;                /* new string heap */
-       Heap h3;                /* new offset heap */
-       Heap *h;                /* string heap */
-       int noffsets = 0;
-       const size_t extralen = b->tvheap->hashash ? EXTRALEN : 0;
-       size_t pos;
-       var_t emptyoff = 0;
-       const char *nme, *bnme;
-       char *srcdir;
-       BUN i;
-       int width;
-       bool nofix = true;
-
-       assert(GDK_ELIMDOUBLES(b->tvheap));
-
-       nme = BBP_physical(b->batCacheid);
-       srcdir = GDKfilepath(NOFARM, BATDIR, nme, NULL);
-       if (srcdir == NULL)
-               GDKfatal("fixstroffheap: GDKmalloc failed\n");
-       *strrchr(srcdir, DIR_SEP) = 0;
-
-       /* load string heap */
-       if (HEAPload(b->tvheap, nme, "theap", false) != GDK_SUCCEED)
-               GDKfatal("fixstroffheap: loading string (theap) heap "
-                        "for BAT %d failed\n", b->batCacheid);
-       h = b->tvheap;          /* abbreviation */
-       /* collect valid offsets */
-       pos = GDK_STRHASHSIZE;
-       while (pos < h->free) {
-               const char *s;
-               size_t pad;
-
-               pad = GDK_VARALIGN - (pos & (GDK_VARALIGN - 1));
-               if (pad < sizeof(stridx_t))
-                       pad += GDK_VARALIGN;
-               pos += pad + extralen;
-               s = h->base + pos;
-               if (*s == '\0')
-                       emptyoff = (var_t) pos;
-               offsets[noffsets++] = (int) pos; /* < 65536, i.e. fits */
-               pos += GDK_STRLEN(s);
-       }
-       HEAPfree(b->tvheap, false);
-
-       if ((bnme = strrchr(nme, DIR_SEP)) != NULL)
-               bnme++;
-       else
-               bnme = nme;
-       sprintf(filename, "BACKUP%c%s", DIR_SEP, bnme);
-
-       width = b->twidth;
-       h2.dirty = false;
-       if (emptyoff == 0) {
-               /* no legitimate empty string in the string heap; we
-                * now make a backup of the old string heap and create
-                * a new one to which we add an empty string */
-               h2 = *b->tvheap;
-               if (GDKmove(h2.farmid, srcdir, bnme, "theap", BAKDIR, bnme, 
"theap") != GDK_SUCCEED)
-                       GDKfatal("fixstroffheap: cannot make backup of 
%s.theap\n", nme);
-               stpconcat(h2.filename, nme, ".theap", NULL);
-               h2.base = NULL;
-               if (HEAPalloc(&h2, h2.size, 1) != GDK_SUCCEED)
-                       GDKfatal("fixstroffheap: allocating new string heap "
-                                "for BAT %d failed\n", b->batCacheid);
-               h2.cleanhash = b->tvheap->cleanhash;
-               h2.hashash = b->tvheap->hashash;
-               h2.free = b->tvheap->free;
-               /* load old offset heap and copy contents to new heap */
-               h1 = *b->tvheap;
-               stpconcat(h1.filename, filename, ".theap", NULL);
-               h1.base = NULL;
-               h1.dirty = false;
-               if (HEAPload(&h1, filename, "theap", false) != GDK_SUCCEED)
-                       GDKfatal("fixstroffheap: loading old tail heap "
-                                "for BAT %d failed\n", b->batCacheid);
-               memcpy(h2.base, h1.base, h2.free);
-               HEAPfree(&h1, false);
-               h2.dirty = true;
-               if ((*BATatoms[TYPE_str].atomPut)(&h2, &emptyoff, "") == 0)
-                       GDKfatal("fixstroffheap: cannot insert empty string "
-                                "in BAT %d failed\n", b->batCacheid);
-               /* if the offset of the new empty string doesn't fit
-                * in the offset heap (too many bits for the current
-                * width), we will also make the new offset heap
-                * wider */
-               if ((width <= 2 ? emptyoff - GDK_VAROFFSET : emptyoff) >= 
(var_t) (1 << (width * 8))) {
-                       width <<= 1;
-                       assert((width <= 2 ? emptyoff - GDK_VAROFFSET : 
emptyoff) < (var_t) (1 << (width * 8)));
-               }
-       }
-
-       /* make backup of offset heap */
-       if (GDKmove(b->theap.farmid, srcdir, bnme, "tail", BAKDIR, bnme, 
"tail") != GDK_SUCCEED)
-               GDKfatal("fixstroffheap: cannot make backup of %s.tail\n", nme);
-       /* load old offset heap */
-       h1 = b->theap;
-       stpconcat(h1.filename, filename, ".tail", NULL);
-       h1.base = NULL;
-       h1.dirty = false;
-       if (HEAPload(&h1, filename, "tail", false) != GDK_SUCCEED)
-               GDKfatal("fixstroffheap: loading old tail heap "
-                        "for BAT %d failed\n", b->batCacheid);
-
-       /* create new offset heap */
-       h3 = b->theap;
-       stpconcat(h3.filename, nme, ".tail", NULL);
-       if (HEAPalloc(&h3, b->batCapacity, width) != GDK_SUCCEED)
-               GDKfatal("fixstroffheap: allocating new tail heap "
-                        "for BAT %d failed\n", b->batCacheid);
-       h3.dirty = true;
-       h3.free = h1.free;
-
-       switch (b->twidth) {
-       case 1:
-               for (i = 0; i < b->batCount; i++) {
-                       pos = (var_t) ((unsigned char *) h1.base)[i] + 
GDK_VAROFFSET;
-                       if (!offsearch(offsets, noffsets, (int) pos)) {
-                               pos = emptyoff;
-                               nofix = false;
-                       }
-                       if (width == 1)
-                               ((unsigned char *) h3.base)[i] = (unsigned 
char) (pos - GDK_VAROFFSET);
-                       else
-                               ((unsigned short *) h3.base)[i] = (unsigned 
short) (pos - GDK_VAROFFSET);
-               }
-               break;
-       case 2:
-               for (i = 0; i < b->batCount; i++) {
-                       pos = (var_t) ((unsigned short *) h1.base)[i] + 
GDK_VAROFFSET;
-                       if (!offsearch(offsets, noffsets, (int) pos)) {
-                               pos = emptyoff;
-                               nofix = false;
-                       }
-                       if (width == 2)
-                               ((unsigned short *) h3.base)[i] = (unsigned 
short) (pos - GDK_VAROFFSET);
-                       else
-                               ((unsigned int *) h3.base)[i] = (unsigned int) 
(pos - GDK_VAROFFSET);
-               }
-               break;
-       case 4:
-               for (i = 0; i < b->batCount; i++) {
-                       pos = (var_t) ((unsigned int *) h1.base)[i];
-                       if (!offsearch(offsets, noffsets, (int) pos)) {
-                               pos = emptyoff;
-                               nofix = false;
-                       }
-                       ((unsigned int *) h3.base)[i] = (unsigned int) pos;
-               }
-               break;
-#if SIZEOF_VAR_T == 8
-       case 8:
-               for (i = 0; i < b->batCount; i++) {
-                       pos = (var_t) ((ulng *) h1.base)[i];
-                       if (!offsearch(offsets, noffsets, (int) pos)) {
-                               pos = emptyoff;
-                               nofix = false;
-                       }
-                       ((ulng *) h3.base)[i] = (ulng) pos;
-               }
-               break;
-#endif
-       default:
-               /* cannot happen */
-               assert(0);
-       }
-
-       /* cleanup */
-       HEAPfree(&h1, false);
-       if (nofix) {
-               /* didn't fix anything, move backups back */
-               if (h2.dirty) {
-                       HEAPfree(&h2, true);
-                       if (GDKmove(b->tvheap->farmid, BAKDIR, bnme, "theap", 
srcdir, bnme, "theap") != GDK_SUCCEED)
-                               GDKfatal("fixstroffheap: cannot restore backup 
of %s.theap\n", nme);
-               }
-               HEAPfree(&h3, true);
-               if (GDKmove(b->theap.farmid, BAKDIR, bnme, "tail", srcdir, 
bnme, "tail") != GDK_SUCCEED)
-                       GDKfatal("fixstroffheap: cannot restore backup of 
%s.tail\n", nme);
-       } else {
-               /* offset heap was fixed */
-               b->twidth = width;
-               b->batDirtydesc = true;
-               if (h2.dirty) {
-                       /* in addition, we added an empty string to
-                        * the string heap */
-                       if (HEAPsave(&h2, nme, "theap") != GDK_SUCCEED)
-                               GDKfatal("fixstroffheap: saving heap failed\n");
-                       HEAPfree(&h2, false);
-                       *b->tvheap = h2;
-               }
-               if (HEAPsave(&h3, nme, "tail") != GDK_SUCCEED)
-                       GDKfatal("fixstroffheap: saving heap failed\n");
-               HEAPfree(&h3, false);
-               b->theap = h3;
-       }
-       GDKfree(srcdir);
-}
-
-static void
-fixstrbats(void)
-{
-       bat bid;
-       BAT *b;
-       int *offsets;
-       int tt;
-
-       fprintf(stderr,
-               "# fixing string offset heaps\n");
-       fflush(stderr);
-
-       /* The minimum size a string occupies in the double-eliminated
-        * part of a string heap is SIZEOF_VAR_T (due to padding to
-        * multiples of this value) plus the size of the chain pointer
-        * (another var_t), and if hashes are stored, plus the size of
-        * a hash value (yet another var_t).  In total, 2 or 3 var_t
-        * sizes.  The hash table itself is 1024 times the size of a
-        * var_t.  So on 32 bit architectures, 8000 is plenty, and on
-        * 64 bit architectures, 4000 is plenty.  But we need less if
-        * the heap is not fully occupied.  This results in the
-        * following calculation. */
-       offsets = GDKmalloc((GDK_ELIMLIMIT / (2 * SIZEOF_VAR_T)) * sizeof(int));
-       if (offsets == NULL)
-               GDKfatal("fixstroffheap: cannot allocate memory\n");
-
-       for (bid = 1; bid < (bat) ATOMIC_GET(BBPsize, BBPsizeLock); bid++) {
-               if ((b = BBP_desc(bid)) == NULL || b->batCount == 0)
-                       continue;       /* not a valid BAT, or an empty one */
-               if ((tt = b->ttype) < 0) {
-                       const char *anme;
-
-                       /* as yet unknown tail column type */
-                       anme = ATOMunknown_name(tt);
-                       /* known string types */
-                       if (strcmp(anme, "url") == 0 ||
-                           strcmp(anme, "json") == 0 ||
-                           strcmp(anme, "xml") == 0 ||
-                           strcmp(anme, "identifier") == 0)
-                               tt = TYPE_str;
-               }
-
-               if (tt != TYPE_str || !GDK_ELIMDOUBLES(b->tvheap))
-                       continue;       /* nothing to do for this BAT */
-
-               fixstroffheap(b, offsets);
-       }
-
-       GDKfree(offsets);
-}
-#endif
-
 #ifdef GDKLIBRARY_NIL_NAN
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to