Changeset: b0d0fff69eb2 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/b0d0fff69eb2 Modified Files: gdk/gdk_analytic_func.c gdk/gdk_analytic_statistics.c gdk/gdk_logger.c gdk/gdk_string.c sql/backends/monet5/sql_rank.c Branch: default Log Message:
Merge with Dec2025 branch.
diffs (truncated from 392 to 300 lines):
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
@@ -984,7 +984,7 @@ GDKanalyticallead(BAT *b, BAT *p, BUN le
#define ANALYTICAL_MIN_MAX_CALC_FIXED_UNBOUNDED_TILL_CURRENT_ROW(TPE, MIN_MAX)
\
do { \
TPE curval = TPE##_nil; \
- for (; k < i;) { \
+ while (k < i) { \
j = k; \
do { \
if (!is_##TPE##_nil(bp[k])) { \
@@ -1091,7 +1091,7 @@ GDKanalyticallead(BAT *b, BAT *p, BUN le
do { \
const void *curval = nil; \
if (ATOMvarsized(tpe)) { \
- for (; k < i;) { \
+ while (k < i) { \
j = k; \
do { \
const void *next = BUNtvar(&bi, k); \
@@ -1109,7 +1109,7 @@ GDKanalyticallead(BAT *b, BAT *p, BUN le
has_nils |= atomeq(curval, nil); \
} \
} else { \
- for (; k < i;) { \
+ while (k < i) { \
j = k; \
do { \
const void *next = BUNtloc(&bi, k); \
@@ -1435,7 +1435,7 @@ ANALYTICAL_MIN_MAX(max, MAX, <)
do { \
curval = 0; \
if (count_all) { \
- for (; k < i;) { \
+ while (k < i) { \
j = k; \
do { \
k++; \
@@ -1445,7 +1445,7 @@ ANALYTICAL_MIN_MAX(max, MAX, <)
rb[j] = curval; \
} \
} else { \
- for (; k < i;) { \
+ while (k < i) { \
j = k; \
do { \
curval += !is_##TPE##_nil(bp[k]); \
@@ -1557,7 +1557,7 @@ ANALYTICAL_MIN_MAX(max, MAX, <)
do { \
curval = 0; \
if (count_all) { \
- for (; k < i;) { \
+ while (k < i) { \
j = k; \
do { \
k++; \
@@ -1567,7 +1567,7 @@ ANALYTICAL_MIN_MAX(max, MAX, <)
rb[j] = curval; \
} \
} else { \
- for (; k < i; ) { \
+ while (k < i) { \
j = k; \
do { \
curval += !atomeq(BUNtail(&bi, k),
nil); \
@@ -1814,7 +1814,7 @@ cleanup:
#define ANALYTICAL_SUM_IMP_NUM_UNBOUNDED_TILL_CURRENT_ROW(TPE1, TPE2) \
do { \
TPE2 curval = TPE2##_nil; \
- for (; k < i;) { \
+ while (k < i) { \
j = k; \
do { \
if (!is_##TPE1##_nil(bp[k])) { \
@@ -2187,7 +2187,7 @@ calc_overflow:
#define ANALYTICAL_PROD_CALC_NUM_UNBOUNDED_TILL_CURRENT_ROW(TPE1, TPE2, TPE3) \
do { \
TPE2 curval = TPE2##_nil; \
- for (; k < i;) { \
+ while (k < i) { \
j = k; \
do { \
PROD_NUM(TPE1, TPE2, TPE3, bp[k]); \
@@ -2294,7 +2294,7 @@ calc_overflow:
#define ANALYTICAL_PROD_CALC_NUM_LIMIT_UNBOUNDED_TILL_CURRENT_ROW(TPE1, TPE2,
REAL_IMP) \
do { \
TPE2 curval = TPE2##_nil; \
- for (; k < i;) { \
+ while (k < i) { \
j = k; \
do { \
PROD_NUM_LIMIT(TPE1, TPE2, REAL_IMP, bp[k]); \
@@ -2390,7 +2390,7 @@ calc_overflow:
#define ANALYTICAL_PROD_CALC_FP_UNBOUNDED_TILL_CURRENT_ROW(TPE1, TPE2, ARG3)
/* ARG3 is ignored here */ \
do { \
TPE2 curval = TPE2##_nil; \
- for (; k < i;) { \
+ while (k < i) { \
j = k; \
do { \
PROD_FP(TPE1, TPE2, bp[k]); \
diff --git a/gdk/gdk_analytic_statistics.c b/gdk/gdk_analytic_statistics.c
--- a/gdk/gdk_analytic_statistics.c
+++ b/gdk/gdk_analytic_statistics.c
@@ -59,7 +59,7 @@
do { \
TPE a = 0; \
dbl curval = dbl_nil; \
- for (; k < i;) { \
+ while (k < i) { \
j = k; \
do { \
ANALYTICAL_AVERAGE_CALC_NUM_STEP1(TPE, IMP,
bp[k]); \
@@ -204,7 +204,7 @@ avg_num_deltas(lng)
do { \
TPE a = 0; \
dbl curval = dbl_nil; \
- for (; k < i;) { \
+ while (k < i) { \
j = k; \
do { \
if (!is_##TPE##_nil(bp[k])) \
@@ -458,7 +458,7 @@ nosupport:
#define ANALYTICAL_AVG_INT_UNBOUNDED_TILL_CURRENT_ROW(TPE) \
do { \
TPE avg = 0; \
- for (; k < i;) { \
+ while (k < i) { \
j = k; \
do { \
if (!is_##TPE##_nil(bp[k])) \
@@ -707,7 +707,7 @@ nosupport:
#define ANALYTICAL_STDEV_VARIANCE_UNBOUNDED_TILL_CURRENT_ROW(TPE, SAMPLE, OP) \
do { \
TPE *restrict bp = (TPE*)bi.base; \
- for (; k < i;) { \
+ while (k < i) { \
j = k; \
do { \
TPE v = bp[k]; \
@@ -994,7 +994,7 @@ GDK_ANALYTICAL_STDEV_VARIANCE(variance_p
#define ANALYTICAL_COVARIANCE_UNBOUNDED_TILL_CURRENT_ROW(TPE, SAMPLE, OP) \
do { \
TPE *bp1 = (TPE*)b1i.base, *bp2 = (TPE*)b2i.base; \
- for (; k < i;) { \
+ while (k < i) { \
j = k; \
do { \
TPE v1 = bp1[k], v2 = bp2[k]; \
@@ -1226,7 +1226,7 @@ GDK_ANALYTICAL_COVARIANCE(covariance_pop
#define ANALYTICAL_CORRELATION_UNBOUNDED_TILL_CURRENT_ROW(TPE, SAMPLE, OP)
/* SAMPLE and OP not used */ \
do { \
TPE *bp1 = (TPE*)b1i.base, *bp2 = (TPE*)b2i.base; \
- for (; k < i;) { \
+ while (k < i) { \
j = k; \
do { \
TPE v1 = bp1[k], v2 = bp2[k]; \
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -3181,7 +3181,7 @@ string_writer(logger *lg, BAT *b, lng of
return GDK_FAIL;
BATiter bi = bat_iterator(b);
BUN p = (BUN) offset;
- for (; p < end;) {
+ while (p < end) {
size_t sz = 0;
if (resize) {
if ((buf = GDKrealloc(lg->wbuf, resize)) == NULL) {
diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c
--- a/gdk/gdk_string.c
+++ b/gdk/gdk_string.c
@@ -1331,13 +1331,11 @@ GDKanalytical_str_group_concat(BAT *r, B
{
bool has_nils = false;
BATiter pi = bat_iterator(p);
- BATiter oi = bat_iterator(o);
BATiter bi = bat_iterator(b);
BATiter sepi = bat_iterator(sep);
BATiter si = bat_iterator(s);
- BATiter ei = bat_iterator(e);
- oid i = 0, j = 0, k = 0, cnt = bi.count, *restrict start = si.base,
*restrict end = ei.base;
- bit *np = pi.base, *op = oi.base;
+ oid i = 0, k = 0;
+ bit *np = pi.base;
char *single_str = NULL;
size_t separator_length = 0, max_group_length = 0;
allocator *ta = MT_thread_getallocator();
@@ -1346,14 +1344,7 @@ GDKanalytical_str_group_concat(BAT *r, B
assert((sep && !separator && bi.count == sepi.count) || (!sep &&
separator));
if (b->ttype != TYPE_str || r->ttype != TYPE_str || (sep && sep->ttype
!= TYPE_str)) {
GDKerror("only string type is supported\n");
- bat_iterator_end(&pi);
- bat_iterator_end(&oi);
- bat_iterator_end(&bi);
- bat_iterator_end(&sepi);
- bat_iterator_end(&si);
- bat_iterator_end(&ei);
- ma_close(&ta_state);
- return GDK_FAIL;
+ goto bailout;
}
if (sep && sepi.count == 1) { /* Only one element in sep */
separator = BUNtvar(&sepi, 0);
@@ -1363,22 +1354,27 @@ GDKanalytical_str_group_concat(BAT *r, B
if (sep == NULL)
separator_length = strlen(separator);
- if (cnt > 0) {
+ if (bi.count > 0) {
switch (frame_type) {
- case FRAME_UNBOUNDED_TILL_CURRENT_ROW:
- for (i = p ? 0 : cnt; i <= cnt; i++) {
- if (i == cnt || np[i]) {
+ case FRAME_UNBOUNDED_TILL_CURRENT_ROW: {
+ BATiter oi = bat_iterator(o);
+ bit *op = oi.base;
+ for (i = p ? 0 : bi.count; i <= bi.count; i++) {
+ if (i == bi.count || np[i]) {
size_t slice_length = 0;
+ /* compute the entire string then slice
it starting from the beginning */
if
(compute_next_single_str(&max_group_length, &single_str,
&has_nils,
ta, separator_length,
separator,
&sepi, &bi,
- k, i) !=
GDK_SUCCEED) /* compute the entire string then slice it starting from the
beginning */
- goto allocation_error;
+ k, i) !=
GDK_SUCCEED) {
+ bat_iterator_end(&oi);
+ goto bailout;
+ }
bool empty = true;
- for (; k < i;) {
+ while (k < i) {
const char *nsep;
oid m = k;
- j = k;
+ oid j = k;
do {
k++;
} while (k < i && !op[k]);
@@ -1401,44 +1397,51 @@ GDKanalytical_str_group_concat(BAT *r, B
}
if (empty) {
for (j = m; j < k; j++)
- if
(tfastins_nocheckVAR(r, j, str_nil) != GDK_SUCCEED)
- goto
allocation_error;
+ if
(tfastins_nocheckVAR(r, j, str_nil) != GDK_SUCCEED) {
+
bat_iterator_end(&oi);
+ goto
bailout;
+ }
has_nils = true;
} else {
char save =
single_str[slice_length];
single_str[slice_length] = '\0';
for (j = m; j < k; j++)
- if
(tfastins_nocheckVAR(r, j, single_str) != GDK_SUCCEED)
- goto
allocation_error;
+ if
(tfastins_nocheckVAR(r, j, single_str) != GDK_SUCCEED) {
+
bat_iterator_end(&oi);
+ goto
bailout;
+ }
single_str[slice_length] = save;
}
}
}
}
+ bat_iterator_end(&oi);
break;
+ }
case FRAME_CURRENT_ROW_TILL_UNBOUNDED:
- goto notimplemented;
+ GDKerror("str_group_concat not yet implemented for
current row until unbounded case\n");
+ goto bailout;
case FRAME_ALL:
- for (i = p ? 0 : cnt; i <= cnt; i++) {
- if (i == cnt || np[i]) {
+ for (i = p ? 0 : bi.count; i <= bi.count; i++) {
+ if (i == bi.count || np[i]) {
if
(compute_next_single_str(&max_group_length, &single_str,
&has_nils,
ta, separator_length,
separator,
&sepi, &bi,
k, i) !=
GDK_SUCCEED)
- goto allocation_error;
+ goto bailout;
for (; k < i; k++)
if (tfastins_nocheckVAR(r, k,
single_str) != GDK_SUCCEED)
- goto allocation_error;
+ goto bailout;
}
}
break;
case FRAME_CURRENT_ROW:
- for (i = p ? 0 : cnt; i <= cnt; i++) {
- if (i == cnt || np[i]) {
+ for (i = p ? 0 : bi.count; i <= bi.count; i++) {
+ if (i == bi.count || np[i]) {
for (; k < i; k++) {
const char *next = BUNtvar(&bi,
k);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]
