Changeset: 491d370cd536 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=491d370cd536 Modified Files: gdk/ChangeLog gdk/gdk.h gdk/gdk_bat.c gdk/gdk_batop.c gdk/gdk_group.c geom/monetdb5/geom.c geom/monetdb5/geomBulk.c monetdb5/modules/kernel/bat5.c monetdb5/modules/mal/manifold.c monetdb5/modules/mal/mat.c monetdb5/modules/mal/tablet.c sql/backends/monet5/generator/generator.c sql/backends/monet5/sql.c sql/backends/monet5/vaults/shp/shp.c Branch: default Log Message:
Removed BATderiveProps. diffs (truncated from 560 to 300 lines): diff --git a/gdk/ChangeLog b/gdk/ChangeLog --- a/gdk/ChangeLog +++ b/gdk/ChangeLog @@ -2,7 +2,8 @@ # This file is updated with Maddlog * Wed Jul 6 2016 Sjoerd Mullender <[email protected]> -- Removed BATderiveTailProps. Use BATderiveProps instead. +- Removed BATderiveTailProps and BATderiveProps. Just set the properties + you know about, or use BATsettrivprop. * Fri Jul 1 2016 Sjoerd Mullender <[email protected]> - Removed the macro BUNfirst. It can be replaced by 0. diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -2686,7 +2686,6 @@ gdk_export void BATundo(BAT *b); gdk_export int ALIGNsynced(BAT *b1, BAT *b2); gdk_export void BATassertProps(BAT *b); -gdk_export void BATderiveProps(BAT *b, int expensive); #define BATPROPS_QUICK 0 /* only derive easy (non-resource consuming) properties */ #define BATPROPS_ALL 1 /* derive all possible properties; no matter what cost (key=hash) */ diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -2167,224 +2167,3 @@ BATassertProps(BAT *b) assert(!b->tnil || seennil); } } - -/* derive properties that can be derived with a simple scan: sorted, - * revsorted, dense; if expensive is set, we also check the key - * property - * note that we don't check nil/nonil: we usually know pretty quickly - * that a column is not sorted, but we usually need a full scan for - * nonil. - */ -void -BATderiveProps(BAT *b, int expensive) -{ - BATiter bi = bat_iterator(b); - BUN p, q; - int (*cmpf)(const void *, const void *); - int cmp; - const void *prev = NULL, *valp, *nilp; - int sorted, revsorted, key, dense; - const char *nme = NULL; - char *ext = NULL; - size_t nmelen; - Heap *hp = NULL; - Hash *hs = NULL; - BUN hb, prb; - oid sqbs = oid_nil; - - if (b == NULL) { - assert(0); - return; - } - assert((b->tkey & BOUND2BTRUE) == 0); - BATsettrivprop(b); - cmpf = ATOMcompare(b->ttype); - nilp = ATOMnilptr(b->ttype); - b->batDirtydesc = 1; /* we will be changing things */ - if (b->ttype == TYPE_void || b->batCount <= 1) { - /* BATsettrivprop has already taken care of all - * properties except for (no)nil if count == 1 */ - if (b->batCount == 1) { - valp = BUNtail(bi, 0); - if (cmpf(valp, nilp) == 0) { - b->tnil = 1; - b->tnonil = 0; - } else { - b->tnil = 0; - b->tnonil = 1; - } - } - return; - } - /* tentatively set until proven otherwise */ - key = 1; - sorted = revsorted = (ATOMlinear(b->ttype) != 0); - dense = (b->ttype == TYPE_oid); - /* if no* props already set correctly, we can maybe speed - * things up, if not set correctly, reset them now and set - * them later */ - if (!b->tkey && - b->tnokey[0] < b->batCount && - b->tnokey[1] < b->batCount && - b->tnokey[0] != b->tnokey[1] && - cmpf(BUNtail(bi, b->tnokey[0]), - BUNtail(bi, b->tnokey[1])) == 0) { - /* we found proof that the column doesn't deserve the - * key property, no need to check the hard way */ - expensive = 0; - key = 0; - } else { - b->tnokey[0] = 0; - b->tnokey[1] = 0; - } - if (!b->tsorted && - b->tnosorted > 0 && - b->tnosorted < b->batCount && - cmpf(BUNtail(bi, b->tnosorted - 1), - BUNtail(bi, b->tnosorted)) > 0) { - sorted = 0; - dense = 0; - } else { - b->tnosorted = 0; - } - if (!b->trevsorted && - b->tnorevsorted > 0 && - b->tnorevsorted < b->batCount && - cmpf(BUNtail(bi, b->tnorevsorted - 1), - BUNtail(bi, b->tnorevsorted)) < 0) { - revsorted = 0; - } else { - b->tnorevsorted = 0; - } - if (dense && - !b->tdense && - b->tnodense < b->batCount && - (b->tnodense == 0 ? - * (oid *) BUNtail(bi, b->tnodense) == oid_nil : - * (oid *) BUNtail(bi, b->tnodense - 1) + 1 != * (oid *) BUNtail(bi, b->tnodense))) { - dense = 0; - } else { - b->tnodense = 0; - } - if (expensive) { - BUN mask; - - nme = BBP_physical(b->batCacheid); - nmelen = strlen(nme); - if (ATOMsize(b->ttype) == 1) - mask = 1 << 8; - else if (ATOMsize(b->ttype) == 2) - mask = 1 << 16; - else - mask = HASHmask(b->batCount); - if ((hp = GDKzalloc(sizeof(Heap))) == NULL || - (hp->filename = GDKmalloc(nmelen + 30)) == NULL || - (hp->farmid = BBPselectfarm(TRANSIENT, b->ttype, hashheap)) < 0 || - snprintf(hp->filename, nmelen + 30, - "%s.hash" SZFMT, nme, MT_getpid()) < 0 || - (ext = GDKstrdup(hp->filename + nmelen + 1)) == NULL || - (hs = HASHnew(hp, b->ttype, BUNlast(b), mask, BUN_NONE)) == NULL) { - if (hp) { - if (hp->filename) - GDKfree(hp->filename); - GDKfree(hp); - } - if (ext) - GDKfree(ext); - hp = NULL; - ext = NULL; - fprintf(stderr, - "#BATderiveProps: cannot allocate " - "hash table: not doing full check\n"); - } - } - for (q = BUNlast(b), p = 0; - p < q && (sorted || revsorted || (key && hs)); - p++) { - valp = BUNtail(bi, p); - if (prev) { - cmp = cmpf(prev, valp); - if (cmp < 0) { - revsorted = 0; - if (b->tnorevsorted == 0) - b->tnorevsorted = p; - if (dense && - * (oid *) prev + 1 != * (oid *) valp) { - dense = 0; - if (b->tnodense == 0) - b->tnodense = p; - } - } else { - if (cmp > 0) { - sorted = 0; - if (b->tnosorted == 0) - b->tnosorted = p; - } else { - key = 0; - if (b->tnokey[0] == 0 && - b->tnokey[1] == 0) { - b->tnokey[0] = p - 1; - b->tnokey[1] = p; - } - } - if (dense) { - dense = 0; - if (b->tnodense == 0) - b->tnodense = p; - } - } - } else if (dense && (sqbs = * (oid *) valp) == oid_nil) { - dense = 0; - b->tnodense = p; - } - prev = valp; - if (key && hs) { - prb = HASHprobe(hs, valp); - for (hb = HASHget(hs,prb); - hb != HASHnil(hs); - hb = HASHgetlink(hs,hb)) { - if (cmpf(valp, BUNtail(bi, hb)) == 0) { - key = 0; - b->tnokey[0] = hb; - b->tnokey[1] = p; - break; - } - } - HASHputlink(hs,p, HASHget(hs,prb)); - HASHput(hs,prb,p); - } - } - if (hs) { - HEAPfree(hp, 1); - GDKfree(hp); - GDKfree(hs); - GDKfree(ext); - } - b->tsorted = sorted; - b->trevsorted = revsorted; - b->tdense = dense; - if (dense) - b->tseqbase = sqbs; - if (hs) { - b->tkey = key; - } else { - /* we can only say something about keyness if the - * column is sorted */ - b->tkey = key & (sorted | revsorted); - } - if (sorted || revsorted) { - /* if sorted, we only need to check the extremes to - * know whether there are any nils */ - if (cmpf(BUNtail(bi, 0), nilp) != 0 && - cmpf(BUNtail(bi, BUNlast(b) - 1), nilp) != 0) { - b->tnonil = 1; - b->tnil = 0; - } else { - b->tnonil = 0; - b->tnil = 1; - } - } -#ifndef NDEBUG - BATassertProps(b); -#endif -} diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -790,7 +790,10 @@ BATslice(BAT *b, BUN l, BUN h) } /* Return whether the BAT is ordered or not. If we don't know, invest -* in a scan and record the results in the bat descriptor. */ + * in a scan and record the results in the bat descriptor. If during + * the scan we happen to find evidence that the BAT is not reverse + * sorted, we record the location. + */ int BATordered(BAT *b) { @@ -817,6 +820,11 @@ BATordered(BAT *b) b->tnosorted = p; ALGODEBUG fprintf(stderr, "#BATordered: fixed nosorted(" BUNFMT ") for %s#" BUNFMT " (" LLFMT " usec)\n", p, BATgetId(b), BATcount(b), GDKusec() - t0); goto doreturn; + } else if (!b->trevsorted && + b->tnorevsorted == 0 && + iptr[p - 1] < iptr[p]) { + b->tnorevsorted = p; + ALGODEBUG fprintf(stderr, "#BATordered: fixed norevsorted(" BUNFMT ") for %s#" BUNFMT "\n", p, BATgetId(b), BATcount(b)); } } break; @@ -828,22 +836,41 @@ BATordered(BAT *b) b->tnosorted = p; ALGODEBUG fprintf(stderr, "#BATordered: fixed nosorted(" BUNFMT ") for %s#" BUNFMT " (" LLFMT " usec)\n", p, BATgetId(b), BATcount(b), GDKusec() - t0); goto doreturn; + } else if (!b->trevsorted && + b->tnorevsorted == 0 && + lptr[p - 1] < lptr[p]) { + b->tnorevsorted = p; + ALGODEBUG fprintf(stderr, "#BATordered: fixed norevsorted(" BUNFMT ") for %s#" BUNFMT "\n", p, BATgetId(b), BATcount(b)); } } break; } default: for (q = BUNlast(b), p = 1; p < q; p++) { - if (cmpf(BUNtail(bi, p - 1), BUNtail(bi, p)) > 0) { + int c; + if ((c = cmpf(BUNtail(bi, p - 1), BUNtail(bi, p))) > 0) { b->tnosorted = p; ALGODEBUG fprintf(stderr, "#BATordered: fixed nosorted(" BUNFMT ") for %s#" BUNFMT " (" LLFMT " usec)\n", p, BATgetId(b), BATcount(b), GDKusec() - t0); goto doreturn; _______________________________________________ checkin-list mailing list [email protected] https://www.monetdb.org/mailman/listinfo/checkin-list
