Changeset: c3e078b0807a for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c3e078b0807a Added Files: monetdb5/extras/jaql/jaqltests/Tests/calculations.jaql monetdb5/extras/jaql/jaqltests/Tests/calculations.stable.err monetdb5/extras/jaql/jaqltests/Tests/calculations.stable.out Modified Files: HowToStart.rst gdk/gdk_group.c gdk/gdk_select.c monetdb5/extras/jaql/Tests/func00.mal monetdb5/extras/jaql/Tests/func00.stable.out monetdb5/extras/jaql/jaqlfunc.mal monetdb5/extras/jaql/jaqlgencode.c monetdb5/mal/mal_dataflow.c monetdb5/mal/mal_resolve.c monetdb5/modules/mal/pcre.c monetdb5/modules/mal/tablet.c monetdb5/optimizer/opt_prelude.c monetdb5/optimizer/opt_prelude.h monetdb5/optimizer/opt_pushselect.c sql/backends/monet5/UDF/Tests/udf-fuse.stable.out sql/backends/monet5/UDF/Tests/udf-reverse.stable.out sql/backends/monet5/sql.mx sql/backends/monet5/sql_gencode.c sql/backends/monet5/sql_optimizer.c sql/backends/monet5/sql_scenario.c sql/scripts/75_storagemodel.sql sql/storage/bat/bat_storage.c sql/test/BugTracker-2009/Tests/POWER_vs_prod.SF-2596114.stable.out sql/test/BugTracker-2009/Tests/explain_gives_crash.SF-2741829.stable.out sql/test/BugTracker-2010/Tests/LIMIT_OFFSET_big-endian.Bug-2622.stable.out sql/test/BugTracker-2010/Tests/group-by_ordered_column.Bug-2564.stable.out sql/test/BugTracker-2011/Tests/exists-select.Bug-2933.stable.out sql/test/BugTracker-2011/Tests/func_iter_vs_bulk.Bug-2826.stable.out sql/test/BugTracker/Tests/explain.SF-1739353.stable.out sql/test/BugTracker/Tests/jdbc_no_debug.SF-1739356.stable.out Branch: rdf Log Message:
Merge with default branch diffs (truncated from 4078 to 300 lines): diff --git a/HowToStart.rst b/HowToStart.rst --- a/HowToStart.rst +++ b/HowToStart.rst @@ -164,8 +164,7 @@ development sources on your computer. hg clone http://dev.monetdb.org/hg/MonetDB This will create the directory MonetDB in your current working directory -with underneath all subcomponents. Then first follow the instructions -in ``buildtools/README`` before continuing with the others. +with underneath all subcomponents. Bootstrap, Configure and Make diff --git a/gdk/gdk_group.c b/gdk/gdk_group.c --- a/gdk/gdk_group.c +++ b/gdk/gdk_group.c @@ -70,6 +70,37 @@ * At the MAL level, the multigroup function would perform the dynamic * optimization. */ +#define GRPhashloop(TYPE) \ + do { \ + v = BUNtail(bi, p); \ + if (grps) { \ + prb = hash_##TYPE(hs, v) ^ hash_oid(hs, &grps[p-r]); \ + for (hb = hs->hash[prb]; \ + hb != BUN_NONE; \ + hb = hs->link[hb]) { \ + if (grps[hb - r] == grps[p - r] && \ + *(TYPE *) v == *(TYPE *) BUNtail(bi, hb)){ \ + ngrps[p - r] = ngrps[hb - r]; \ + if (histo) \ + cnts[ngrps[hb - r]]++; \ + break; \ + } \ + } \ + } else { \ + prb = hash_##TYPE(hs, v); \ + for (hb = hs->hash[prb]; \ + hb != BUN_NONE; \ + hb = hs->link[hb]) { \ + if (*(TYPE *) v == *(TYPE *) BUNtail(bi, hb)){ \ + ngrps[p - r] = ngrps[hb - r]; \ + if (histo) \ + cnts[ngrps[hb - r]]++; \ + break; \ + } \ + } \ + } \ + } while (0) + gdk_return BATgroup_internal(BAT **groups, BAT **extents, BAT **histo, BAT *b, BAT *g, BAT *e, BAT *h, int subsorted) @@ -111,7 +142,8 @@ BATgroup_internal(BAT **groups, BAT **ex if (b->tkey || BATcount(b) <= 1 || (g && (g->tkey || BATtdense(g)))) { /* grouping is trivial: 1 element per group */ - ALGODEBUG fprintf(stderr, "#BATgroup: trivial case: 1 element per group\n"); + ALGODEBUG fprintf(stderr, "#BATgroup: trivial case: " + "1 element per group\n"); if (BATcount(b) == 1 && b->htype == TYPE_oid) ngrp = * (oid *) Hloc(b, BUNfirst(b)); else @@ -146,7 +178,8 @@ BATgroup_internal(BAT **groups, BAT **ex /* all values are equal */ if (g == NULL) { /* there's only a single group: 0 */ - ALGODEBUG fprintf(stderr, "#BATgroup: trivial case: single output group\n"); + ALGODEBUG fprintf(stderr, "#BATgroup: trivial case: " + "single output group\n"); ngrp = 0; gn = BATconstant(TYPE_oid, &ngrp, BATcount(b)); if (gn == NULL) @@ -178,7 +211,8 @@ BATgroup_internal(BAT **groups, BAT **ex * e/h available in order to copy them, * otherwise we will need to calculate them * which we will do using the "normal" case */ - ALGODEBUG fprintf(stderr, "#BATgroup: trivial case: copy input groups\n"); + ALGODEBUG fprintf(stderr, "#BATgroup: trivial case: " + "copy input groups\n"); gn = BATcopy(g, g->htype, g->ttype, 0); if (gn == NULL) goto error; @@ -249,7 +283,9 @@ BATgroup_internal(BAT **groups, BAT **ex if ((grps && *grps != prev) || cmp(pv, v) != 0) { ngrp++; if (ngrp == maxgrps) { - /* we need to extend extents and histo bats, do it once */ + /* we need to extend extents + * and histo bats, do it + * once */ maxgrps = BATcount(b); if (extents) { BATsetcount(en, ngrp); @@ -324,7 +360,8 @@ BATgroup_internal(BAT **groups, BAT **ex } /* start a new group */ if (ngrp == maxgrps) { - /* we need to extend extents and histo bats, do it once */ + /* we need to extend extents and histo + * bats, do it once */ maxgrps = BATcount(b); if (extents) { BATsetcount(en, ngrp); @@ -371,7 +408,9 @@ BATgroup_internal(BAT **groups, BAT **ex if (hb == BUN_NONE) { /* no equal found: start new group */ if (ngrp == maxgrps) { - /* we need to extend extents and histo bats, do it once */ + /* we need to extend extents + * and histo bats, do it + * once */ maxgrps = BATcount(b); if (extents) { BATsetcount(en, ngrp); @@ -425,53 +464,50 @@ BATgroup_internal(BAT **groups, BAT **ex GDKerror("BATgroup: cannot allocate hash table\n"); goto error; } -#define GRPhashloop(TYPE,EXP1,EXP2) {\ -v = BUNtail(bi, p);\ -prb = hash_##TYPE(hs, v) EXP1;\ -for (hb = hs->hash[prb];\ - hb != BUN_NONE;\ - hb = hs->link[hb]) {\ - if (EXP2 *(TYPE*) v == *(TYPE*) BUNtail(bi,hb) ){\ - ngrps[p - r] = ngrps[hb - r];\ - if (histo)\ - cnts[ngrps[hb - r]]++;\ - break;\ - }\ -} } - -#define GRPhashfactor(TYPE) \ - if (grps == NULL ) { GRPhashloop(TYPE,, ) }\ - else GRPhashloop(TYPE, ^ hash_oid(hs, (oid *)&grps[p-r]) ,grps[hb - r] == grps[p - r] &&) - -#define GRPhashswitch \ -switch( ATOMstorage(hs->type)){\ -case TYPE_bte: GRPhashfactor(bte); break;\ -case TYPE_sht: GRPhashfactor(sht); break;\ -case TYPE_int: GRPhashfactor(int); break;\ -case TYPE_flt: GRPhashfactor(flt); break;\ -case TYPE_lng: GRPhashfactor(lng); break;\ -default: \ - v = BUNtail(bi, p);\ - prb = hash_any(hs, v);\ - for (hb = hs->hash[prb];\ - hb != BUN_NONE;\ - hb = hs->link[hb]) {\ - if ((grps == NULL ||\ - grps[hb - r] == grps[p - r]) &&\ - cmp(v, BUNtail(bi, hb)) == 0) {\ - ngrps[p - r] = ngrps[hb - r];\ - if (histo)\ - cnts[ngrps[hb - r]]++;\ - break;\ - } } } for (r = BUNfirst(b), p = r, q = r + BATcount(b); p < q; p++) { - GRPhashswitch; + switch (ATOMstorage(hs->type)) { + case TYPE_bte: + GRPhashloop(bte); + break; + case TYPE_sht: + GRPhashloop(sht); + break; + case TYPE_int: + GRPhashloop(int); + break; + case TYPE_lng: + GRPhashloop(lng); + break; + case TYPE_flt: + GRPhashloop(flt); + break; + case TYPE_dbl: + GRPhashloop(dbl); + break; + default: + v = BUNtail(bi, p); + prb = hash_any(hs, v); + for (hb = hs->hash[prb]; + hb != BUN_NONE; + hb = hs->link[hb]) { + if ((grps == NULL || + grps[hb - r] == grps[p - r]) && + cmp(v, BUNtail(bi, hb)) == 0) { + ngrps[p - r] = ngrps[hb - r]; + if (histo) + cnts[ngrps[hb - r]]++; + break; + } + } + } if (hb == BUN_NONE) { /* no equal found: start new group and * enter into hash table */ if (ngrp == maxgrps) { - /* we need to extend extents and histo bats, do it at most once */ + /* we need to extend extents + * and histo bats, do it at + * most once */ maxgrps = BATcount(b); if (extents) { BATsetcount(en, ngrp); diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c --- a/gdk/gdk_select.c +++ b/gdk/gdk_select.c @@ -21,6 +21,21 @@ #include "gdk.h" #include "gdk_private.h" +#define buninsfix(B,C,A,I,T,V,G,M,R) \ + do { \ + if ((I) == BATcapacity((B))) { \ + BATsetcount((B), (I)); \ + if (BATextend((B), \ + MIN(BATcapacity((B)) + (G), \ + (M))) == NULL) { \ + BBPreclaim((B)); \ + return (R); \ + } \ + A = (T *) C##loc((B), BUNfirst((B))); \ + } \ + A[(I)] = (V); \ + } while (0) + static BAT * newempty(void) { @@ -93,12 +108,16 @@ BATslice2(BAT *b, BUN l1, BUN h1, BUN l2 } static BAT * -BAT_hashselect(BAT *b, BAT *s, BAT *bn, const void *tl) +BAT_hashselect(BAT *b, BAT *s, BAT *bn, const void *tl, BUN maximum) { BATiter bi; - BUN i; - oid o; - oid off; + BUN i, cnt; + oid o, *dst; + /* off must be signed as it can be negative, + * e.g., if b->hseqbase == 0 and b->U->first > 0; + * instead of wrd, we could also use ssize_t or int/lng with + * 32/64-bit OIDs */ + wrd off; assert(bn->htype == TYPE_void); assert(bn->ttype == TYPE_oid); @@ -110,20 +129,30 @@ BAT_hashselect(BAT *b, BAT *s, BAT *bn, return NULL; } bi = bat_iterator(b); + dst = (oid*) Tloc(bn, BUNfirst(bn)); + cnt = 0; if (s) { assert(s->tsorted); s = BATmirror(s); /* SORTfnd works on HEAD column */ HASHloop(bi, b->H->hash, i, tl) { o = (oid) i + off; - if (SORTfnd(s, &o) != BUN_NONE) - bunfastins(bn, NULL, &o); + if (SORTfnd(s, &o) != BUN_NONE) { + buninsfix(bn, T, dst, cnt, oid, o, + maximum - BATcapacity(bn), + maximum, NULL); + cnt++; + } } } else { HASHloop(bi, b->H->hash, i, tl) { o = (oid) i + off; - bunfastins(bn, NULL, &o); + buninsfix(bn, T, dst, cnt, oid, o, + maximum - BATcapacity(bn), + maximum, NULL); + cnt++; } } + BATsetcount(bn, cnt); bn->tkey = 1; bn->tdense = bn->tsorted = bn->trevsorted = bn->U->count <= 1; if (bn->U->count == 1) @@ -138,163 +167,227 @@ BAT_hashselect(BAT *b, BAT *s, BAT *bn, bn->hsorted = 1; bn->hrevsorted = bn->U->count <= 1; return bn; - - bunins_failed: - BBPreclaim(bn); - return NULL; } -/* scan select loop with candidates */ _______________________________________________ checkin-list mailing list checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list