Changeset: 129ce6058e13 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=129ce6058e13 Modified Files: clients/Tests/exports.stable.out gdk/ChangeLog.Jun2016 gdk/gdk.h gdk/gdk_aggr.c gdk/gdk_batop.c gdk/gdk_calc.c gdk/gdk_calc_compare.h gdk/gdk_group.c gdk/gdk_project.c monetdb5/modules/atoms/batxml.c monetdb5/modules/atoms/json.c monetdb5/modules/kernel/algebra.c monetdb5/modules/mal/batcalc.c sql/storage/bat/bat_storage.c Branch: Jun2016 Log Message:
Cleanup: removed BATconst, changed BATconstant. diffs (truncated from 444 to 300 lines): diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -102,8 +102,7 @@ BAT *BATcalcxor(BAT *b1, BAT *b2, BAT *s BAT *BATcalcxorcst(BAT *b, const ValRecord *v, BAT *s); gdk_return BATclear(BAT *b, int force); void BATcommit(BAT *b); -BAT *BATconst(BAT *l, int tt, const void *val, int role); -BAT *BATconstant(int tt, const void *val, BUN cnt, int role); +BAT *BATconstant(oid hseq, int tt, const void *val, BUN cnt, int role); BAT *BATconvert(BAT *b, BAT *s, int tp, int abort_on_error); BUN BATcount_no_nil(BAT *b); gdk_return BATdel(BAT *b, BAT *d); diff --git a/gdk/ChangeLog.Jun2016 b/gdk/ChangeLog.Jun2016 --- a/gdk/ChangeLog.Jun2016 +++ b/gdk/ChangeLog.Jun2016 @@ -1,6 +1,11 @@ # ChangeLog file for MonetDB # This file is updated with Maddlog +* Thu Mar 24 2016 Sjoerd Mullender <sjo...@acm.org> +- Removed BATconst. Use BATconstant instead. +- Changed BATconstant. It now has a new first argument with the seqbase + for the head column. + * Thu Jan 14 2016 Sjoerd Mullender <sjo...@acm.org> - Removed BATmmap. It was no longer used. diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -2968,8 +2968,7 @@ gdk_export void BATsetprop(BAT *b, int i gdk_export BAT *BATselect(BAT *b, BAT *s, const void *tl, const void *th, int li, int hi, int anti); gdk_export BAT *BATthetaselect(BAT *b, BAT *s, const void *val, const char *op); -gdk_export BAT *BATconstant(int tt, const void *val, BUN cnt, int role); -gdk_export BAT *BATconst(BAT *l, int tt, const void *val, int role); +gdk_export BAT *BATconstant(oid hseq, int tt, const void *val, BUN cnt, int role); gdk_export gdk_return BATsubcross(BAT **r1p, BAT **r2p, BAT *l, BAT *r, BAT *sl, BAT *sr); gdk_export gdk_return BATleftjoin(BAT **r1p, BAT **r2p, BAT *l, BAT *r, BAT *sl, BAT *sr, int nil_matches, BUN estimate); diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c --- a/gdk/gdk_aggr.c +++ b/gdk/gdk_aggr.c @@ -505,9 +505,7 @@ BATgroupsum(BAT *b, BAT *g, BAT *e, BAT if (BATcount(b) == 0 || ngrp == 0) { /* trivial: no sums, so return bat aligned with g with * nil in the tail */ - bn = BATconstant(tp, ATOMnilptr(tp), ngrp, TRANSIENT); - BATseqbase(bn, ngrp == 0 ? 0 : min); - return bn; + return BATconstant(ngrp == 0 ? 0 : min, tp, ATOMnilptr(tp), ngrp, TRANSIENT); } if ((e == NULL || @@ -518,7 +516,7 @@ BATgroupsum(BAT *b, BAT *g, BAT *e, BAT return BATconvert(b, s, tp, abort_on_error); } - bn = BATconstant(tp, ATOMnilptr(tp), ngrp, TRANSIENT); + bn = BATconstant(0, tp, ATOMnilptr(tp), ngrp, TRANSIENT); if (bn == NULL) { return NULL; } @@ -1161,9 +1159,7 @@ BATgroupprod(BAT *b, BAT *g, BAT *e, BAT if (BATcount(b) == 0 || ngrp == 0) { /* trivial: no products, so return bat aligned with g * with nil in the tail */ - bn = BATconstant(tp, ATOMnilptr(tp), ngrp, TRANSIENT); - BATseqbase(bn, ngrp == 0 ? 0 : min); - return bn; + return BATconstant(ngrp == 0 ? 0 : min, tp, ATOMnilptr(tp), ngrp, TRANSIENT); } if ((e == NULL || @@ -1174,7 +1170,7 @@ BATgroupprod(BAT *b, BAT *g, BAT *e, BAT return BATconvert(b, s, tp, abort_on_error); } - bn = BATconstant(tp, ATOMnilptr(tp), ngrp, TRANSIENT); + bn = BATconstant(0, tp, ATOMnilptr(tp), ngrp, TRANSIENT); if (bn == NULL) { return NULL; } @@ -1450,20 +1446,18 @@ BATgroupavg(BAT **bnp, BAT **cntsp, BAT if (BATcount(b) == 0 || ngrp == 0) { /* trivial: no averages, so return bat aligned with g * with nil in the tail */ - bn = BATconstant(TYPE_dbl, &dbl_nil, ngrp, TRANSIENT); + bn = BATconstant(ngrp == 0 ? 0 : min, TYPE_dbl, &dbl_nil, ngrp, TRANSIENT); if (bn == NULL) { GDKerror("BATgroupavg: failed to create BAT\n"); return GDK_FAIL; } - BATseqbase(bn, ngrp == 0 ? 0 : min); if (cntsp) { wrd zero = 0; - if ((*cntsp = BATconstant(TYPE_wrd, &zero, ngrp, TRANSIENT)) == NULL) { + if ((*cntsp = BATconstant(ngrp == 0 ? 0 : min, TYPE_wrd, &zero, ngrp, TRANSIENT)) == NULL) { GDKerror("BATgroupavg: failed to create BAT\n"); BBPreclaim(bn); return GDK_FAIL; } - BATseqbase(*cntsp, ngrp == 0 ? 0 : min); } *bnp = bn; return GDK_SUCCEED; @@ -1478,11 +1472,10 @@ BATgroupavg(BAT **bnp, BAT **cntsp, BAT return GDK_FAIL; if (cntsp) { wrd one = 1; - if ((*cntsp = BATconstant(TYPE_wrd, &one, ngrp, TRANSIENT)) == NULL) { + if ((*cntsp = BATconstant(ngrp == 0 ? 0 : min, TYPE_wrd, &one, ngrp, TRANSIENT)) == NULL) { BBPreclaim(bn); return GDK_FAIL; } - BATseqbase(*cntsp, ngrp == 0 ? 0 : min); } *bnp = bn; return GDK_SUCCEED; @@ -1828,9 +1821,7 @@ BATgroupcount(BAT *b, BAT *g, BAT *e, BA /* trivial: no products, so return bat aligned with g * with zero in the tail */ wrd zero = 0; - bn = BATconstant(TYPE_wrd, &zero, ngrp, TRANSIENT); - BATseqbase(bn, ngrp == 0 ? 0 : min); - return bn; + return BATconstant(ngrp == 0 ? 0 : min, TYPE_wrd, &zero, ngrp, TRANSIENT); } bn = BATnew(TYPE_void, TYPE_wrd, ngrp, TRANSIENT); @@ -1948,9 +1939,7 @@ BATgroupsize(BAT *b, BAT *g, BAT *e, BAT /* trivial: no products, so return bat aligned with g * with zero in the tail */ wrd zero = 0; - bn = BATconstant(TYPE_wrd, &zero, ngrp, TRANSIENT); - BATseqbase(bn, ngrp == 0 ? 0 : min); - return bn; + return BATconstant(ngrp == 0 ? 0 : min, TYPE_wrd, &zero, ngrp, TRANSIENT); } bn = BATnew(TYPE_void, TYPE_wrd, ngrp, TRANSIENT); @@ -2343,9 +2332,7 @@ BATgroupminmax(BAT *b, BAT *g, BAT *e, B if (BATcount(b) == 0 || ngrp == 0) { /* trivial: no minimums, so return bat aligned with g * with nil in the tail */ - bn = BATconstant(TYPE_oid, &oid_nil, ngrp, TRANSIENT); - BATseqbase(bn, ngrp == 0 ? 0 : min); - return bn; + return BATconstant(ngrp == 0 ? 0 : min, TYPE_oid, &oid_nil, ngrp, TRANSIENT); } bn = BATnew(TYPE_void, TYPE_oid, ngrp, TRANSIENT); @@ -2510,9 +2497,7 @@ BATgroupquantile(BAT *b, BAT *g, BAT *e, if (BATcount(b) == 0 || ngrp == 0) { /* trivial: no values, thus also no quantiles, * so return bat aligned with e with nil in the tail */ - bn = BATconstant(tp, ATOMnilptr(tp), ngrp, TRANSIENT); - BATseqbase(bn, ngrp == 0 ? 0 : min); - return bn; + return BATconstant(ngrp == 0 ? 0 : min, tp, ATOMnilptr(tp), ngrp, TRANSIENT); } if (s) { @@ -2836,9 +2821,7 @@ dogroupstdev(BAT **avgb, BAT *b, BAT *g, if (BATcount(b) == 0 || ngrp == 0) { /* trivial: no products, so return bat aligned with g * with nil in the tail */ - bn = BATconstant(TYPE_dbl, &dbl_nil, ngrp, TRANSIENT); - BATseqbase(bn, ngrp == 0 ? 0 : min); - return bn; + return BATconstant(ngrp == 0 ? 0 : min, TYPE_dbl, &dbl_nil, ngrp, TRANSIENT); } if ((e == NULL || @@ -2847,9 +2830,7 @@ dogroupstdev(BAT **avgb, BAT *b, BAT *g, /* trivial: singleton groups, so all results are equal * to zero (population) or nil (sample) */ dbl v = issample ? dbl_nil : 0; - bn = BATconstant(TYPE_dbl, &v, ngrp, TRANSIENT); - BATseqbase(bn, ngrp == 0 ? 0 : min); - return bn; + return BATconstant(ngrp == 0 ? 0 : min, TYPE_dbl, &v, ngrp, TRANSIENT); } delta = GDKmalloc(ngrp * sizeof(dbl)); diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -1068,16 +1068,16 @@ BATsort(BAT **sorted, BAT **order, BAT * goto error; BATsetcount(gn, BATcount(b)); BATseqbase(BATmirror(gn), 0); + BATseqbase(gn, 0); } else { /* single group */ const oid *o = 0; assert(BATcount(b) == 1 || (BATtordered(b) && BATtrevordered(b))); - gn = BATconstant(TYPE_oid, &o, BATcount(b), TRANSIENT); + gn = BATconstant(0, TYPE_oid, &o, BATcount(b), TRANSIENT); if (gn == NULL) goto error; } - BATseqbase(gn, 0); *groups = gn; } return GDK_SUCCEED; @@ -1246,10 +1246,10 @@ BATsort(BAT **sorted, BAT **order, BAT * return GDK_FAIL; } -/* return a new BAT of length n with a dense head and the constant v - * in the tail */ +/* return a new BAT of length n with a dense head with seqbase hseq, + * and the constant v in the tail */ BAT * -BATconstant(int tailtype, const void *v, BUN n, int role) +BATconstant(oid hseq, int tailtype, const void *v, BUN n, int role) { BAT *bn; void *restrict p; @@ -1304,7 +1304,7 @@ BATconstant(int tailtype, const void *v, bn->trevsorted = 1; bn->T->nonil = !bn->T->nil; bn->T->key = BATcount(bn) <= 1; - BATseqbase(bn, 0); + BATseqbase(bn, hseq); return bn; bunins_failed: @@ -1312,22 +1312,6 @@ BATconstant(int tailtype, const void *v, return NULL; } -/* return a new bat which is aligned with b and with the constant v in - * the tail */ -BAT * -BATconst(BAT *b, int tailtype, const void *v, int role) -{ - BAT *bn; - - BATcheck(b, "BATconst", NULL); - bn = BATconstant(tailtype, v, BATcount(b), role); - if (bn == NULL) - return NULL; - BATseqbase(bn, b->hseqbase); - - return bn; -} - /* * BAT Aggregates * diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c --- a/gdk/gdk_calc.c +++ b/gdk/gdk_calc.c @@ -866,15 +866,11 @@ BATcalcisnil_implementation(BAT *b, BAT (b->T->type == TYPE_void && b->T->seq != oid_nil)) { bit zero = 0; - bn = BATconstant(TYPE_bit, &zero, cnt, TRANSIENT); - BATseqbase(bn, b->H->seq); - return bn; + return BATconstant(b->H->seq, TYPE_bit, &zero, cnt, TRANSIENT); } else if (b->T->type == TYPE_void && b->T->seq == oid_nil) { bit one = 1; - bn = BATconstant(TYPE_bit, &one, cnt, TRANSIENT); - BATseqbase(bn, b->H->seq); - return bn; + return BATconstant(b->H->seq, TYPE_bit, &one, cnt, TRANSIENT); } } @@ -12740,7 +12736,7 @@ BATcalcbetween(BAT *b, BAT *lo, BAT *hi, b->T->seq >= hi->T->seq && b->T->seq <= lo->T->seq)); - return BATconst(b, TYPE_bit, &res, TRANSIENT); + return BATconstant(b->hseqbase, TYPE_bit, &res, BATcount(b), TRANSIENT); } bn = BATcalcbetween_intern(Tloc(b, b->batFirst), 1, diff --git a/gdk/gdk_calc_compare.h b/gdk/gdk_calc_compare.h --- a/gdk/gdk_calc_compare.h +++ b/gdk/gdk_calc_compare.h @@ -645,9 +645,7 @@ BATcalcop(BAT *b1, BAT *b2, BAT *s) else res = OP(b1->T->seq, b2->T->seq); - bn = BATconstant(TYPE_TPE, &res, cnt, TRANSIENT); - BATseqbase(bn, b1->hseqbase); - return bn; + return BATconstant(b1->hseqbase, TYPE_TPE, &res, cnt, TRANSIENT); } bn = BATcalcop_intern(b1->T->type == TYPE_void ? (void *) &b1->T->seq : (void *) Tloc(b1, b1->batFirst), ATOMbasetype(b1->T->type), 1, diff --git a/gdk/gdk_group.c b/gdk/gdk_group.c --- a/gdk/gdk_group.c _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list