Changeset: fde1696af938 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/fde1696af938
Modified Files:
gdk/gdk_calc_addsub.c
gdk/gdk_string.c
gdk/gdk_subquery.c
gdk/gdk_utils.c
monetdb5/extras/rapi/rapi.c
monetdb5/mal/mal_parser.c
Branch: Dec2025
Log Message:
Various small changes.
No local variable used anymore for COND_LOCK_ALLOCATOR.
diffs (truncated from 387 to 300 lines):
diff --git a/gdk/gdk_calc_addsub.c b/gdk/gdk_calc_addsub.c
--- a/gdk/gdk_calc_addsub.c
+++ b/gdk/gdk_calc_addsub.c
@@ -1456,12 +1456,10 @@ addstr_loop(BAT *b1, const char *l, BAT
llen = strlen(l);
rlen = strlen(r);
if (llen + rlen >= slen) {
- /* ma_close(&ta_state); */
- /* ta_state = ma_open(ta); */
- slen = llen + rlen + 1024;
- s = ma_alloc(ta, slen);
+ s = ma_realloc(ta, s, llen + rlen + 1024, slen);
if (s == NULL)
goto bailout;
+ slen = llen + rlen + 1024;
}
(void) stpcpy(stpcpy(s, l), r);
if (tfastins_nocheckVAR(bn, i, s) != GDK_SUCCEED)
diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c
--- a/gdk/gdk_string.c
+++ b/gdk/gdk_string.c
@@ -6978,8 +6978,6 @@ BATcaseconvert(BAT *b, BAT *s, int direc
oid bhseqbase = b->hseqbase;
QryCtx *qry_ctx = MT_thread_get_qry_ctx();
qry_ctx = qry_ctx ? qry_ctx : &(QryCtx) {.endtime = 0};
- allocator *ta = MT_thread_getallocator();
- allocator_state ta_state = ma_open(ta);
TRC_DEBUG_IF(ALGO) t0 = GDKusec();
BATcheck(b, NULL);
@@ -6990,6 +6988,8 @@ BATcaseconvert(BAT *b, BAT *s, int direc
bi = bat_iterator(b);
char *buf = NULL;
size_t buflen = 0;
+ allocator *ta = MT_thread_getallocator();
+ allocator_state ta_state = ma_open(ta);
TIMEOUT_LOOP_IDX_DECL(i, ci.ncand, qry_ctx) {
BUN x = canditer_next(&ci) - bhseqbase;
if (convertcase(ta, &buf, &buflen, BUNtvar(bi, x),
@@ -9784,8 +9784,6 @@ BATasciify(BAT *b, BAT *s)
oid bhseqbase = b->hseqbase;
QryCtx *qry_ctx = MT_thread_get_qry_ctx();
qry_ctx = qry_ctx ? qry_ctx : &(QryCtx) {.endtime = 0};
- allocator *ta = MT_thread_getallocator();
- allocator_state ta_state = ma_open(ta);
TRC_DEBUG_IF(ALGO) t0 = GDKusec();
BATcheck(b, NULL);
@@ -9796,6 +9794,8 @@ BATasciify(BAT *b, BAT *s)
bi = bat_iterator(b);
char *buf = NULL;
size_t buflen = 0;
+ allocator *ta = MT_thread_getallocator();
+ allocator_state ta_state = ma_open(ta);
TIMEOUT_LOOP_IDX_DECL(i, ci.ncand, qry_ctx) {
BUN x = canditer_next(&ci) - bhseqbase;
if (GDKasciify(ta, &buf, &buflen, BUNtvar(bi, x)) !=
GDK_SUCCEED ||
diff --git a/gdk/gdk_subquery.c b/gdk/gdk_subquery.c
--- a/gdk/gdk_subquery.c
+++ b/gdk/gdk_subquery.c
@@ -71,120 +71,119 @@ BATall_grp(BAT *l, BAT *g, BAT *e, BAT *
return NULL;
}
- allocator *ta = MT_thread_getallocator();
- allocator_state ta_state = ma_open(ta);
if (BATcount(l) == 0 || ngrp == 0) {
const void *nilp = ATOMnilptr(l->ttype);
- if ((res = BATconstant(ngrp == 0 ? 0 : min, l->ttype, nilp,
ngrp, TRANSIENT)) == NULL)
- goto alloc_fail;
- } else {
- BATiter li;
+ return BATconstant(ngrp == 0 ? 0 : min, l->ttype, nilp, ngrp,
TRANSIENT);
+ }
+
+ if ((res = COLnew(min, l->ttype, ngrp, TRANSIENT)) == NULL)
+ return NULL;
- if ((res = COLnew(min, l->ttype, ngrp, TRANSIENT)) == NULL)
- goto alloc_fail;
- if ((oids = ma_alloc(ta, ngrp * sizeof(oid))) == NULL)
- goto alloc_fail;
+ allocator *ta = MT_thread_getallocator();
+ allocator_state ta_state = ma_open(ta);
- for (i = 0; i < ngrp; i++)
- oids[i] = BUN_NONE;
+ if ((oids = ma_alloc(ta, ngrp * sizeof(oid))) == NULL)
+ goto alloc_fail;
+
+ for (i = 0; i < ngrp; i++)
+ oids[i] = BUN_NONE;
- if (!g || BATtdense(g))
- gids = NULL;
- else
- gids = (const oid *) Tloc(g, 0);
+ if (!g || BATtdense(g))
+ gids = NULL;
+ else
+ gids = (const oid *) Tloc(g, 0);
- li = bat_iterator(l);
- switch (ATOMbasetype(l->ttype)) {
- case TYPE_bte:
- SQLall_grp_imp(bte);
- break;
- case TYPE_sht:
- SQLall_grp_imp(sht);
- break;
- case TYPE_int:
- SQLall_grp_imp(int);
- break;
- case TYPE_lng:
- SQLall_grp_imp(lng);
- break;
+ BATiter li = bat_iterator(l);
+ switch (ATOMbasetype(l->ttype)) {
+ case TYPE_bte:
+ SQLall_grp_imp(bte);
+ break;
+ case TYPE_sht:
+ SQLall_grp_imp(sht);
+ break;
+ case TYPE_int:
+ SQLall_grp_imp(int);
+ break;
+ case TYPE_lng:
+ SQLall_grp_imp(lng);
+ break;
#ifdef HAVE_HGE
- case TYPE_hge:
- SQLall_grp_imp(hge);
- break;
+ case TYPE_hge:
+ SQLall_grp_imp(hge);
+ break;
#endif
- case TYPE_flt:
- SQLall_grp_imp(flt);
- break;
- case TYPE_dbl:
- SQLall_grp_imp(dbl);
- break;
- default: {
- bool (*atomeq) (const void *, const void *) =
ATOMequal(l->ttype);
- const void *restrict nilp = ATOMnilptr(l->ttype);
+ case TYPE_flt:
+ SQLall_grp_imp(flt);
+ break;
+ case TYPE_dbl:
+ SQLall_grp_imp(dbl);
+ break;
+ default: {
+ bool (*atomeq) (const void *, const void *) =
ATOMequal(l->ttype);
+ const void *restrict nilp = ATOMnilptr(l->ttype);
- for (BUN n = 0; n < ci.ncand; n++) {
- i = canditer_next(&ci) - l->hseqbase;
- if (gids == NULL ||
- (gids[i] >= min && gids[i] <= max)) {
- if (gids)
- gid = gids[i] - min;
- else
- gid = (oid) i;
- if (oids[gid] != (BUN_NONE - 1)) {
- if (oids[gid] == BUN_NONE) {
- if (!atomeq(BUNtail(li,
i), nilp))
- oids[gid] = i;
- } else {
- const void *pi =
BUNtail(li, oids[gid]);
- const void *pp =
BUNtail(li, i);
- if (!atomeq(pi, pp) &&
!atomeq(pp, nilp))
- oids[gid] =
BUN_NONE - 1;
- }
+ for (BUN n = 0; n < ci.ncand; n++) {
+ i = canditer_next(&ci) - l->hseqbase;
+ if (gids == NULL ||
+ (gids[i] >= min && gids[i] <= max)) {
+ if (gids)
+ gid = gids[i] - min;
+ else
+ gid = (oid) i;
+ if (oids[gid] != (BUN_NONE - 1)) {
+ if (oids[gid] == BUN_NONE) {
+ if (!atomeq(BUNtail(li, i),
nilp))
+ oids[gid] = i;
+ } else {
+ const void *pi = BUNtail(li,
oids[gid]);
+ const void *pp = BUNtail(li, i);
+ if (!atomeq(pi, pp) &&
!atomeq(pp, nilp))
+ oids[gid] = BUN_NONE -
1;
}
}
}
+ }
- if (ATOMvarsized(l->ttype)) {
- for (i = 0; i < ngrp; i++) { /* convert the
found oids in values */
- BUN noid = oids[i];
- const void *next;
- if (noid > (BUN_NONE - 2)) {
- next = nilp;
- hasnil = 1;
- } else {
- next = BUNtvar(li, noid);
- }
- if (tfastins_nocheckVAR(res, i, next)
!= GDK_SUCCEED) {
- bat_iterator_end(&li);
- goto alloc_fail;
- }
+ if (ATOMvarsized(l->ttype)) {
+ for (i = 0; i < ngrp; i++) { /* convert the found oids
in values */
+ BUN noid = oids[i];
+ const void *next;
+ if (noid > (BUN_NONE - 2)) {
+ next = nilp;
+ hasnil = 1;
+ } else {
+ next = BUNtvar(li, noid);
}
- } else {
- uint8_t *restrict rcast = (uint8_t *) Tloc(res,
0);
- uint16_t width = res->twidth;
- for (i = 0; i < ngrp; i++) { /* convert the
found oids in values */
- BUN noid = oids[i];
- const void *next;
- if (noid > (BUN_NONE - 2)) {
- next = nilp;
- hasnil = 1;
- } else {
- next = BUNtloc(li, noid);
- }
- memcpy(rcast, next, width);
- rcast += width;
+ if (tfastins_nocheckVAR(res, i, next) !=
GDK_SUCCEED) {
+ bat_iterator_end(&li);
+ goto alloc_fail;
}
}
- }
+ } else {
+ uint8_t *restrict rcast = (uint8_t *) Tloc(res, 0);
+ uint16_t width = res->twidth;
+ for (i = 0; i < ngrp; i++) { /* convert the found oids
in values */
+ BUN noid = oids[i];
+ const void *next;
+ if (noid > (BUN_NONE - 2)) {
+ next = nilp;
+ hasnil = 1;
+ } else {
+ next = BUNtloc(li, noid);
+ }
+ memcpy(rcast, next, width);
+ rcast += width;
+ }
}
- bat_iterator_end(&li);
- BATsetcount(res, ngrp);
- res->tnil = hasnil != 0;
- res->tnonil = hasnil == 0;
- res->tkey = BATcount(res) <= 1;
- res->tsorted = BATcount(res) <= 1;
- res->trevsorted = BATcount(res) <= 1;
+ }
}
+ bat_iterator_end(&li);
+ BATsetcount(res, ngrp);
+ res->tnil = hasnil != 0;
+ res->tnonil = hasnil == 0;
+ res->tkey = BATcount(res) <= 1;
+ res->tsorted = BATcount(res) <= 1;
+ res->trevsorted = BATcount(res) <= 1;
ma_close(&ta_state);
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -2006,17 +2006,19 @@ GDKmremap(const char *path, int mode, vo
#define round16(sz) ((sz+15)&~15)
#define round_block_size(sz) ((sz + (MA_BLOCK_SIZE - 1))&~(MA_BLOCK_SIZE - 1))
-#define COND_LOCK_ALLOCATOR(a) \
- bool __alloc_locked = false; \
- if ((a)->use_lock) { \
- MT_lock_set(&(a)->lock); \
- __alloc_locked = true; \
- } else assert((a)->self == MT_getpid());
+#define COND_LOCK_ALLOCATOR(a) \
+ do { \
+ if ((a)->use_lock) { \
+ MT_lock_set(&(a)->lock); \
+ } else assert((a)->self == MT_getpid()); \
+ } while (0)
-#define COND_UNLOCK_ALLOCATOR(a) \
- if (__alloc_locked) { \
- MT_lock_unset(&(a)->lock); \
- }
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]