Changeset: cd9638fcba55 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=cd9638fcba55 Modified Files: clients/Tests/exports.stable.out monetdb5/modules/atoms/blob.c monetdb5/modules/atoms/mtime.c Branch: unlock Log Message:
merged with default diffs (truncated from 849 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 @@ -1511,12 +1511,12 @@ str MTIMEcurrent_time(daytime *ret); str MTIMEcurrent_timestamp(timestamp *ret); str MTIMEdate_add_msec_interval(date *ret, const date *v1, const lng *v2); str MTIMEdate_add_msec_interval_bulk(bat *ret, const bat *bid1, const bat *bid2); -str MTIMEdate_add_msec_interval_bulk_p1(bat *ret, const date *v1, const bat *bid2); -str MTIMEdate_add_msec_interval_bulk_p2(bat *ret, const bat *bid1, const lng *v2); +str MTIMEdate_add_msec_interval_bulk_p1(bat *ret, const date *src1, const bat *bid2); +str MTIMEdate_add_msec_interval_bulk_p2(bat *ret, const bat *bid1, const lng *src2); str MTIMEdate_addmonths(date *ret, const date *v1, const int *v2); str MTIMEdate_addmonths_bulk(bat *ret, const bat *bid1, const bat *bid2); -str MTIMEdate_addmonths_bulk_p1(bat *ret, const date *v1, const bat *bid2); -str MTIMEdate_addmonths_bulk_p2(bat *ret, const bat *bid1, const int *v2); +str MTIMEdate_addmonths_bulk_p1(bat *ret, const date *src1, const bat *bid2); +str MTIMEdate_addmonths_bulk_p2(bat *ret, const bat *bid1, const int *src2); str MTIMEdate_date(date *ret, const date *src); str MTIMEdate_date_bulk(bat *ret, const bat *bid); str MTIMEdate_diff(int *ret, const date *v1, const date *v2); @@ -1545,12 +1545,12 @@ str MTIMEdate_fromstr(date *ret, const s str MTIMEdate_fromstr_bulk(bat *ret, const bat *bid); str MTIMEdate_sub_msec_interval(date *ret, const date *v1, const lng *v2); str MTIMEdate_sub_msec_interval_bulk(bat *ret, const bat *bid1, const bat *bid2); -str MTIMEdate_sub_msec_interval_bulk_p1(bat *ret, const date *v1, const bat *bid2); -str MTIMEdate_sub_msec_interval_bulk_p2(bat *ret, const bat *bid1, const lng *v2); +str MTIMEdate_sub_msec_interval_bulk_p1(bat *ret, const date *src1, const bat *bid2); +str MTIMEdate_sub_msec_interval_bulk_p2(bat *ret, const bat *bid1, const lng *src2); str MTIMEdate_submonths(date *ret, const date *v1, const int *v2); str MTIMEdate_submonths_bulk(bat *ret, const bat *bid1, const bat *bid2); -str MTIMEdate_submonths_bulk_p1(bat *ret, const date *v1, const bat *bid2); -str MTIMEdate_submonths_bulk_p2(bat *ret, const bat *bid1, const int *v2); +str MTIMEdate_submonths_bulk_p1(bat *ret, const date *src1, const bat *bid2); +str MTIMEdate_submonths_bulk_p2(bat *ret, const bat *bid1, const int *src2); str MTIMEdate_to_str(str *ret, const date *v1, const str *v2); str MTIMEdate_to_str_bulk(bat *ret, const bat *bid1, const bat *bid2); str MTIMEdate_to_str_bulk_p1(bat *ret, const date *src1, const bat *bid2); @@ -1612,12 +1612,12 @@ str MTIMEtime_to_str_bulk_p1(bat *ret, c str MTIMEtime_to_str_bulk_p2(bat *ret, const bat *bid1, const str *src2); str MTIMEtimestamp_add_month_interval(timestamp *ret, const timestamp *v1, const int *v2); str MTIMEtimestamp_add_month_interval_bulk(bat *ret, const bat *bid1, const bat *bid2); -str MTIMEtimestamp_add_month_interval_bulk_p1(bat *ret, const timestamp *v1, const bat *bid2); -str MTIMEtimestamp_add_month_interval_bulk_p2(bat *ret, const bat *bid1, const int *v2); +str MTIMEtimestamp_add_month_interval_bulk_p1(bat *ret, const timestamp *src1, const bat *bid2); +str MTIMEtimestamp_add_month_interval_bulk_p2(bat *ret, const bat *bid1, const int *src2); str MTIMEtimestamp_add_msec_interval(timestamp *ret, const timestamp *v1, const lng *v2); str MTIMEtimestamp_add_msec_interval_bulk(bat *ret, const bat *bid1, const bat *bid2); -str MTIMEtimestamp_add_msec_interval_bulk_p1(bat *ret, const timestamp *v1, const bat *bid2); -str MTIMEtimestamp_add_msec_interval_bulk_p2(bat *ret, const bat *bid1, const lng *v2); +str MTIMEtimestamp_add_msec_interval_bulk_p1(bat *ret, const timestamp *src1, const bat *bid2); +str MTIMEtimestamp_add_msec_interval_bulk_p2(bat *ret, const bat *bid1, const lng *src2); str MTIMEtimestamp_century(int *ret, const timestamp *src); str MTIMEtimestamp_century_bulk(bat *ret, const bat *bid); str MTIMEtimestamp_day(int *ret, const timestamp *src); @@ -1652,12 +1652,12 @@ str MTIMEtimestamp_sql_seconds(int *ret, str MTIMEtimestamp_sql_seconds_bulk(bat *ret, const bat *bid); str MTIMEtimestamp_sub_month_interval(timestamp *ret, const timestamp *v1, const int *v2); str MTIMEtimestamp_sub_month_interval_bulk(bat *ret, const bat *bid1, const bat *bid2); -str MTIMEtimestamp_sub_month_interval_bulk_p1(bat *ret, const timestamp *v1, const bat *bid2); -str MTIMEtimestamp_sub_month_interval_bulk_p2(bat *ret, const bat *bid1, const int *v2); +str MTIMEtimestamp_sub_month_interval_bulk_p1(bat *ret, const timestamp *src1, const bat *bid2); +str MTIMEtimestamp_sub_month_interval_bulk_p2(bat *ret, const bat *bid1, const int *src2); str MTIMEtimestamp_sub_msec_interval(timestamp *ret, const timestamp *v1, const lng *v2); str MTIMEtimestamp_sub_msec_interval_bulk(bat *ret, const bat *bid1, const bat *bid2); -str MTIMEtimestamp_sub_msec_interval_bulk_p1(bat *ret, const timestamp *v1, const bat *bid2); -str MTIMEtimestamp_sub_msec_interval_bulk_p2(bat *ret, const bat *bid1, const lng *v2); +str MTIMEtimestamp_sub_msec_interval_bulk_p1(bat *ret, const timestamp *src1, const bat *bid2); +str MTIMEtimestamp_sub_msec_interval_bulk_p2(bat *ret, const bat *bid1, const lng *src2); str MTIMEtimestamp_timestamp(timestamp *ret, const timestamp *src); str MTIMEtimestamp_timestamp_bulk(bat *ret, const bat *bid); str MTIMEtimestamp_to_str(str *ret, const timestamp *v1, const str *v2); diff --git a/monetdb5/modules/atoms/blob.c b/monetdb5/modules/atoms/blob.c --- a/monetdb5/modules/atoms/blob.c +++ b/monetdb5/modules/atoms/blob.c @@ -202,7 +202,7 @@ BLOBnitems_bulk(bat *ret, const bat *bid { BAT *b = NULL, *bn = NULL; BUN n, p, q; - int *dst, i = 0; + int *dst; str msg = MAL_SUCCEED; BATiter bi; @@ -219,7 +219,7 @@ BLOBnitems_bulk(bat *ret, const bat *bid bi = bat_iterator(b); BATloop(b, p, q) { blob *next = BUNtvar(bi, p); - dst[i++] = blob_nitems(next); + dst[p] = blob_nitems(next); } bn->tnonil = b->tnonil; bn->tnil = b->tnil; diff --git a/monetdb5/modules/atoms/mtime.c b/monetdb5/modules/atoms/mtime.c --- a/monetdb5/modules/atoms/mtime.c +++ b/monetdb5/modules/atoms/mtime.c @@ -67,13 +67,39 @@ MTIMEcurrent_timestamp(timestamp *ret) #define is_str_nil strNil -#define COPYFLAGS do { bn->tsorted = b->tsorted; bn->trevsorted = b->trevsorted; } while (0) + +#define DEC_INT(INTYPE, VAR) INTYPE * VAR; + +#define INIT_INT(VAR, VAR_BAT) VAR = Tloc(VAR_BAT, 0); + +#define APPEND_INT(MALFUNC) dst[i] = res; + +#define GET_NEXT_INT(VAR) VAR[i] + + +#define DEC_STR(INTYPE, VAR) BATiter VAR; + +#define INIT_STR(VAR, VAR_BAT) VAR = bat_iterator(VAR_BAT); + +#define APPEND_STR(MALFUNC) \ + if (BUNappend(bn, res, false) != GDK_SUCCEED) { \ + msg = createException(SQL, "batmtime." MALFUNC, SQLSTATE(HY013) MAL_MALLOC_FAIL); \ + break; \ + } + +#define GET_NEXT_STR(VAR) BUNtvar(VAR, i) + + +#define DEC_NOTHING(A, B) ; + +#define COPYFLAGS do { bn->tsorted = b1->tsorted; bn->trevsorted = b1->trevsorted; } while (0) #define SETFLAGS do { bn->tsorted = bn->trevsorted = n < 2; } while (0) -#define func1(NAME, NAMEBULK, MALFUNC, INTYPE, OUTYPE, FUNC, SETFLAGS, FUNC_CALL) \ -mal_export str NAME(OUTYPE *ret, const INTYPE *src); \ +#define func1(NAME, NAMEBULK, MALFUNC, INTYPE, OUTTYPE, FUNC, SETFLAGS, FUNC_CALL, DEC_INPUT, DEC_OUTPUT, \ + INIT_INPUT, INIT_OUTPUT, GET_NEXT_INPUT) \ +mal_export str NAME(OUTTYPE *ret, const INTYPE *src); \ mal_export str NAMEBULK(bat *ret, const bat *bid); \ str \ -NAME(OUTYPE *ret, const INTYPE *src) \ +NAME(OUTTYPE *ret, const INTYPE *src) \ { \ str msg = MAL_SUCCEED; \ do { \ @@ -84,36 +110,36 @@ NAME(OUTYPE *ret, const INTYPE *src) str \ NAMEBULK(bat *ret, const bat *bid) \ { \ - BAT *b = NULL, *bn = NULL; \ + BAT *b1 = NULL, *bn = NULL; \ BUN n; \ - const INTYPE *src; \ - OUTYPE *dst; \ + DEC_INPUT(INTYPE, src1); \ + DEC_OUTPUT(OUTTYPE, dst); \ str msg = MAL_SUCCEED; \ \ - if ((b = BATdescriptor(*bid)) == NULL) { \ + if ((b1 = BATdescriptor(*bid)) == NULL) { \ msg = createException(MAL, "batmtime." MALFUNC, \ SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); \ goto bailout; \ } \ - n = BATcount(b); \ - if ((bn = COLnew(b->hseqbase, TYPE_##OUTYPE, n, TRANSIENT)) == NULL) { \ + n = BATcount(b1); \ + if ((bn = COLnew(b1->hseqbase, TYPE_##OUTTYPE, n, TRANSIENT)) == NULL) { \ msg = createException(MAL, "batmtime." MALFUNC, \ SQLSTATE(HY013) MAL_MALLOC_FAIL); \ goto bailout; \ } \ - src = Tloc(b, 0); \ - dst = Tloc(bn, 0); \ - for (BUN i = 0; i < n; i++) { \ - FUNC_CALL(FUNC, (dst[i]), src[i]); \ + INIT_INPUT(src1, b1); \ + INIT_OUTPUT(dst, bn); \ + for (BUN i = 0; i < n; i++) { \ + FUNC_CALL(FUNC, (dst[i]), (GET_NEXT_INPUT(src1))); \ } \ - bn->tnonil = b->tnonil; \ - bn->tnil = b->tnil; \ + bn->tnonil = b1->tnonil; \ + bn->tnil = b1->tnil; \ BATsetcount(bn, n); \ SETFLAGS; \ bn->tkey = false; \ bailout: \ - if (b) \ - BBPunfix(b->batCacheid); \ + if (b1) \ + BBPunfix(b1->batCacheid); \ if (msg && bn) \ BBPreclaim(bn); \ else if (bn) \ @@ -124,7 +150,8 @@ bailout: \ #define func1_noexcept(FUNC, RET, PARAM) RET = FUNC(PARAM) #define func1_except(FUNC, RET, PARAM) msg = FUNC(&RET, PARAM); if (msg) break; -#define func2(NAME, NAMEBULK, MALFUNC, INTYPE1, INTYPE2, OUTTYPE, FUNC, FUNC_CALL) \ +#define func2(NAME, NAMEBULK, MALFUNC, INTYPE1, INTYPE2, OUTTYPE, FUNC, FUNC_CALL, DEC_INPUT1, DEC_INPUT2, DEC_OUTPUT, \ + INIT_INPUT1, INIT_INPUT2, INIT_OUTPUT, GET_NEXT_INPUT1, GET_NEXT_INPUT2, APPEND_NEXT) \ mal_export str NAME(OUTTYPE *ret, const INTYPE1 *v1, const INTYPE2 *v2); \ mal_export str NAMEBULK(bat *ret, const bat *bid1, const bat *bid2); \ mal_export str NAMEBULK##_p1(bat *ret, const INTYPE1 *src1, const bat *bid2); \ @@ -143,9 +170,9 @@ NAMEBULK(bat *ret, const bat *bid1, cons { \ BAT *b1 = NULL, *b2 = NULL, *bn = NULL; \ BUN n; \ - const INTYPE1 *src1; \ - const INTYPE2 *src2; \ - OUTTYPE *dst; \ + DEC_INPUT1(INTYPE1, src1); \ + DEC_INPUT2(INTYPE2, src2); \ + DEC_OUTPUT(OUTTYPE, dst); \ str msg = MAL_SUCCEED; \ \ b1 = BATdescriptor(*bid1); \ @@ -166,11 +193,13 @@ NAMEBULK(bat *ret, const bat *bid1, cons SQLSTATE(HY013) MAL_MALLOC_FAIL); \ goto bailout; \ } \ - src1 = Tloc(b1, 0); \ - src2 = Tloc(b2, 0); \ - dst = Tloc(bn, 0); \ - for (BUN i = 0; i < n; i++) { \ - FUNC_CALL(FUNC, (dst[i]), src1[i], src2[i]); \ + INIT_INPUT1(src1, b1); \ + INIT_INPUT2(src2, b2); \ + INIT_OUTPUT(dst, bn); \ + for (BUN i = 0; i < n; i++) { \ + OUTTYPE res; \ + FUNC_CALL(FUNC, (res), (GET_NEXT_INPUT1(src1)), (GET_NEXT_INPUT2(src2))); \ + APPEND_NEXT(MALFUNC); \ } \ bn->tnonil = b1->tnonil & b2->tnonil; \ bn->tnil = b1->tnil | b2->tnil; \ @@ -194,8 +223,8 @@ NAMEBULK##_p1(bat *ret, const INTYPE1 *s { \ BAT *b2 = NULL, *bn = NULL; \ BUN n; \ - const INTYPE2 *src2; \ - OUTTYPE *dst; \ + DEC_INPUT2(INTYPE2, src2); \ + DEC_OUTPUT(OUTTYPE, dst); \ str msg = MAL_SUCCEED; \ \ if ((b2 = BATdescriptor(*bid2)) == NULL) { \ @@ -209,10 +238,12 @@ NAMEBULK##_p1(bat *ret, const INTYPE1 *s SQLSTATE(HY013) MAL_MALLOC_FAIL); \ goto bailout; \ } \ - src2 = Tloc(b2, 0); \ - dst = Tloc(bn, 0); \ - for (BUN i = 0; i < n; i++) { \ - FUNC_CALL(FUNC, (dst[i]), (*src1), src2[i]); \ + INIT_INPUT2(src2, b2); \ + INIT_OUTPUT(dst, bn); \ + for (BUN i = 0; i < n; i++) { \ + OUTTYPE res; \ + FUNC_CALL(FUNC, (res), *src1, (GET_NEXT_INPUT2(src2))); \ + APPEND_NEXT(MALFUNC); \ } \ bn->tnonil = !is_##INTYPE1##_nil(*src1) && b2->tnonil; \ bn->tnil = is_##INTYPE1##_nil(*src1) || b2->tnil; \ @@ -234,8 +265,8 @@ NAMEBULK##_p2(bat *ret, const bat *bid1, { \ BAT *b1 = NULL, *bn = NULL; \ BUN n; \ - const INTYPE1 *src1; \ - OUTTYPE *dst; \ + DEC_INPUT1(INTYPE1, src1); \ + DEC_OUTPUT(OUTTYPE, dst); \ str msg = MAL_SUCCEED; \ \ if ((b1 = BATdescriptor(*bid1)) == NULL) { \ @@ -249,10 +280,12 @@ NAMEBULK##_p2(bat *ret, const bat *bid1, SQLSTATE(HY013) MAL_MALLOC_FAIL); \ goto bailout; \ } \ - src1 = Tloc(b1, 0); \ - dst = Tloc(bn, 0); \ - for (BUN i = 0; i < n; i++) { \ - FUNC_CALL(FUNC, (dst[i]), src1[i], (*src2)); \ + INIT_INPUT1(src1, b1); \ + INIT_OUTPUT(dst, bn); \ + for (BUN i = 0; i < n; i++) { \ + OUTTYPE res; \ + FUNC_CALL(FUNC, (res), (GET_NEXT_INPUT1(src1)), *src2); \ + APPEND_NEXT(MALFUNC); \ } \ bn->tnonil = b1->tnonil && !is_##INTYPE2##_nil(*src2); \ bn->tnil = b1->tnil || is_##INTYPE2##_nil(*src2); \ @@ -273,186 +306,91 @@ bailout: \ #define func2_noexcept(FUNC, RET, PARAM1, PARAM2) RET = FUNC(PARAM1, PARAM2) #define func2_except(FUNC, RET, PARAM1, PARAM2) msg = FUNC(&RET, PARAM1, PARAM2); if (msg) break; -func2(MTIMEdate_diff, MTIMEdate_diff_bulk, "diff", date, date, int, date_diff, func2_noexcept) -func2(MTIMEdaytime_diff_msec, MTIMEdaytime_diff_msec_bulk, "diff", daytime, daytime, lng, daytime_diff, func2_noexcept) +func2(MTIMEdate_diff, MTIMEdate_diff_bulk, "diff", date, date, int, date_diff, func2_noexcept, \ + DEC_INT, DEC_INT, DEC_INT, INIT_INT, INIT_INT, INIT_INT, GET_NEXT_INT, GET_NEXT_INT, APPEND_INT) +func2(MTIMEdaytime_diff_msec, MTIMEdaytime_diff_msec_bulk, "diff", daytime, daytime, lng, daytime_diff, func2_noexcept, \ + DEC_INT, DEC_INT, DEC_INT, INIT_INT, INIT_INT, INIT_INT, GET_NEXT_INT, GET_NEXT_INT, APPEND_INT) + +static inline str _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list