Changeset: b617946b4079 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b617946b4079 Modified Files: gdk/ChangeLog gdk/gdk_bbp.c gdk/gdk_logger.c gdk/gdk_logger.h Branch: default Log Message:
Cleanup: removed conversion of 32 to 64 bit OIDs. diffs (truncated from 589 to 300 lines): diff --git a/gdk/ChangeLog b/gdk/ChangeLog --- a/gdk/ChangeLog +++ b/gdk/ChangeLog @@ -1,6 +1,10 @@ # ChangeLog file for MonetDB # This file is updated with Maddlog +* Fri Dec 16 2016 Sjoerd Mullender <sjo...@acm.org> +- Removed automatic conversion of 32-bit OIDs to 64 bits on 64-bit + architectures. + * Tue Dec 13 2016 Sjoerd Mullender <sjo...@acm.org> - Removed functions OIDbase() and OIDnew(). - Removed talign field from BAT descriptor. diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -408,244 +408,6 @@ static gdk_return BBPrecover(int farmid) static gdk_return BBPrecover_subdir(void); static int BBPdiskscan(const char *); -#if SIZEOF_SIZE_T == 8 && SIZEOF_OID == 8 -/* Convert 32-bit OIDs to 64 bits. - * This function must be called at the end of BBPinit(), just before - * "normal processing" starts. All errors that happen during the - * conversion are fatal. This function is "safe" in the sense that - * when it is interrupted, recovery will just start over. No - * permanent changes are made to the database until all string heaps - * have been converted, and then the changes are made atomically. - * - * In addition to doing the conversion to all BATs with OID or STR - * columns (the latter since the format of the string heap is - * different for 64/32 and 64/64 configurations), we also look out for - * the *_catalog BATs that are used by gdk_logger. If we encounter - * such a BAT, we create a file based on the name of that BAT - * (i.e. using the first part of the name) to inform the logger that - * it too needs to convert 32 bit OIDs to 64 bits. If the process - * here gets interrupted, the logger is never called, and if we get - * then restarted, we just create the file again, so this process is - * safe. */ - -static void -fixoidheapcolumn(BAT *b, const char *srcdir, const char *nme, - const char *filename, const char *headtail, - const char *htheap) -{ - bat bid = b->batCacheid; - Heap h1, h2; - int *old; - oid *new; - BUN i; - char *s; - unsigned short w; - const char *bnme; - int tt; - - if ((bnme = strrchr(nme, DIR_SEP)) != NULL) - bnme++; - else - bnme = nme; - - if (GDKmove(b->theap.farmid, srcdir, bnme, headtail, BAKDIR, bnme, headtail) != GDK_SUCCEED) - GDKfatal("fixoidheap: cannot make backup of %s.%s\n", nme, headtail); - - if ((tt = b->ttype) < 0) { - const char *anme; - - /* as yet unknown tail column type */ - anme = ATOMunknown_name(tt); - if (strcmp(anme, "url") == 0) - b->ttype = TYPE_str; - else if (strcmp(anme, "sqlblob") == 0 || - strcmp(anme, "wkb") == 0) - b->ttype = TYPE_int; - else - GDKfatal("fixoidheap: unrecognized column " - "type %s for BAT %d\n", anme, bid); - } - - if (b->ttype == TYPE_str) { - if (GDKmove(b->tvheap->farmid, srcdir, bnme, htheap, BAKDIR, bnme, htheap) != GDK_SUCCEED) - GDKfatal("fixoidheap: cannot make backup of %s.%s\n", nme, htheap); - - h1 = b->theap; - h1.filename = NULL; - h1.base = NULL; - h1.dirty = 0; - h2 = *b->tvheap; - h2.filename = NULL; - h2.base = NULL; - h2.dirty = 0; - - /* load old string heap */ - if (HEAPload(&h1, filename, headtail, 0) != GDK_SUCCEED) - GDKfatal("fixoidheap: loading old %s heap " - "for BAT %d failed\n", headtail, bid); - if (HEAPload(&h2, filename, htheap, 0) != GDK_SUCCEED) - GDKfatal("fixoidheap: loading old string heap " - "for BAT %d failed\n", bid); - - /* create new string heap */ - b->theap.filename = GDKfilepath(NOFARM, NULL, nme, headtail); - if (b->theap.filename == NULL) - GDKfatal("fixoidheap: GDKmalloc failed\n"); - w = b->twidth; /* remember old width */ - b->twidth = 1; - b->tshift = 0; - if (HEAPalloc(&b->theap, b->batCapacity, SIZEOF_OID) != GDK_SUCCEED) - GDKfatal("fixoidheap: allocating new %s heap " - "for BAT %d failed\n", headtail, bid); - - b->theap.dirty = TRUE; - b->tvheap->filename = GDKfilepath(NOFARM, NULL, nme, htheap); - if (b->tvheap->filename == NULL) - GDKfatal("fixoidheap: GDKmalloc failed\n"); - if (ATOMheap(TYPE_str, b->tvheap, b->batCapacity) != GDK_SUCCEED) - GDKfatal("fixoidheap: initializing new string " - "heap for BAT %d failed\n", bid); - b->tvheap->parentid = bid; - - /* do the conversion */ - b->theap.dirty = TRUE; - b->tvheap->dirty = TRUE; - for (i = 0; i < b->batCount; i++) { - /* s = h2.base + VarHeapVal(h1.base, i, w); */ - switch (w) { - case 1: - s = h2.base + (((var_t) ((unsigned char *) h1.base)[i] + ((GDK_STRHASHTABLE * sizeof(unsigned short)) >> 3)) << 3); - break; - case 2: - s = h2.base + (((var_t) ((unsigned short *) h1.base)[i] + ((GDK_STRHASHTABLE * sizeof(unsigned short)) >> 3)) << 3); - break; - case 4: - s = h2.base + ((var_t) ((unsigned int *) h1.base)[i] << 3); - break; - default: - assert(0); - /* cannot happen, but compiler doesn't know */ - s = NULL; - } - b->theap.free += b->twidth; - Tputvalue(b, Tloc(b, i), s, 0); - } - HEAPfree(&h1, 0); - HEAPfree(&h2, 0); - HEAPsave(b->tvheap, nme, htheap); - HEAPfree(b->tvheap, 0); - } else { - assert(b->ttype == TYPE_oid || - (b->ttype != TYPE_void && b->tvarsized)); - h1 = b->theap; - h1.filename = NULL; - h1.base = NULL; - h1.dirty = 0; - h1.parentid = 0; - - /* load old heap */ - if (HEAPload(&h1, filename, headtail, 0) != GDK_SUCCEED) - GDKfatal("fixoidheap: loading old %s heap " - "for BAT %d failed\n", headtail, bid); - - /* create new heap */ - b->theap.filename = GDKfilepath(NOFARM, NULL, nme, headtail); - if (b->theap.filename == NULL) - GDKfatal("fixoidheap: GDKmalloc failed\n"); - b->twidth = SIZEOF_OID; - b->tshift = 3; - assert(b->twidth == (1 << b->tshift)); - if (HEAPalloc(&b->theap, b->batCapacity, SIZEOF_OID) != GDK_SUCCEED) - GDKfatal("fixoidheap: allocating new %s heap " - "for BAT %d failed\n", headtail, bid); - - b->theap.dirty = TRUE; - old = (int *) h1.base; - new = (oid *) b->theap.base; - if (b->tvarsized) - for (i = 0; i < b->batCount; i++) - new[i] = (oid) old[i] << 3; - else - for (i = 0; i < b->batCount; i++) - new[i] = old[i] == int_nil ? oid_nil : (oid) old[i]; - b->theap.free = h1.free << 1; - HEAPfree(&h1, 0); - } - HEAPsave(&b->theap, nme, headtail); - HEAPfree(&b->theap, 0); - - if (tt < 0) - b->ttype = tt; - - return; - - bunins_failed: - GDKfatal("fixoidheap: memory allocation failed\n"); -} - -static void -fixoidheap(void) -{ - bat bid; - BAT *b; - const char *nme, *bnme; - char *srcdir; - long_str filename; - size_t len; - FILE *fp; - - fprintf(stderr, - "# upgrading database from 32 bit OIDs to 64 bit OIDs\n"); - fflush(stderr); - - for (bid = 1; bid < (bat) ATOMIC_GET(BBPsize, BBPsizeLock); bid++) { - if ((b = BBP_desc(bid)) == NULL) - continue; /* not a valid BAT */ - if (BBP_logical(bid) && - (len = strlen(BBP_logical(bid))) > 8 && - strcmp(BBP_logical(bid) + len - 8, "_catalog") == 0) { - /* this is one of the files used by the - * logger. We need to communicate to the - * logger that it also needs to do a - * conversion. That is done by creating a - * file here based on the name of this BAT. */ - snprintf(filename, sizeof(filename), - "%.*s_32-64-convert", - (int) (len - 8), BBP_logical(bid)); - fp = fopen(filename, "w"); - if (fp == NULL) - GDKfatal("fixoidheap: cannot create file %s\n", - filename); - fclose(fp); - } - - /* OID and (non-void) varsized columns have to be rewritten */ - if (b->ttype != TYPE_oid && - (b->ttype == TYPE_void || !b->tvarsized)) - continue; /* nothing to do for this BAT */ - - nme = BBP_physical(bid); - if ((bnme = strrchr(nme, DIR_SEP)) == NULL) - bnme = nme; - else - bnme++; - sprintf(filename, "BACKUP%c%s", DIR_SEP, bnme); - srcdir = GDKfilepath(b->theap.farmid, BATDIR, nme, NULL); - *strrchr(srcdir, DIR_SEP) = 0; - if (b->ttype == TYPE_oid || - (b->tvarsized && b->ttype != TYPE_void)) { - assert(b->ttype != TYPE_oid || b->twidth == 4); - fixoidheapcolumn(b, srcdir, nme, filename, "tail", "theap"); - } - GDKfree(srcdir); - } - - /* make permanent */ - if (TMcommit() != GDK_SUCCEED) - GDKfatal("fixoidheap: commit failed\n"); -} -#endif - #ifdef GDKLIBRARY_SORTEDPOS static void fixsorted(void) @@ -909,7 +671,7 @@ headheapinit(oid *hseq, const char *buf, } static int -heapinit(BAT *b, const char *buf, int *hashash, const char *HT, int oidsize, int bbpversion, bat bid) +heapinit(BAT *b, const char *buf, int *hashash, const char *HT, int bbpversion, bat bid) { int t; char type[11]; @@ -927,7 +689,6 @@ heapinit(BAT *b, const char *buf, int *h unsigned short storage; int n; - (void) oidsize; /* only used when SIZEOF_OID==8 */ (void) bbpversion; /* could be used to implement compatibility */ norevsorted = 0; /* default for first case */ @@ -973,11 +734,7 @@ heapinit(BAT *b, const char *buf, int *h && width != 8 #endif ) : - ATOMsize(t) != width -#if SIZEOF_SIZE_T == 8 && SIZEOF_OID == 8 - && (t != TYPE_oid || oidsize == 0 || width != oidsize) -#endif - ) + ATOMsize(t) != width) GDKfatal("BBPinit: inconsistent entry in BBP.dir: %s.size mismatch for BAT %d\n", HT, (int) bid); b->ttype = t; b->twidth = width; @@ -1043,7 +800,7 @@ vheapinit(BAT *b, const char *buf, int h } static void -BBPreadEntries(FILE *fp, int oidsize, int bbpversion) +BBPreadEntries(FILE *fp, int bbpversion) { bat bid = 0; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list