Changeset: 9573b019aeb6 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9573b019aeb6 Modified Files: gdk/gdk_aggr.c gdk/gdk_calc.c gdk/gdk_calc_private.h gdk/gdk_join.c Branch: default Log Message:
Push maximum value for overflow check up the call chain. diffs (truncated from 6343 to 300 lines): diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c --- a/gdk/gdk_aggr.c +++ b/gdk/gdk_aggr.c @@ -162,6 +162,7 @@ BATgroupaggrinit(BAT *b, BAT *g, BAT *e, ADD_WITH_CHECK(TYPE1, x, \ TYPE2, sum, \ TYPE2, sum, \ + GDK_##TYPE2##_max, \ goto overflow); \ } \ } else { \ @@ -177,6 +178,7 @@ BATgroupaggrinit(BAT *b, BAT *g, BAT *e, ADD_WITH_CHECK(TYPE1, x, \ TYPE2, sum, \ TYPE2, sum, \ + GDK_##TYPE2##_max, \ goto overflow); \ seenval = 1; \ } \ @@ -209,6 +211,7 @@ BATgroupaggrinit(BAT *b, BAT *g, BAT *e, ADD_WITH_CHECK(TYPE1, x, \ TYPE2, sum, \ TYPE2, sum, \ + GDK_##TYPE2##_max, \ goto overflow); \ seenval = 1; \ } \ @@ -246,6 +249,7 @@ BATgroupaggrinit(BAT *b, BAT *g, BAT *e, sums[gid], \ TYPE2, \ sums[gid], \ + GDK_##TYPE2##_max, \ goto overflow); \ } \ } \ @@ -285,6 +289,7 @@ BATgroupaggrinit(BAT *b, BAT *g, BAT *e, sums[gid], \ TYPE2, \ sums[gid], \ + GDK_##TYPE2##_max, \ goto overflow); \ } \ } \ @@ -710,6 +715,7 @@ BATsum(void *res, int tp, BAT *b, BAT *s TYPE1, vals[i], \ TYPE2, prods[gid], \ TYPE2, prods[gid], \ + GDK_##TYPE2##_max, \ TYPE3, \ goto overflow); \ } \ @@ -758,6 +764,7 @@ BATsum(void *res, int tp, BAT *b, BAT *s HGEMUL_CHECK(TYPE, vals[i], \ hge, prods[gid], \ prods[gid], \ + GDK_hge_max, \ goto overflow); \ } \ } \ @@ -805,6 +812,7 @@ BATsum(void *res, int tp, BAT *b, BAT *s TYPE, vals[i], \ lng, prods[gid], \ prods[gid], \ + GDK_lng_max, \ goto overflow); \ } \ } \ @@ -1618,6 +1626,7 @@ BATgroupavg(BAT **bnp, BAT **cntsp, BAT ADD_WITH_CHECK(TYPE, x, \ lng_hge, sum, \ lng_hge, sum, \ + GDK_hge_max, \ goto overflow##TYPE); \ /* don't count value until after overflow check */ \ n++; \ diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c --- a/gdk/gdk_calc.c +++ b/gdk/gdk_calc.c @@ -1312,7 +1312,8 @@ BATcalcmax_no_nil(BAT *b1, BAT *b2, BAT static BUN \ add_##TYPE1##_##TYPE2##_##TYPE3(const TYPE1 *lft, int incr1, \ const TYPE2 *rgt, int incr2, \ - TYPE3 *restrict dst, BUN cnt, BUN start, \ + TYPE3 *restrict dst, TYPE3 max, \ + BUN cnt, BUN start, \ BUN end, const oid *restrict cand, \ const oid *candend, oid candoff, \ int abort_on_error) \ @@ -1331,6 +1332,7 @@ add_##TYPE1##_##TYPE2##_##TYPE3(const TY ADD_WITH_CHECK(TYPE1, lft[i], \ TYPE2, rgt[j], \ TYPE3, dst[k], \ + max, \ ON_OVERFLOW(TYPE1, TYPE2, "+")); \ } \ } \ @@ -1342,22 +1344,41 @@ add_##TYPE1##_##TYPE2##_##TYPE3(const TY static BUN \ add_##TYPE1##_##TYPE2##_##TYPE3(const TYPE1 *lft, int incr1, \ const TYPE2 *rgt, int incr2, \ - TYPE3 *restrict dst, BUN cnt, BUN start, \ + TYPE3 *restrict dst, TYPE3 max, \ + BUN cnt, BUN start, \ BUN end, const oid *restrict cand, \ - const oid *candend, oid candoff) \ + const oid *candend, oid candoff, \ + int abort_on_error) \ { \ BUN i, j, k; \ BUN nils = 0; \ \ CANDLOOP(dst, k, TYPE3##_nil, 0, start); \ - for (i = start * incr1, j = start * incr2, k = start; \ - k < end; i += incr1, j += incr2, k++) { \ - CHECKCAND(dst, k, candoff, TYPE3##_nil); \ - if (lft[i] == TYPE1##_nil || rgt[j] == TYPE2##_nil) { \ - dst[k] = TYPE3##_nil; \ - nils++; \ - } else { \ - dst[k] = (TYPE3) lft[i] + rgt[j]; \ + if (max < (TYPE3) GDK_##TYPE1##_max + (TYPE3) GDK_##TYPE2##_max) { \ + for (i = start * incr1, j = start * incr2, k = start; \ + k < end; i += incr1, j += incr2, k++) { \ + CHECKCAND(dst, k, candoff, TYPE3##_nil); \ + if (lft[i] == TYPE1##_nil || rgt[j] == TYPE2##_nil) { \ + dst[k] = TYPE3##_nil; \ + nils++; \ + } else { \ + ADD_WITH_CHECK(TYPE1, lft[i], \ + TYPE2, rgt[j], \ + TYPE3, dst[k], \ + max, \ + ON_OVERFLOW(TYPE1, TYPE2, "+")); \ + } \ + } \ + } else { \ + for (i = start * incr1, j = start * incr2, k = start; \ + k < end; i += incr1, j += incr2, k++) { \ + CHECKCAND(dst, k, candoff, TYPE3##_nil); \ + if (lft[i] == TYPE1##_nil || rgt[j] == TYPE2##_nil) { \ + dst[k] = TYPE3##_nil; \ + nils++; \ + } else { \ + dst[k] = (TYPE3) lft[i] + rgt[j]; \ + } \ } \ } \ CANDLOOP(dst, k, TYPE3##_nil, end, cnt); \ @@ -1621,42 +1642,55 @@ add_typeswitchloop(const void *lft, int switch (tp) { case TYPE_bte: nils = add_bte_bte_bte(lft, incr1, rgt, incr2, - dst, cnt, start, end, + dst, GDK_bte_max, cnt, + start, end, cand, candend, candoff, abort_on_error); break; case TYPE_sht: nils = add_bte_bte_sht(lft, incr1, rgt, incr2, - dst, cnt, start, end, - cand, candend, candoff); + dst, GDK_sht_max, cnt, + start, end, + cand, candend, candoff, + abort_on_error); break; #ifdef FULL_IMPLEMENTATION case TYPE_int: nils = add_bte_bte_int(lft, incr1, rgt, incr2, - dst, cnt, start, end, - cand, candend, candoff); + dst, GDK_int_max, cnt, + start, end, + cand, candend, candoff, + abort_on_error); break; case TYPE_lng: nils = add_bte_bte_lng(lft, incr1, rgt, incr2, - dst, cnt, start, end, - cand, candend, candoff); + dst, GDK_lng_max, cnt, + start, end, + cand, candend, candoff, + abort_on_error); break; #ifdef HAVE_HGE case TYPE_hge: nils = add_bte_bte_hge(lft, incr1, rgt, incr2, - dst, cnt, start, end, - cand, candend, candoff); + dst, GDK_hge_max, cnt, + start, end, + cand, candend, candoff, + abort_on_error); break; #endif case TYPE_flt: nils = add_bte_bte_flt(lft, incr1, rgt, incr2, - dst, cnt, start, end, - cand, candend, candoff); + dst, GDK_flt_max, cnt, + start, end, + cand, candend, candoff, + abort_on_error); break; case TYPE_dbl: nils = add_bte_bte_dbl(lft, incr1, rgt, incr2, - dst, cnt, start, end, - cand, candend, candoff); + dst, GDK_dbl_max, cnt, + start, end, + cand, candend, candoff, + abort_on_error); break; #endif default: @@ -1667,37 +1701,48 @@ add_typeswitchloop(const void *lft, int switch (tp) { case TYPE_sht: nils = add_bte_sht_sht(lft, incr1, rgt, incr2, - dst, cnt, start, end, + dst, GDK_sht_max, cnt, + start, end, cand, candend, candoff, abort_on_error); break; case TYPE_int: nils = add_bte_sht_int(lft, incr1, rgt, incr2, - dst, cnt, start, end, - cand, candend, candoff); + dst, GDK_int_max, cnt, + start, end, + cand, candend, candoff, + abort_on_error); break; #ifdef FULL_IMPLEMENTATION case TYPE_lng: nils = add_bte_sht_lng(lft, incr1, rgt, incr2, - dst, cnt, start, end, - cand, candend, candoff); + dst, GDK_lng_max, cnt, + start, end, + cand, candend, candoff, + abort_on_error); break; #ifdef HAVE_HGE case TYPE_hge: nils = add_bte_sht_hge(lft, incr1, rgt, incr2, - dst, cnt, start, end, - cand, candend, candoff); + dst, GDK_hge_max, cnt, + start, end, + cand, candend, candoff, + abort_on_error); break; #endif case TYPE_flt: nils = add_bte_sht_flt(lft, incr1, rgt, incr2, - dst, cnt, start, end, - cand, candend, candoff); + dst, GDK_flt_max, cnt, + start, end, + cand, candend, candoff, + abort_on_error); break; case TYPE_dbl: nils = add_bte_sht_dbl(lft, incr1, rgt, incr2, - dst, cnt, start, end, - cand, candend, candoff); + dst, GDK_dbl_max, cnt, + start, end, + cand, candend, candoff, + abort_on_error); break; #endif default: @@ -1708,32 +1753,41 @@ add_typeswitchloop(const void *lft, int switch (tp) { case TYPE_int: nils = add_bte_int_int(lft, incr1, rgt, incr2, - dst, cnt, start, end, + dst, GDK_int_max, cnt, + start, end, cand, candend, candoff, abort_on_error); break; case TYPE_lng: nils = add_bte_int_lng(lft, incr1, rgt, incr2, - dst, cnt, start, end, - cand, candend, candoff); + dst, GDK_lng_max, cnt, + start, end, + cand, candend, candoff, + abort_on_error); break; #ifdef FULL_IMPLEMENTATION #ifdef HAVE_HGE case TYPE_hge: nils = add_bte_int_hge(lft, incr1, rgt, incr2, _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list