Changeset: a9b777c3b1ce for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a9b777c3b1ce Modified Files: gdk/gdk_bat.c gdk/gdk_batop.c gdk/gdk_bbp.c gdk/gdk_firstn.c gdk/gdk_group.c gdk/gdk_join.c gdk/gdk_logger.c gdk/gdk_sample.c gdk/gdk_select.c gdk/gdk_unique.c sql/backends/monet5/generator/generator.c sql/backends/monet5/sql.c sql/storage/bat/bat_table.c sql/storage/bat/bat_utils.c Branch: default Log Message:
Merge with Jul2017 branch. diffs (truncated from 600 to 300 lines): diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -246,10 +246,10 @@ BATdense(oid hseq, oid tseq, BUN cnt) BAT *bn; bn = COLnew(hseq, TYPE_void, 0, TRANSIENT); - if (bn == NULL) - return NULL; - BATtseqbase(bn, tseq); - BATsetcount(bn, cnt); + if (bn != NULL) { + BATtseqbase(bn, tseq); + BATsetcount(bn, cnt); + } return bn; } @@ -1380,6 +1380,7 @@ BATsetcount(BAT *b, BUN cnt) { /* head column is always VOID, and some head properties never change */ assert(b->hseqbase != oid_nil); + assert(cnt <= BUN_MAX); b->batCount = cnt; b->batDirtydesc = TRUE; diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -1306,21 +1306,17 @@ BATsort(BAT **sorted, BAT **order, BAT * *sorted = bn; } if (order) { - on = COLnew(b->hseqbase, TYPE_void, BATcount(b), TRANSIENT); + on = BATdense(b->hseqbase, b->hseqbase, BATcount(b)); if (on == NULL) goto error; - BATsetcount(on, BATcount(b)); - BATtseqbase(on, b->hseqbase); *order = on; } if (groups) { if (BATtkey(b)) { /* singleton groups */ - gn = COLnew(0, TYPE_void, BATcount(b), TRANSIENT); + gn = BATdense(0, 0, BATcount(b)); if (gn == NULL) goto error; - BATsetcount(gn, BATcount(b)); - BATtseqbase(gn, 0); } else { /* single group */ const oid *o = 0; @@ -1822,15 +1818,9 @@ BATcount_no_nil(BAT *b) static BAT * newdensecand(oid first, oid last) { - BAT *bn; - - if ((bn = COLnew(0, TYPE_void, 0, TRANSIENT)) == NULL) - return NULL; if (last < first) first = last = 0; /* empty range */ - BATsetcount(bn, last - first); - BATtseqbase(bn, first); - return bn; + return BATdense(0, first, last - first); } /* merge two candidate lists and produce a new one diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -321,9 +321,18 @@ BBPselectfarm(int role, int type, enum h { int i; - assert(role >= 0 && role < 32); (void) type; /* may use in future */ (void) hptype; /* may use in future */ + + assert(role >= 0 && role < 32); +#ifndef PERSISTENTHASH + if (hptype == hashheap) + role = TRANSIENT; +#endif +#ifndef PERSISTENTIDX + if (hptype == orderidxheap) + role = TRANSIENT; +#endif for (i = 0; i < MAXFARMS; i++) if (BBPfarms[i].dirname && BBPfarms[i].roles & (1 << role)) return i; @@ -1909,7 +1918,9 @@ BBPdump(void) vm += HEAPvmsize(b->thash->heap); } } - fprintf(stderr, "\n"); + fprintf(stderr, " role: %s, persistence: %s\n", + b->batRole == PERSISTENT ? "persistent" : "transient", + b->batPersistence == PERSISTENT ? "persistent" : "transient"); } fprintf(stderr, "# %d bats: mem=" SZFMT ", vm=" SZFMT " %d cached bats: mem=" SZFMT ", vm=" SZFMT "\n", diff --git a/gdk/gdk_firstn.c b/gdk/gdk_firstn.c --- a/gdk/gdk_firstn.c +++ b/gdk/gdk_firstn.c @@ -119,6 +119,10 @@ * refer to the N smallest/largest (depending on asc) tail values of b * (taking the optional candidate list s into account). If there are * multiple equal values to take us past N, we return a subset of those. + * + * If lastp is non-NULL, it is filled in with the oid of the "last" + * value, i.e. the value of which there may be multiple occurrences + * that are not all included in the first N. */ static BAT * BATfirstn_unique(BAT *b, BAT *s, BUN n, int asc, oid *lastp) @@ -148,11 +152,9 @@ BATfirstn_unique(BAT *b, BAT *s, BUN n, } } else if (n >= cnt) { /* trivial: return everything */ - bn = COLnew(0, TYPE_void, cnt, TRANSIENT); + bn = BATdense(0, start + b->hseqbase, cnt); if (bn == NULL) return NULL; - BATsetcount(bn, cnt); - BATtseqbase(bn, start + b->hseqbase); if (lastp) *lastp = 0; return bn; @@ -178,18 +180,14 @@ BATfirstn_unique(BAT *b, BAT *s, BUN n, *lastp = candend[-(ssize_t)n]; return BATslice(s, i - n, i); } - bn = COLnew(0, TYPE_void, n, TRANSIENT); - if (bn == NULL) - return NULL; - BATsetcount(bn, n); if (asc ? b->tsorted : b->trevsorted) { /* first n entries from b */ - BATtseqbase(bn, start + b->hseqbase); + bn = BATdense(0, start + b->hseqbase, n); if (lastp) *lastp = start + b->hseqbase + n - 1; } else { /* last n entries from b */ - BATtseqbase(bn, start + cnt + b->hseqbase - n); + bn = BATdense(0, start + cnt + b->hseqbase - n, n); if (lastp) *lastp = start + cnt + b->hseqbase - n; } @@ -370,6 +368,17 @@ BATfirstn_unique(BAT *b, BAT *s, BUN n, } \ } while (0) +/* This version of BATfirstn is like the one above, except that it + * also looks at groups. The values of the group IDs are important: + * we return only the smallest N (i.e., not dependent on asc which + * refers only to the values in the BAT b). + * + * If lastp is non-NULL, it is filled in with the oid of the "last" + * value, i.e. the value of which there may be multiple occurrences + * that are not all included in the first N. If lastgp is non-NULL, + * it is filled with the group ID (not the oid of the group ID) for + * that same value. + */ static BAT * BATfirstn_unique_with_groups(BAT *b, BAT *s, BAT *g, BUN n, int asc, oid *lastp, oid *lastgp) { @@ -401,11 +410,7 @@ BATfirstn_unique_with_groups(BAT *b, BAT if (n == 0) { /* candidate list might refer only to values outside * of the bat and hence be effectively empty */ - bn = COLnew(0, TYPE_void, 0, TRANSIENT); - if (bn == NULL) - return NULL; - BATtseqbase(bn, 0); - return bn; + return BATdense(0, 0, 0); } bn = COLnew(0, TYPE_oid, n, TRANSIENT); @@ -581,7 +586,7 @@ BATfirstn_grouped(BAT **topn, BAT **gids return GDK_FAIL; if (BATcount(bn) == 0) { if (gids) { - gn = COLnew(0, TYPE_void, 0, TRANSIENT); + gn = BATdense(0, 0, 0); if (gn == NULL) { BBPunfix(bn->batCacheid); return GDK_FAIL; @@ -707,7 +712,7 @@ BATfirstn_grouped_with_groups(BAT **topn } if (BATcount(bn) == 0) { if (gids) { - gn = COLnew(0, TYPE_void, 0, TRANSIENT); + gn = BATdense(0, 0, 0); if (gn == NULL) { BBPunfix(bn->batCacheid); return GDK_FAIL; @@ -816,17 +821,15 @@ BATfirstn(BAT **topn, BAT **gids, BAT *b if (n == 0 || BATcount(b) == 0 || (s != NULL && BATcount(s) == 0)) { /* trivial: empty result */ - *topn = COLnew(0, TYPE_void, 0, TRANSIENT); + *topn = BATdense(0, 0, 0); if (*topn == NULL) return GDK_FAIL; - BATtseqbase(*topn, 0); if (gids) { - *gids = COLnew(0, TYPE_void, 0, TRANSIENT); + *gids = BATdense(0, 0, 0); if (*gids == NULL) { BBPreclaim(*topn); return GDK_FAIL; } - BATtseqbase(*gids, 0); } return GDK_SUCCEED; } diff --git a/gdk/gdk_group.c b/gdk/gdk_group.c --- a/gdk/gdk_group.c +++ b/gdk/gdk_group.c @@ -599,17 +599,16 @@ BATgroup_internal(BAT **groups, BAT **ex h ? BATgetId(h) : "NULL", h ? BATcount(h) : 0, subsorted); ngrp = cnt == 0 ? 0 : cand ? s->hseqbase + (cand - (const oid *) Tloc(s, 0)) : s ? s->hseqbase + start - s->tseqbase : b->hseqbase; - gn = COLnew(hseqb, TYPE_void, BATcount(b), TRANSIENT); + gn = BATdense(hseqb, 0, BATcount(b)); if (gn == NULL) goto error; - BATsetcount(gn, BATcount(b)); - BATtseqbase(gn, 0); *groups = gn; if (extents) { if (cand) { en = COLnew(0, TYPE_oid, cnt, TRANSIENT); if (en == NULL) goto error; + BATsetcount(en, cnt); memcpy(Tloc(en, 0), cand, cnt * sizeof(oid)); en->tsorted = 1; en->trevsorted = cnt <= 1; @@ -618,12 +617,10 @@ BATgroup_internal(BAT **groups, BAT **ex en->tnonil = 1; en->tdense = 0; } else { - en = COLnew(0, TYPE_void, BATcount(b), TRANSIENT); + en = BATdense(0, b->hseqbase, cnt); if (en == NULL) goto error; - BATtseqbase(en, b->hseqbase + start); } - BATsetcount(en, cnt); *extents = en; } if (histo) { @@ -672,11 +669,9 @@ BATgroup_internal(BAT **groups, BAT **ex *groups = gn; if (extents) { ngrp = b->hseqbase + start; - en = COLnew(0, TYPE_void, 1, TRANSIENT); + en = BATdense(0, b->hseqbase + start, 1); if (en == NULL) goto error; - BATtseqbase(en, b->hseqbase + start); - BATsetcount(en, 1); *extents = en; } if (histo) { diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c --- a/gdk/gdk_join.c +++ b/gdk/gdk_join.c @@ -157,18 +157,16 @@ joininitresults(BAT **r1p, BAT **r2p, BU } if (maxsize == 0) { - r1 = COLnew(0, TYPE_void, 0, TRANSIENT); + r1 = BATdense(0, 0, 0); if (r1 == NULL) { return BUN_NONE; } - BATtseqbase(r1, 0); if (r2p) { - r2 = COLnew(0, TYPE_void, 0, TRANSIENT); + r2 = BATdense(0, 0, 0); if (r2 == NULL) { BBPreclaim(r1); return BUN_NONE; } - BATtseqbase(r2, 0); *r2p = r2; } *r1p = r1; @@ -3755,15 +3753,13 @@ BATjoin(BAT **r1p, BAT **r2p, BAT *l, BA if (sr) rcount = MIN(rcount, BATcount(sr)); if (lcount == 0 || rcount == 0) { - r1 = COLnew(0, TYPE_void, 0, TRANSIENT); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list