Changeset: e901114fc14e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e901114fc14e
Modified Files:
clients/Tests/exports.stable.out
gdk/gdk_calc.h
gdk/gdk_string.c
sql/backends/monet5/sql_rank.c
Branch: default
Log Message:
Move BAT creation into GDK layer.
diffs (172 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
@@ -256,7 +256,7 @@ BAT *GDKanalytical_covariance_pop(BAT *p
BAT *GDKanalytical_covariance_samp(BAT *p, BAT *o, BAT *b1, BAT *b2, BAT *s,
BAT *e, int tpe, int frame_type) __attribute__((__warn_unused_result__));
BAT *GDKanalytical_stddev_pop(BAT *p, BAT *o, BAT *b, BAT *s, BAT *e, int tpe,
int frame_type) __attribute__((__warn_unused_result__));
BAT *GDKanalytical_stddev_samp(BAT *p, BAT *o, BAT *b, BAT *s, BAT *e, int
tpe, int frame_type) __attribute__((__warn_unused_result__));
-gdk_return GDKanalytical_str_group_concat(BAT *r, BAT *p, BAT *o, BAT *b, BAT
*sep, BAT *s, BAT *e, const char *restrict separator, int frame_type);
+BAT *GDKanalytical_str_group_concat(BAT *b, BAT *p, BAT *o, BAT *sep, BAT *s,
BAT *e, const char *restrict separator, int frame_type);
BAT *GDKanalytical_variance_pop(BAT *p, BAT *o, BAT *b, BAT *s, BAT *e, int
tpe, int frame_type) __attribute__((__warn_unused_result__));
BAT *GDKanalytical_variance_samp(BAT *p, BAT *o, BAT *b, BAT *s, BAT *e, int
tpe, int frame_type) __attribute__((__warn_unused_result__));
BAT *GDKanalyticalavg(BAT *p, BAT *o, BAT *b, BAT *s, BAT *e, int tpe, int
frame_type) __attribute__((__warn_unused_result__));
diff --git a/gdk/gdk_calc.h b/gdk/gdk_calc.h
--- a/gdk/gdk_calc.h
+++ b/gdk/gdk_calc.h
@@ -166,4 +166,4 @@ gdk_export BAT *BATgroupcorrelation(BAT
gdk_export BAT *BATgroupstr_group_concat(BAT *b, BAT *g, BAT *e, BAT *s, BAT
*sep, bool skip_nils, const char *restrict separator);
gdk_export gdk_return BATstr_group_concat(allocator *ma, ValPtr res, BAT *b,
BAT *s, BAT *sep, bool skip_nils, bool nil_if_empty, const char *restrict
separator);
-gdk_export gdk_return GDKanalytical_str_group_concat(BAT *r, BAT *p, BAT *o,
BAT *b, BAT *sep, BAT *s, BAT *e, const char *restrict separator, int
frame_type);
+gdk_export BAT *GDKanalytical_str_group_concat(BAT *b, BAT *p, BAT *o, BAT
*sep, BAT *s, BAT *e, const char *restrict separator, int frame_type);
diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c
--- a/gdk/gdk_string.c
+++ b/gdk/gdk_string.c
@@ -1326,8 +1326,8 @@ compute_next_single_str(size_t *mglp, ch
#define FRAME_ALL 5
#define FRAME_CURRENT_ROW 6
-gdk_return
-GDKanalytical_str_group_concat(BAT *r, BAT *p, BAT *o, BAT *b, BAT *sep, BAT
*s, BAT *e, const char *restrict separator, int frame_type)
+BAT *
+GDKanalytical_str_group_concat(BAT *b, BAT *p, BAT *o, BAT *sep, BAT *s, BAT
*e, const char *restrict separator, int frame_type)
{
bool has_nils = false;
BATiter pi = bat_iterator(p);
@@ -1340,9 +1340,10 @@ GDKanalytical_str_group_concat(BAT *r, B
size_t separator_length = 0, max_group_length = 0;
allocator *ta = MT_thread_getallocator();
allocator_state ta_state = ma_open(ta);
+ BAT *bn = NULL;
assert((sep && !separator && bi.count == sepi.count) || (!sep &&
separator));
- if (b->ttype != TYPE_str || r->ttype != TYPE_str || (sep && sep->ttype
!= TYPE_str)) {
+ if (b->ttype != TYPE_str || (sep && sep->ttype != TYPE_str)) {
GDKerror("only string type is supported\n");
goto bailout;
}
@@ -1354,6 +1355,9 @@ GDKanalytical_str_group_concat(BAT *r, B
if (sep == NULL)
separator_length = strlen(separator);
+ if ((bn = COLnew(b->hseqbase, TYPE_str, bi.count, TRANSIENT)) == NULL)
+ goto bailout;
+
if (bi.count > 0) {
switch (frame_type) {
case FRAME_UNBOUNDED_TILL_CURRENT_ROW: {
@@ -1397,7 +1401,7 @@ GDKanalytical_str_group_concat(BAT *r, B
}
if (empty) {
for (j = m; j < k; j++)
- if
(tfastins_nocheckVAR(r, j, str_nil) != GDK_SUCCEED) {
+ if
(tfastins_nocheckVAR(bn, j, str_nil) != GDK_SUCCEED) {
bat_iterator_end(&oi);
goto
bailout;
}
@@ -1406,7 +1410,7 @@ GDKanalytical_str_group_concat(BAT *r, B
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) {
+ if
(tfastins_nocheckVAR(bn, j, single_str) != GDK_SUCCEED) {
bat_iterator_end(&oi);
goto
bailout;
}
@@ -1430,7 +1434,7 @@ GDKanalytical_str_group_concat(BAT *r, B
k, i) !=
GDK_SUCCEED)
goto bailout;
for (; k < i; k++)
- if (tfastins_nocheckVAR(r, k,
single_str) != GDK_SUCCEED)
+ if (tfastins_nocheckVAR(bn, k,
single_str) != GDK_SUCCEED)
goto bailout;
}
}
@@ -1440,7 +1444,7 @@ GDKanalytical_str_group_concat(BAT *r, B
if (i == bi.count || np[i]) {
for (; k < i; k++) {
const char *next = BUNtvar(&bi,
k);
- if (tfastins_nocheckVAR(r, k,
next) != GDK_SUCCEED)
+ if (tfastins_nocheckVAR(bn, k,
next) != GDK_SUCCEED)
goto bailout;
has_nils |= strNil(next);
}
@@ -1463,7 +1467,7 @@ GDKanalytical_str_group_concat(BAT *r, B
bat_iterator_end(&ei);
goto bailout;
}
- if (tfastins_nocheckVAR(r, k,
single_str) != GDK_SUCCEED) {
+ if (tfastins_nocheckVAR(bn, k,
single_str) != GDK_SUCCEED) {
bat_iterator_end(&ei);
goto bailout;
}
@@ -1478,23 +1482,24 @@ GDKanalytical_str_group_concat(BAT *r, B
}
}
- BATsetcount(r, bi.count);
+ BATsetcount(bn, bi.count);
bat_iterator_end(&pi);
bat_iterator_end(&bi);
bat_iterator_end(&sepi);
bat_iterator_end(&si);
- r->tnonil = !has_nils;
- r->tnil = has_nils;
+ bn->tnonil = !has_nils;
+ bn->tnil = has_nils;
ma_close(&ta_state);
- return GDK_SUCCEED;
+ return bn;
bailout:
+ BBPreclaim(bn);
bat_iterator_end(&pi);
bat_iterator_end(&bi);
bat_iterator_end(&sepi);
bat_iterator_end(&si);
ma_close(&ta_state);
- return GDK_FAIL;
+ return NULL;
}
/* The three case conversion tables are specially crafted from the
diff --git a/sql/backends/monet5/sql_rank.c b/sql/backends/monet5/sql_rank.c
--- a/sql/backends/monet5/sql_rank.c
+++ b/sql/backends/monet5/sql_rank.c
@@ -2017,7 +2017,7 @@ SQLcorr(Client cntxt, MalBlkPtr mb, MalS
str
SQLstrgroup_concat(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
- BAT *r = NULL, *b = NULL, *sep = NULL, *p = NULL, *o = NULL, *s = NULL,
*e = NULL;
+ BAT *bn = NULL, *b = NULL, *sep = NULL, *p = NULL, *o = NULL, *s =
NULL, *e = NULL;
int separator_offset = 0, tpe, frame_type;
str msg = MAL_SUCCEED, separator = NULL;
bat *res = NULL;
@@ -2045,10 +2045,6 @@ SQLstrgroup_concat(Client cntxt, MalBlkP
msg = createException(SQL, "sql.strgroup_concat",
SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
goto bailout;
}
- if (!(r = COLnew(b->hseqbase, TYPE_str, BATcount(b),
TRANSIENT))) {
- msg = createException(SQL, "sql.strgroup_concat",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
- goto bailout;
- }
if (separator_offset) {
if (isaBatType(getArgType(mb, pci, 2))) {
if (!(sep =
BATdescriptor(*getArgReference_bat(stk, pci, 2)))) {
@@ -2086,7 +2082,7 @@ SQLstrgroup_concat(Client cntxt, MalBlkP
}
assert((separator && !sep) || (!separator && sep)); /* only one
of them must be set */
- if (GDKanalytical_str_group_concat(r, p, o, b, sep, s, e,
separator, frame_type) != GDK_SUCCEED)
+ if ((bn = GDKanalytical_str_group_concat(b, p, o, sep, s, e,
separator, frame_type)) == NULL)
msg = createException(SQL, "sql.strgroup_concat",
GDK_EXCEPTION);
} else {
str *res = getArgReference_str(stk, pci, 0);
@@ -2114,6 +2110,6 @@ SQLstrgroup_concat(Client cntxt, MalBlkP
bailout:
unfix_inputs(6, b, sep, p, o, s, e);
- finalize_output(res, r, msg);
+ finalize_output(res, bn, msg);
return msg;
}
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]