Changeset: c3a7e9f1a1b2 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/c3a7e9f1a1b2 Branch: sqloptimizer Log Message:
Merged with default diffs (truncated from 316 to 300 lines): diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -1805,14 +1805,14 @@ BBPexit(void) * reclaimed as well. */ static inline int -heap_entry(FILE *fp, BAT *b, BUN size) +heap_entry(FILE *fp, BAT *b, BUN size, BATiter *bi) { - size_t free = b->theap->free; + size_t free = bi->hfree; if (size < BUN_NONE) { - if ((b->ttype >= 0 && ATOMstorage(b->ttype) == TYPE_msk)) + if ((bi->type >= 0 && ATOMstorage(bi->type) == TYPE_msk)) free = ((size + 31) / 32) * 4; - else if (b->twidth > 0) - free = size << b->tshift; + else if (bi->width > 0) + free = size << bi->shift; else free = 0; } @@ -1835,8 +1835,8 @@ heap_entry(FILE *fp, BAT *b, BUN size) return fprintf(fp, " %s %d %d %d " BUNFMT " " BUNFMT " " BUNFMT " " BUNFMT " " OIDFMT " %zu %zu %d %" PRIu64" %" PRIu64, - b->ttype >= 0 ? BATatoms[b->ttype].name : ATOMunknown_name(b->ttype), - b->twidth, + bi->type >= 0 ? BATatoms[bi->type].name : ATOMunknown_name(bi->type), + bi->width, b->tvarsized, (unsigned short) b->tsorted | ((unsigned short) b->trevsorted << 7) | @@ -1850,14 +1850,14 @@ heap_entry(FILE *fp, BAT *b, BUN size) b->tnorevsorted >= size ? 0 : b->tnorevsorted, b->tseqbase, free, - b->theap->size, + bi->h->size, 0, - b->tminpos < b->hseqbase + size ? (uint64_t) b->tminpos : (uint64_t) oid_nil, - b->tmaxpos < b->hseqbase + size ? (uint64_t) b->tmaxpos : (uint64_t) oid_nil); + bi->minpos < b->hseqbase + size ? (uint64_t) bi->minpos : (uint64_t) oid_nil, + bi->maxpos < b->hseqbase + size ? (uint64_t) bi->maxpos : (uint64_t) oid_nil); } static inline int -vheap_entry(FILE *fp, Heap *h, BUN size) +vheap_entry(FILE *fp, Heap *h, BUN size, BATiter *bi) { (void) size; if (h == NULL) @@ -1869,18 +1869,18 @@ vheap_entry(FILE *fp, Heap *h, BUN size) if (stat(fname, &stb) == -1) { assert(0); TRC_WARNING(GDK, "file %s not found (expected size %zu)\n", fname, h->free); - } else if ((size_t) stb.st_size < h->free) { + } else if ((size_t) stb.st_size < bi->vhfree) { /* no assert since this can actually happen */ - TRC_WARNING(GDK, "file %s too small (expected %zu, actual %zu)\n", fname, h->free, (size_t) stb.st_size); + TRC_WARNING(GDK, "file %s too small (expected %zu, actual %zu)\n", fname, bi->vhfree, (size_t) stb.st_size); } GDKfree(fname); } } - return fprintf(fp, " %zu %zu %d", h->free, h->size, 0); + return fprintf(fp, " %zu %zu %d", bi->vhfree, h->size, 0); } static gdk_return -new_bbpentry(FILE *fp, bat i, BUN size) +new_bbpentry(FILE *fp, bat i, BUN size, BATiter *bi) { #ifndef NDEBUG assert(i > 0); @@ -1894,11 +1894,11 @@ new_bbpentry(FILE *fp, bat i, BUN size) assert(0 <= BBP_desc(i)->tvheap->farmid && BBP_desc(i)->tvheap->farmid < MAXFARMS); assert(BBPfarms[BBP_desc(i)->tvheap->farmid].roles & (1U << PERSISTENT)); } + assert(size <= BBP_desc(i)->batCount || size == BUN_NONE); #endif - assert(size <= BBP_desc(i)->batCount || size == BUN_NONE); - if (size > BBP_desc(i)->batCount) - size = BBP_desc(i)->batCount; + if (size > bi->count) + size = bi->count; if (fprintf(fp, "%d %u %s %s %d " BUNFMT " " BUNFMT " " OIDFMT, /* BAT info */ (int) i, @@ -1909,8 +1909,8 @@ new_bbpentry(FILE *fp, bat i, BUN size) size, BBP_desc(i)->batCapacity, BBP_desc(i)->hseqbase) < 0 || - heap_entry(fp, BBP_desc(i), size) < 0 || - vheap_entry(fp, BBP_desc(i)->tvheap, size) < 0 || + heap_entry(fp, BBP_desc(i), size, bi) < 0 || + vheap_entry(fp, BBP_desc(i)->tvheap, size, bi) < 0 || (BBP_options(i) && fprintf(fp, " %s", BBP_options(i)) < 0) || fprintf(fp, "\n") < 0) { GDKsyserror("new_bbpentry: Writing BBP.dir entry failed\n"); @@ -2008,7 +2008,7 @@ BBPdir_first(bool subcommit, lng logno, static bat BBPdir_step(bat bid, BUN size, int n, char *buf, size_t bufsize, - FILE **obbpfp, FILE *nbbpf, bool subcommit) + FILE **obbpfp, FILE *nbbpf, bool subcommit, BATiter *bi) { if (n < -1) /* safety catch */ return n; @@ -2138,7 +2138,7 @@ BBPdir_step(bat bid, BUN size, int n, ch } } if (BBP_status(bid) & BBPPERSISTENT) { - if (new_bbpentry(nbbpf, bid, size) != GDK_SUCCEED) + if (new_bbpentry(nbbpf, bid, size, bi) != GDK_SUCCEED) goto bailout; } return n == -1 ? -1 : n == bid ? 0 : n; @@ -3091,13 +3091,13 @@ decref(bat i, bool logical, bool release int BBPunfix(bat i) { - return decref(i, false, false, true, "BBPunfix"); + return decref(i, false, false, true, __func__); } int BBPrelease(bat i) { - return decref(i, true, false, true, "BBPrelease"); + return decref(i, true, false, true, __func__); } /* @@ -3124,15 +3124,15 @@ BBPkeepref(bat i) } assert(BBP_refs(i)); - decref(i, false, false, lock, "BBPkeepref"); + decref(i, false, false, lock, __func__); } } static inline void GDKunshare(bat parent) { - (void) decref(parent, false, true, true, "GDKunshare"); - (void) decref(parent, true, false, true, "GDKunshare"); + (void) decref(parent, false, true, true, __func__); + (void) decref(parent, true, false, true, __func__); } void @@ -3162,7 +3162,7 @@ BBPreclaim(BAT *b) assert(BBP_refs(i) == 1); - return decref(i, false, false, lock, "BBPreclaim") <0; + return decref(i, false, false, lock, __func__) <0; } /* @@ -3404,7 +3404,7 @@ dirty_bat(bat *i, bool subcommit) if (b != NULL) { if ((BBP_status(*i) & BBPNEW) && BATcheckmodes(b, false) != GDK_SUCCEED) /* check mmap modes */ - *i = 0; /* error */ + *i = -*i; /* error */ if ((BBP_status(*i) & BBPPERSISTENT) && (subcommit || BATdirty(b))) return b; /* the bat is loaded, persistent and dirty */ @@ -3904,12 +3904,17 @@ BBPsync(int cnt, bat *restrict subcommit bat i = subcommit ? subcommit[idx] : idx; /* BBP_desc(i) may be NULL */ BUN size = sizes ? sizes[idx] : BUN_NONE; - + BATiter bi; + + /* add a fix so that BBPmanager doesn't interfere */ + BBPfix(i); if (BBP_status(i) & BBPPERSISTENT) { BAT *b = dirty_bat(&i, subcommit != NULL); if (i <= 0) { + decref(-i, false, false, locked_by == 0 || locked_by != MT_getpid(), __func__); break; } + bi = bat_iterator(BBP_desc(i)); if (b) { /* wait for BBPSAVING so that we * can set it, wait for @@ -3927,20 +3932,24 @@ BBPsync(int cnt, bat *restrict subcommit BBP_status_on(i, BBPSAVING); if (lock) MT_lock_unset(&GDKswapLock(i)); - BATiter bi = bat_iterator(b); assert(size <= bi.count || size == BUN_NONE); if (size > bi.count) size = bi.count; MT_rwlock_rdlock(&b->thashlock); ret = BATsave_locked(b, &bi, size); MT_rwlock_rdunlock(&b->thashlock); - bat_iterator_end(&bi); BBP_status_off(i, BBPSAVING); } + } else { + bi = bat_iterator(NULL); } if (ret == GDK_SUCCEED) { - n = BBPdir_step(i, size, n, buf, sizeof(buf), &obbpf, nbbpf, subcommit != NULL); + n = BBPdir_step(i, size, n, buf, sizeof(buf), &obbpf, nbbpf, subcommit != NULL, &bi); } + bat_iterator_end(&bi); + /* can't use BBPunfix because of the "lock" + * argument: locked_by may be set here */ + decref(i, false, false, locked_by == 0 || locked_by != MT_getpid(), __func__); if (n == -2) break; /* we once again have a saved heap */ diff --git a/monetdb5/modules/atoms/url.c b/monetdb5/modules/atoms/url.c --- a/monetdb5/modules/atoms/url.c +++ b/monetdb5/modules/atoms/url.c @@ -835,7 +835,7 @@ extractURLHost(str *retval, str *url, bi if ((s = skip_scheme(*url)) != NULL && (s = skip_authority(s, NULL, NULL, &h, &p)) != NULL && h != NULL) - { + { ssize_t l; const char *pos = s; const char *domain = NULL; @@ -852,33 +852,24 @@ extractURLHost(str *retval, str *url, bi } else { l = s - h; } + if (*no_www && !strncmp(h, "www.", 4)) { + h +=4; + l -=4; + } if (domain && l > 3) { - if ((*retval = GDKmalloc(l + 1)) != NULL) { - if (*no_www && strlen(h) > 4 && !strncmp(h, "www.", 4)) { - strcpy_len(*retval, (h + 4), l + 1); - } else { - strcpy_len(*retval, h, l + 1); - } - // clean up if not valid UTF-8 - if (!checkUTF8(*retval)) { - // printf("%s\n", h); - GDKfree(*retval); - *retval = GDKstrdup(str_nil); - } - } else { - throw(MAL, "url.getURLHost", SQLSTATE(HY013) MAL_MALLOC_FAIL); - } + if ((*retval = GDKmalloc(l + 1)) != NULL) + strcpy_len(*retval, h, l + 1); } else { - // printf("%s\n", h); *retval = GDKstrdup(str_nil); } - } else { *retval = GDKstrdup(str_nil); } } else { *retval = GDKstrdup(str_nil); } + if (!*retval) + throw(MAL, "url.getURLHost", SQLSTATE(HY013) MAL_MALLOC_FAIL); return MAL_SUCCEED; } @@ -899,8 +890,7 @@ BATextractURLHost(bat *res, const bat *b const char *s; const char *host = NULL; const char *port = NULL; - BAT *bn = NULL; - BAT *b = BATdescriptor(*bid); + BAT *bn = NULL, *b = NULL; BUN p, q; size_t buflen = INITIAL_STR_BUFFER_LENGTH; str buf = GDKmalloc(buflen); @@ -910,16 +900,19 @@ BATextractURLHost(bat *res, const bat *b if (buf == NULL) throw(MAL, "baturl.extractURLHost", SQLSTATE(HY013) MAL_MALLOC_FAIL); - if (b == NULL) + if (!(b = BATdescriptor(*bid))) { + GDKfree(buf); throw(MAL, "baturl.extractURLHost", SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); + } if ((bn = COLnew(b->hseqbase, TYPE_str, BATcount(b), TRANSIENT)) == NULL) { + GDKfree(buf); + BBPunfix(b->batCacheid); throw(MAL, "baturl.extractURLHost", SQLSTATE(HY013) MAL_MALLOC_FAIL); - BBPunfix(b->batCacheid); } _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org