Changeset: e066094d5537 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/e066094d5537 Modified Files: gdk/gdk.h gdk/gdk_bat.c gdk/gdk_batop.c gdk/gdk_group.c gdk/gdk_hash.c Branch: default Log Message:
Merge with Jul2021 branch. diffs (truncated from 709 to 300 lines): diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -1696,6 +1696,12 @@ tfastins_nocheckVAR(BAT *b, BUN p, const } static inline gdk_return __attribute__((__warn_unused_result__)) +tfastins_nocheckFIX(BAT *b, BUN p, const void *v) +{ + return ATOMputFIX(b->ttype, Tloc(b, p), v); +} + +static inline gdk_return __attribute__((__warn_unused_result__)) tfastins_nocheck(BAT *b, BUN p, const void *v) { assert(b->theap->parentid == b->batCacheid); @@ -1707,7 +1713,7 @@ tfastins_nocheck(BAT *b, BUN p, const vo } else if (b->tvarsized) { return tfastins_nocheckVAR(b, p, v); } else { - return ATOMputFIX(b->ttype, Tloc(b, p), v); + return tfastins_nocheckFIX(b, p, v); } return GDK_SUCCEED; } diff --git a/gdk/gdk_analytic_func.c b/gdk/gdk_analytic_func.c --- a/gdk/gdk_analytic_func.c +++ b/gdk/gdk_analytic_func.c @@ -70,7 +70,7 @@ GDKrebuild_segment_tree(oid ncount, oid #define ANALYTICAL_NTILE(IMP, TPE, NEXT_VALUE, LNG_HGE, UPCAST, VALIDATION) \ do { \ - TPE *restrict rb = (TPE*)Tloc(r, 0); \ + TPE *rb = (TPE*)Tloc(r, 0); \ if (p) { \ while (i < cnt) { \ if (np[i]) { \ @@ -197,7 +197,7 @@ invalidntile: #define ANALYTICAL_FIRST_FIXED(TPE) \ do { \ const TPE *bp = (TPE*)bi.base; \ - TPE *restrict rb = (TPE*)Tloc(r, 0); \ + TPE *rb = (TPE*)Tloc(r, 0); \ for (; k < cnt; k++) { \ const TPE *bs = bp + start[k], *be = bp + end[k]; \ TPE curval = (be > bs) ? *bs : TPE##_nil; \ @@ -279,7 +279,7 @@ GDKanalyticalfirst(BAT *r, BAT *b, BAT * #define ANALYTICAL_LAST_FIXED(TPE) \ do { \ const TPE *bp = (TPE*)bi.base; \ - TPE *restrict rb = (TPE*)Tloc(r, 0); \ + TPE *rb = (TPE*)Tloc(r, 0); \ for (; k < cnt; k++) { \ const TPE *bs = bp + start[k], *be = bp + end[k]; \ TPE curval = (be > bs) ? *(be - 1) : TPE##_nil; \ @@ -360,7 +360,7 @@ GDKanalyticallast(BAT *r, BAT *b, BAT *s #define ANALYTICAL_NTHVALUE_IMP_SINGLE_FIXED(TPE) \ do { \ const TPE *bp = (TPE*)bi.base; \ - TPE *restrict rb = (TPE*)Tloc(r, 0); \ + TPE *rb = (TPE*)Tloc(r, 0); \ if (is_lng_nil(nth)) { \ has_nils = true; \ for (; k < cnt; k++) \ @@ -380,7 +380,7 @@ GDKanalyticallast(BAT *r, BAT *b, BAT *s #define ANALYTICAL_NTHVALUE_IMP_MULTI_FIXED(TPE) \ do { \ const TPE *bp = (TPE*)bi.base; \ - TPE curval, *restrict rb = (TPE*)Tloc(r, 0); \ + TPE curval, *rb = (TPE*)Tloc(r, 0); \ for (; k < cnt; k++) { \ lng lnth = tp[k]; \ const TPE *bs = bp + start[k]; \ @@ -1171,7 +1171,7 @@ GDKanalyticallead(BAT *r, BAT *b, BAT *p #define ANALYTICAL_MIN_MAX_PARTITIONS(TPE, MIN_MAX, IMP) \ do { \ - TPE *restrict bp = (TPE*)bi.base, *restrict rb = (TPE*)Tloc(r, 0); \ + TPE *restrict bp = (TPE*)bi.base, *rb = (TPE*)Tloc(r, 0); \ if (p) { \ while (i < cnt) { \ if (np[i]) { \ @@ -1606,7 +1606,7 @@ GDKanalyticalcount(BAT *r, BAT *p, BAT * BATiter ei = bat_iterator(e); oid i = 0, j = 0, k = 0, l = 0, cnt = BATcount(b), *restrict start = si.base, *restrict end = ei.base, *levels_offset = NULL, tree_capacity = 0, nlevels = 0; - lng curval = 0, *restrict rb = (lng *) Tloc(r, 0); + lng curval = 0, *rb = (lng *) Tloc(r, 0); bit *np = pi.base, *op = oi.base; const void *restrict nil = ATOMnilptr(tpe); int (*cmp) (const void *, const void *) = ATOMcompare(tpe); @@ -1787,7 +1787,7 @@ cleanup: #define ANALYTICAL_SUM_CALC(TPE1, TPE2, IMP) \ do { \ TPE1 *restrict bp = (TPE1*)bi.base; \ - TPE2 *restrict rb = (TPE2*)Tloc(r, 0); \ + TPE2 *rb = (TPE2*)Tloc(r, 0); \ if (p) { \ while (i < cnt) { \ if (np[i]) { \ @@ -2290,7 +2290,7 @@ nosupport: #define ANALYTICAL_PROD_CALC_NUM_PARTITIONS(TPE1, TPE2, TPE3_OR_REAL_IMP, IMP) \ do { \ TPE1 *restrict bp = (TPE1*)bi.base; \ - TPE2 *restrict rb = (TPE2*)Tloc(r, 0); \ + TPE2 *rb = (TPE2*)Tloc(r, 0); \ if (p) { \ while (i < cnt) { \ if (np[i]) { \ @@ -2856,7 +2856,7 @@ GDKanalyticalavg(BAT *r, BAT *p, BAT *o, oid i = 0, j = 0, k = 0, l = 0, cnt = BATcount(b), *restrict start = si.base, *restrict end = ei.base, *levels_offset = NULL, tree_capacity = 0, nlevels = 0; lng n = 0, rr = 0; - dbl *restrict rb = (dbl *) Tloc(r, 0), curval = dbl_nil; + dbl *rb = (dbl *) Tloc(r, 0), curval = dbl_nil; bit *np = pi.base, *op = oi.base; bool abort_on_error = true; BUN nils = 0; @@ -3058,7 +3058,7 @@ avg_int_deltas(lng) #define ANALYTICAL_AVG_INT_PARTITIONS(TPE, IMP) \ do { \ - TPE *restrict bp = (TPE*)bi.base, *restrict rb = (TPE *) Tloc(r, 0); \ + TPE *restrict bp = (TPE*)bi.base, *rb = (TPE *) Tloc(r, 0); \ if (p) { \ while (i < cnt) { \ if (np[i]) { \ @@ -3382,7 +3382,7 @@ GDKanalytical_##NAME(BAT *r, BAT *p, BAT *levels_offset = NULL, tree_capacity = 0, nlevels = 0; \ lng n = 0; \ bit *np = pi.base, *op = oi.base; \ - dbl *restrict rb = (dbl *) Tloc(r, 0), mean = 0, m2 = 0, delta; \ + dbl *rb = (dbl *) Tloc(r, 0), mean = 0, m2 = 0, delta; \ void *segment_tree = NULL; \ gdk_return res = GDK_SUCCEED; \ \ @@ -3600,7 +3600,7 @@ GDKanalytical_##NAME(BAT *r, BAT *p, BAT *levels_offset = NULL, tree_capacity = 0, nlevels = 0; \ lng n = 0; \ bit *np = pi.base, *op = oi.base; \ - dbl *restrict rb = (dbl *) Tloc(r, 0), mean1 = 0, mean2 = 0, m2 = 0, delta1, delta2; \ + dbl *rb = (dbl *) Tloc(r, 0), mean1 = 0, mean2 = 0, m2 = 0, delta1, delta2; \ void *segment_tree = NULL; \ gdk_return res = GDK_SUCCEED; \ \ @@ -3852,7 +3852,7 @@ GDKanalytical_correlation(BAT *r, BAT *p const oid *restrict start = si.base, *restrict end = ei.base; lng n = 0; const bit *np = pi.base, *op = oi.base; - dbl *restrict rb = (dbl *) Tloc(r, 0), mean1 = 0, mean2 = 0, up = 0, down1 = 0, down2 = 0, delta1, delta2, aux, rr; + dbl *rb = (dbl *) Tloc(r, 0), mean1 = 0, mean2 = 0, up = 0, down1 = 0, down2 = 0, delta1, delta2, aux, rr; void *segment_tree = NULL; gdk_return res = GDK_SUCCEED; diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -632,11 +632,12 @@ BATclear(BAT *b, bool force) b->tvheap->dirty = true; } } - MT_lock_unset(&b->theaplock); if (force) b->batInserted = 0; - BATsetcount(b,0); + b->batCount = 0; + if (b->ttype == TYPE_void) + b->batCapacity = 0; BAThseqbase(b, 0); BATtseqbase(b, ATOMtype(b->ttype) == TYPE_oid ? 0 : oid_nil); b->batDirtydesc = true; @@ -644,6 +645,7 @@ BATclear(BAT *b, bool force) BATsettrivprop(b); b->tnosorted = b->tnorevsorted = 0; b->tnokey[0] = b->tnokey[1] = 0; + MT_lock_unset(&b->theaplock); return GDK_SUCCEED; } @@ -1162,22 +1164,42 @@ BUNappendmulti(BAT *b, const void *value } MT_rwlock_wrlock(&b->thashlock); if (values && b->ttype) { - for (BUN i = 0; i < count; i++) { - t = b->tvarsized ? ((void **) values)[i] : - (void *) ((char *) values + (i << b->tshift)); - gdk_return rc = bunfastapp_nocheck(b, t); - if (rc != GDK_SUCCEED) { - MT_rwlock_wrunlock(&b->thashlock); - return rc; + if (b->tvarsized) { + for (BUN i = 0; i < count; i++) { + t = ((void **) values)[i]; + gdk_return rc = tfastins_nocheckVAR(b, p, t); + if (rc != GDK_SUCCEED) { + MT_rwlock_wrunlock(&b->thashlock); + return rc; + } + if (b->thash) { + HASHappend_locked(b, p, t); + } + p++; } - if (b->thash) { - HASHappend_locked(b, p, t); + } else if (ATOMstorage(b->ttype) == TYPE_msk) { + for (BUN i = 0; i < count; i++) { + t = (void *) ((char *) values + (i << b->tshift)); + mskSetVal(b, p, *(msk *) t); + p++; } - p++; + } else { + for (BUN i = 0; i < count; i++) { + t = (void *) ((char *) values + (i << b->tshift)); + gdk_return rc = tfastins_nocheckFIX(b, p, t); + if (rc != GDK_SUCCEED) { + MT_rwlock_wrunlock(&b->thashlock); + return rc; + } + if (b->thash) { + HASHappend_locked(b, p, t); + } + p++; + } } } else { for (BUN i = 0; i < count; i++) { - gdk_return rc = bunfastapp_nocheck(b, t); + gdk_return rc = tfastins_nocheck(b, p, t); if (rc != GDK_SUCCEED) { MT_rwlock_wrunlock(&b->thashlock); return rc; @@ -1189,6 +1211,7 @@ BUNappendmulti(BAT *b, const void *value } } MT_rwlock_wrunlock(&b->thashlock); + BATsetcount(b, p); IMPSdestroy(b); /* no support for inserts in imprints yet */ OIDXdestroy(b); diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -226,7 +226,6 @@ insert_string_bat(BAT *b, BAT *n, struct /* we don't need to do any translation of offset * values, so we can use fast memcpy */ memcpy(Tloc(b, BUNlast(b)), (const char *) ni.base + ((ci->seq - n->hseqbase) << ni.shift), cnt << ni.shift); - BATsetcount(b, oldcnt + cnt); } else if (toff != ~(size_t) 0) { /* we don't need to insert any actual strings since we * have already made sure that they are all in b's @@ -311,7 +310,6 @@ insert_string_bat(BAT *b, BAT *n, struct break; } } - BATsetcount(b, r); /* set batCount and theap->free */ } else if (b->tvheap->free < ni.vh->free / 2 || GDK_ELIMDOUBLES(b->tvheap)) { /* if b's string heap is much smaller than n's string @@ -332,7 +330,6 @@ insert_string_bat(BAT *b, BAT *n, struct } r++; } - BATsetcount(b, r); } else { /* Insert values from n individually into b; however, * we check whether there is a string in b's string @@ -382,8 +379,8 @@ insert_string_bat(BAT *b, BAT *n, struct } r++; } - BATsetcount(b, r); } + BATsetcount(b, oldcnt + ci->ncand); bat_iterator_end(&ni); assert(b->batCapacity >= b->batCount); b->theap->dirty = true; @@ -460,11 +457,13 @@ append_varsized_bat(BAT *b, BAT *n, stru b->theap->dirty = true; BATsetcount(b, BATcount(b) + ci->ncand); /* maintain hash table */ + MT_rwlock_wrlock(&b->thashlock); for (BUN i = BATcount(b) - ci->ncand; b->thash && i < BATcount(b); i++) { - HASHappend(b, i, b->tvheap->base + *(var_t *) Tloc(b, i)); + HASHappend_locked(b, i, b->tvheap->base + *(var_t *) Tloc(b, i)); } + MT_rwlock_wrunlock(&b->thashlock); bat_iterator_end(&ni); return GDK_SUCCEED; } @@ -499,7 +498,7 @@ append_varsized_bat(BAT *b, BAT *n, stru cnt--; BUN p = canditer_next(ci) - hseq; const void *t = BUNtvar(ni, p); - if (bunfastapp_nocheckVAR(b, t) != GDK_SUCCEED) { + if (tfastins_nocheckVAR(b, r, t) != GDK_SUCCEED) { _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list