| 1 | /* | 
| 2 |  * This Source Code Form is subject to the terms of the Mozilla Public | 
| 3 |  * License, v. 2.0.  If a copy of the MPL was not distributed with this | 
| 4 |  * file, You can obtain one at http://mozilla.org/MPL/2.0/. | 
| 5 |  * | 
| 6 |  * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V. | 
| 7 |  */ | 
| 8 |  | 
| 9 | #include "monetdb_config.h" | 
| 10 | #include "mal.h" | 
| 11 | #include "mal_exception.h" | 
| 12 |  | 
| 13 | /* | 
| 14 |  * grouped aggregates | 
| 15 |  */ | 
| 16 | static str | 
| 17 | AGGRgrouped(bat *retval1, bat *retval2, const bat *bid, const bat *gid, const bat *eid, const bat *sid, | 
| 18 | 			bool skip_nils, bool abort_on_error, int scale, int tp, | 
| 19 | 			BAT *(*grpfunc1)(BAT *, BAT *, BAT *, BAT *, int, bool, bool), | 
| 20 | 			gdk_return (*grpfunc2)(BAT **, BAT **, BAT *, BAT *, BAT *, BAT *, int, bool, bool, int), | 
| 21 | 			BAT *(*quantilefunc)(BAT *, BAT *, BAT *, BAT *, int, double, bool, bool), | 
| 22 | 			const bat *quantile, | 
| 23 | 			const char *malfunc) | 
| 24 | { | 
| 25 | 	BAT *b, *g, *e, *s, *bn = NULL, *cnts, *q = NULL; | 
| 26 | 	double qvalue; | 
| 27 |  | 
| 28 | 	/* exactly one of grpfunc1, grpfunc2 and quantilefunc is non-NULL */ | 
| 29 | 	assert((grpfunc1 != NULL) + (grpfunc2 != NULL) + (quantilefunc != NULL) == 1); | 
| 30 |  | 
| 31 | 	/* if retval2 is non-NULL, we must have grpfunc2 */ | 
| 32 | 	assert(retval2 == NULL || grpfunc2 != NULL); | 
| 33 | 	/* only quantiles need a quantile BAT */ | 
| 34 | 	assert((quantilefunc == NULL) == (quantile == NULL)); | 
| 35 |  | 
| 36 | 	b = BATdescriptor(*bid); | 
| 37 | 	g = gid ? BATdescriptor(*gid) : NULL; | 
| 38 | 	e = eid ? BATdescriptor(*eid) : NULL; | 
| 39 | 	s = sid ? BATdescriptor(*sid) : NULL; | 
| 40 | 	q = quantile ? BATdescriptor(*quantile) : NULL; | 
| 41 |  | 
| 42 | 	if (b == NULL || | 
| 43 | 		(gid != NULL && g == NULL) || | 
| 44 | 		(eid != NULL && e == NULL) || | 
| 45 | 		(sid != NULL && s == NULL) || | 
| 46 | 		(quantile != NULL && q == NULL)) { | 
| 47 | 		if (b) | 
| 48 | 			BBPunfix(b->batCacheid); | 
| 49 | 		if (g) | 
| 50 | 			BBPunfix(g->batCacheid); | 
| 51 | 		if (e) | 
| 52 | 			BBPunfix(e->batCacheid); | 
| 53 | 		if (s) | 
| 54 | 			BBPunfix(s->batCacheid); | 
| 55 | 		if (q) | 
| 56 | 			BBPunfix(q->batCacheid); | 
| 57 | 		throw(MAL, malfunc, SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); | 
| 58 | 	} | 
| 59 | 	if (tp == TYPE_any && | 
| 60 | 		(grpfunc1 == BATgroupmedian || | 
| 61 | 		 grpfunc1 == BATgroupmedian_avg || | 
| 62 | 		 quantilefunc == BATgroupquantile || | 
| 63 | 		 quantilefunc == BATgroupquantile_avg)) | 
| 64 | 		tp = b->ttype; | 
| 65 |  | 
| 66 | 	if (grpfunc1) { | 
| 67 | 		bn = (*grpfunc1)(b, g, e, s, tp, skip_nils, abort_on_error); | 
| 68 | 	} else if (quantilefunc) { | 
| 69 | 		assert(BATcount(q) > 0 || BATcount(b) == 0); | 
| 70 | 		assert(q->ttype == TYPE_dbl); | 
| 71 | 		if (BATcount(q) == 0) { | 
| 72 | 			qvalue = 0.5; | 
| 73 | 		} else { | 
| 74 | 			qvalue = ((const dbl *)Tloc(q, 0))[0]; | 
| 75 | 			if (qvalue < 0 || qvalue > 1) { | 
| 76 | 				BBPunfix(b->batCacheid); | 
| 77 | 				if (g) | 
| 78 | 					BBPunfix(g->batCacheid); | 
| 79 | 				if (e) | 
| 80 | 					BBPunfix(e->batCacheid); | 
| 81 | 				if (s) | 
| 82 | 					BBPunfix(s->batCacheid); | 
| 83 | 				BBPunfix(q->batCacheid); | 
| 84 | 				throw(MAL, malfunc, | 
| 85 | 					  "quantile value of %f is not in range [0,1]" , qvalue); | 
| 86 | 			} | 
| 87 | 		} | 
| 88 | 		BBPunfix(q->batCacheid); | 
| 89 | 		bn = (*quantilefunc)(b, g, e, s, tp, qvalue, skip_nils, abort_on_error); | 
| 90 | 	} else if ((*grpfunc2)(&bn, retval2 ? &cnts : NULL, b, g, e, s, tp, | 
| 91 | 						   skip_nils, abort_on_error, scale) != GDK_SUCCEED) { | 
| 92 | 		bn = NULL; | 
| 93 | 	} | 
| 94 |  | 
| 95 | 	BBPunfix(b->batCacheid); | 
| 96 | 	if (g) | 
| 97 | 		BBPunfix(g->batCacheid); | 
| 98 | 	if (e) | 
| 99 | 		BBPunfix(e->batCacheid); | 
| 100 | 	if (s) | 
| 101 | 		BBPunfix(s->batCacheid); | 
| 102 | 	if (bn == NULL) | 
| 103 | 		throw(MAL, malfunc, GDK_EXCEPTION); | 
| 104 | 	*retval1 = bn->batCacheid; | 
| 105 | 	BBPkeepref(bn->batCacheid); | 
| 106 | 	if (retval2) { | 
| 107 | 		*retval2 = cnts->batCacheid; | 
| 108 | 		BBPkeepref(cnts->batCacheid); | 
| 109 | 	} | 
| 110 | 	return MAL_SUCCEED; | 
| 111 | } | 
| 112 |  | 
| 113 | mal_export str AGGRsum3_bte(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 114 | str | 
| 115 | AGGRsum3_bte(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 116 | { | 
| 117 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 1, 1, 0, TYPE_bte, | 
| 118 | 					   BATgroupsum, NULL, NULL, NULL, "aggr.sum" ); | 
| 119 | } | 
| 120 |  | 
| 121 | mal_export str AGGRsum3_sht(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 122 | str | 
| 123 | AGGRsum3_sht(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 124 | { | 
| 125 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 1, 1, 0, TYPE_sht, | 
| 126 | 					   BATgroupsum, NULL, NULL, NULL, "aggr.sum" ); | 
| 127 | } | 
| 128 |  | 
| 129 | mal_export str AGGRsum3_int(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 130 | str | 
| 131 | AGGRsum3_int(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 132 | { | 
| 133 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 1, 1, 0, TYPE_int, | 
| 134 | 					   BATgroupsum, NULL, NULL, NULL, "aggr.sum" ); | 
| 135 | } | 
| 136 |  | 
| 137 | mal_export str AGGRsum3_lng(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 138 | str | 
| 139 | AGGRsum3_lng(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 140 | { | 
| 141 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 1, 1, 0, TYPE_lng, | 
| 142 | 					   BATgroupsum, NULL, NULL, NULL, "aggr.sum" ); | 
| 143 | } | 
| 144 |  | 
| 145 | #ifdef HAVE_HGE | 
| 146 | mal_export str AGGRsum3_hge(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 147 | str | 
| 148 | AGGRsum3_hge(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 149 | { | 
| 150 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 1, 1, 0, TYPE_hge, | 
| 151 | 					   BATgroupsum, NULL, NULL, NULL, "aggr.sum" ); | 
| 152 | } | 
| 153 | #endif | 
| 154 |  | 
| 155 | mal_export str AGGRsum3_flt(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 156 | str | 
| 157 | AGGRsum3_flt(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 158 | { | 
| 159 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 1, 1, 0, TYPE_flt, | 
| 160 | 					   BATgroupsum, NULL, NULL, NULL, "aggr.sum" ); | 
| 161 | } | 
| 162 |  | 
| 163 | mal_export str AGGRsum3_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 164 | str | 
| 165 | AGGRsum3_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 166 | { | 
| 167 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 1, 1, 0, TYPE_dbl, | 
| 168 | 					   BATgroupsum, NULL, NULL, NULL, "aggr.sum" ); | 
| 169 | } | 
| 170 |  | 
| 171 | mal_export str AGGRprod3_bte(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 172 | str | 
| 173 | AGGRprod3_bte(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 174 | { | 
| 175 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 1, 1, 0, TYPE_bte, | 
| 176 | 					   BATgroupprod, NULL, NULL, NULL, "aggr.prod" ); | 
| 177 | } | 
| 178 |  | 
| 179 | mal_export str AGGRprod3_sht(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 180 | str | 
| 181 | AGGRprod3_sht(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 182 | { | 
| 183 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 1, 1, 0, TYPE_sht, | 
| 184 | 					   BATgroupprod, NULL, NULL, NULL, "aggr.prod" ); | 
| 185 | } | 
| 186 |  | 
| 187 | mal_export str AGGRprod3_int(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 188 | str | 
| 189 | AGGRprod3_int(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 190 | { | 
| 191 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 1, 1, 0, TYPE_int, | 
| 192 | 					   BATgroupprod, NULL, NULL, NULL, "aggr.prod" ); | 
| 193 | } | 
| 194 |  | 
| 195 | mal_export str AGGRprod3_lng(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 196 | str | 
| 197 | AGGRprod3_lng(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 198 | { | 
| 199 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 1, 1, 0, TYPE_lng, | 
| 200 | 					   BATgroupprod, NULL, NULL, NULL, "aggr.prod" ); | 
| 201 | } | 
| 202 |  | 
| 203 | #ifdef HAVE_HGE | 
| 204 | mal_export str AGGRprod3_hge(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 205 | str | 
| 206 | AGGRprod3_hge(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 207 | { | 
| 208 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 1, 1, 0, TYPE_hge, | 
| 209 | 					   BATgroupprod, NULL, NULL, NULL, "aggr.prod" ); | 
| 210 | } | 
| 211 | #endif | 
| 212 |  | 
| 213 | mal_export str AGGRprod3_flt(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 214 | str | 
| 215 | AGGRprod3_flt(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 216 | { | 
| 217 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 1, 1, 0, TYPE_flt, | 
| 218 | 					   BATgroupprod, NULL, NULL, NULL, "aggr.prod" ); | 
| 219 | } | 
| 220 |  | 
| 221 | mal_export str AGGRprod3_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 222 | str | 
| 223 | AGGRprod3_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 224 | { | 
| 225 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 1, 1, 0, TYPE_dbl, | 
| 226 | 					   BATgroupprod, NULL, NULL, NULL, "aggr.prod" ); | 
| 227 | } | 
| 228 |  | 
| 229 | mal_export str AGGRavg13_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 230 | str | 
| 231 | AGGRavg13_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 232 | { | 
| 233 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 1, 1, 0, TYPE_dbl, | 
| 234 | 					   NULL, BATgroupavg, NULL, NULL, "aggr.avg" ); | 
| 235 | } | 
| 236 |  | 
| 237 | mal_export str AGGRavg23_dbl(bat *retval1, bat *retval2, const bat *bid, const bat *gid, const bat *eid); | 
| 238 | str | 
| 239 | AGGRavg23_dbl(bat *retval1, bat *retval2, const bat *bid, const bat *gid, const bat *eid) | 
| 240 | { | 
| 241 | 	return AGGRgrouped(retval1, retval2, bid, gid, eid, NULL, 1, 1, 0, TYPE_dbl, | 
| 242 | 					   NULL, BATgroupavg, NULL, NULL, "aggr.avg" ); | 
| 243 | } | 
| 244 |  | 
| 245 | mal_export str AGGRavg14_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, int *scale); | 
| 246 | str | 
| 247 | AGGRavg14_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, int *scale) | 
| 248 | { | 
| 249 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 1, 1, *scale, TYPE_dbl, | 
| 250 | 					   NULL, BATgroupavg, NULL, NULL, "aggr.avg" ); | 
| 251 | } | 
| 252 |  | 
| 253 | mal_export str AGGRavg24_dbl(bat *retval1, bat *retval2, const bat *bid, const bat *gid, const bat *eid, int *scale); | 
| 254 | str | 
| 255 | AGGRavg24_dbl(bat *retval1, bat *retval2, const bat *bid, const bat *gid, const bat *eid, int *scale) | 
| 256 | { | 
| 257 | 	return AGGRgrouped(retval1, retval2, bid, gid, eid, NULL, 1, 1, *scale, TYPE_dbl, | 
| 258 | 					   NULL, BATgroupavg, NULL, NULL, "aggr.avg" ); | 
| 259 | } | 
| 260 |  | 
| 261 | mal_export str AGGRstdev3_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 262 | str | 
| 263 | AGGRstdev3_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 264 | { | 
| 265 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 1, 1, 0, TYPE_dbl, | 
| 266 | 					   BATgroupstdev_sample, NULL, NULL, NULL, "aggr.stdev" ); | 
| 267 | } | 
| 268 |  | 
| 269 | mal_export str AGGRstdevp3_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 270 | str | 
| 271 | AGGRstdevp3_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 272 | { | 
| 273 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 1, 1, 0, TYPE_dbl, | 
| 274 | 					   BATgroupstdev_population, NULL, NULL, NULL, "aggr.stdevp" ); | 
| 275 | } | 
| 276 |  | 
| 277 | mal_export str AGGRvariance3_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 278 | str | 
| 279 | AGGRvariance3_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 280 | { | 
| 281 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 1, 1, 0, TYPE_dbl, | 
| 282 | 					   BATgroupvariance_sample, NULL, NULL, NULL, "aggr.variance" ); | 
| 283 | } | 
| 284 |  | 
| 285 | mal_export str AGGRvariancep3_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 286 | str | 
| 287 | AGGRvariancep3_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 288 | { | 
| 289 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 1, 1, 0, TYPE_dbl, | 
| 290 | 					   BATgroupvariance_population, NULL, NULL, NULL, "aggr.variancep" ); | 
| 291 | } | 
| 292 |  | 
| 293 | mal_export str AGGRcount3(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *ignorenils); | 
| 294 | str | 
| 295 | AGGRcount3(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *ignorenils) | 
| 296 | { | 
| 297 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *ignorenils, 1, 0, TYPE_lng, | 
| 298 | 					   BATgroupcount, NULL, NULL, NULL, "aggr.count" ); | 
| 299 | } | 
| 300 |  | 
| 301 | mal_export str AGGRcount3nonils(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 302 | str | 
| 303 | AGGRcount3nonils(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 304 | { | 
| 305 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 1, 1, 0, TYPE_lng, | 
| 306 | 					   BATgroupcount, NULL, NULL, NULL, "aggr.count" ); | 
| 307 | } | 
| 308 |  | 
| 309 | mal_export str AGGRcount3nils(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 310 | str | 
| 311 | AGGRcount3nils(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 312 | { | 
| 313 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, 0, 1, 0, TYPE_lng, | 
| 314 | 					   BATgroupcount, NULL, NULL, NULL, "aggr.count" ); | 
| 315 | } | 
| 316 |  | 
| 317 | #include "algebra.h"			/* for ALGprojection */ | 
| 318 | mal_export str AGGRmin3(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 319 | str | 
| 320 | AGGRmin3(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 321 | { | 
| 322 | 	bat tmpid; | 
| 323 | 	str err; | 
| 324 |  | 
| 325 | 	err = AGGRgrouped(&tmpid, NULL, bid, gid, eid, NULL, 0, 1, 0, TYPE_oid, | 
| 326 | 					  BATgroupmin, NULL, NULL, NULL, "aggr.min" ); | 
| 327 | 	if (err == MAL_SUCCEED) { | 
| 328 | 		err = ALGprojection(retval, &tmpid, bid); | 
| 329 | 		BBPrelease(tmpid); | 
| 330 | 	} | 
| 331 | 	return err; | 
| 332 | } | 
| 333 |  | 
| 334 | mal_export str AGGRmax3(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 335 | str | 
| 336 | AGGRmax3(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 337 | { | 
| 338 | 	bat tmpid; | 
| 339 | 	str err; | 
| 340 |  | 
| 341 | 	err = AGGRgrouped(&tmpid, NULL, bid, gid, eid, NULL, 0, 1, 0, TYPE_oid, | 
| 342 | 					  BATgroupmax, NULL, NULL, NULL, "aggr.max" ); | 
| 343 | 	if (err == MAL_SUCCEED) { | 
| 344 | 		err = ALGprojection(retval, &tmpid, bid); | 
| 345 | 		BBPrelease(tmpid); | 
| 346 | 	} | 
| 347 | 	return err; | 
| 348 | } | 
| 349 |  | 
| 350 | mal_export str AGGRsubsum_bte(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error); | 
| 351 | str | 
| 352 | AGGRsubsum_bte(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error) | 
| 353 | { | 
| 354 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 355 | 					   *abort_on_error, 0, TYPE_bte, BATgroupsum, NULL, | 
| 356 | 					   NULL, NULL, "aggr.subsum" ); | 
| 357 | } | 
| 358 |  | 
| 359 | mal_export str AGGRsubsum_sht(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error); | 
| 360 | str | 
| 361 | AGGRsubsum_sht(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error) | 
| 362 | { | 
| 363 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 364 | 					   *abort_on_error, 0, TYPE_sht, BATgroupsum, NULL, | 
| 365 | 					   NULL, NULL, "aggr.subsum" ); | 
| 366 | } | 
| 367 |  | 
| 368 | mal_export str AGGRsubsum_int(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error); | 
| 369 | str | 
| 370 | AGGRsubsum_int(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error) | 
| 371 | { | 
| 372 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 373 | 					   *abort_on_error, 0, TYPE_int, BATgroupsum, NULL, | 
| 374 | 					   NULL, NULL, "aggr.subsum" ); | 
| 375 | } | 
| 376 |  | 
| 377 | mal_export str AGGRsubsum_lng(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error); | 
| 378 | str | 
| 379 | AGGRsubsum_lng(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error) | 
| 380 | { | 
| 381 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 382 | 					   *abort_on_error, 0, TYPE_lng, BATgroupsum, NULL, | 
| 383 | 					   NULL, NULL, "aggr.subsum" ); | 
| 384 | } | 
| 385 |  | 
| 386 | #ifdef HAVE_HGE | 
| 387 | mal_export str AGGRsubsum_hge(bat *retval, const bat *bid, const bat *gid, const bat *eid, bit *skip_nils, bit *abort_on_error); | 
| 388 | str | 
| 389 | AGGRsubsum_hge(bat *retval, const bat *bid, const bat *gid, const bat *eid, bit *skip_nils, bit *abort_on_error) | 
| 390 | { | 
| 391 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 392 | 					   *abort_on_error, 0, TYPE_hge, BATgroupsum, NULL, | 
| 393 | 					   NULL, NULL, "aggr.subsum" ); | 
| 394 | } | 
| 395 | #endif | 
| 396 |  | 
| 397 | mal_export str AGGRsubsum_flt(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error); | 
| 398 | str | 
| 399 | AGGRsubsum_flt(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error) | 
| 400 | { | 
| 401 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 402 | 					   *abort_on_error, 0, TYPE_flt, BATgroupsum, NULL, | 
| 403 | 					   NULL, NULL, "aggr.subsum" ); | 
| 404 | } | 
| 405 |  | 
| 406 | mal_export str AGGRsubsum_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error); | 
| 407 | str | 
| 408 | AGGRsubsum_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error) | 
| 409 | { | 
| 410 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 411 | 					   *abort_on_error, 0, TYPE_dbl, BATgroupsum, NULL, | 
| 412 | 					   NULL, NULL, "aggr.subsum" ); | 
| 413 | } | 
| 414 |  | 
| 415 | mal_export str AGGRsubsumcand_bte(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 416 | str | 
| 417 | AGGRsubsumcand_bte(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 418 | { | 
| 419 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 420 | 					   *abort_on_error, 0, TYPE_bte, BATgroupsum, NULL, | 
| 421 | 					   NULL, NULL, "aggr.subsum" ); | 
| 422 | } | 
| 423 |  | 
| 424 | mal_export str AGGRsubsumcand_sht(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 425 | str | 
| 426 | AGGRsubsumcand_sht(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 427 | { | 
| 428 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 429 | 					   *abort_on_error, 0, TYPE_sht, BATgroupsum, NULL, | 
| 430 | 					   NULL, NULL, "aggr.subsum" ); | 
| 431 | } | 
| 432 |  | 
| 433 | mal_export str AGGRsubsumcand_int(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 434 | str | 
| 435 | AGGRsubsumcand_int(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 436 | { | 
| 437 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 438 | 					   *abort_on_error, 0, TYPE_int, BATgroupsum, NULL, | 
| 439 | 					   NULL, NULL, "aggr.subsum" ); | 
| 440 | } | 
| 441 |  | 
| 442 | mal_export str AGGRsubsumcand_lng(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 443 | str | 
| 444 | AGGRsubsumcand_lng(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 445 | { | 
| 446 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 447 | 					   *abort_on_error, 0, TYPE_lng, BATgroupsum, NULL, | 
| 448 | 					   NULL, NULL, "aggr.subsum" ); | 
| 449 | } | 
| 450 |  | 
| 451 | #ifdef HAVE_HGE | 
| 452 | mal_export str AGGRsubsumcand_hge(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 453 | str | 
| 454 | AGGRsubsumcand_hge(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 455 | { | 
| 456 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 457 | 					   *abort_on_error, 0, TYPE_hge, BATgroupsum, NULL, | 
| 458 | 					   NULL, NULL, "aggr.subsum" ); | 
| 459 | } | 
| 460 | #endif | 
| 461 |  | 
| 462 | mal_export str AGGRsubsumcand_flt(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 463 | str | 
| 464 | AGGRsubsumcand_flt(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 465 | { | 
| 466 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 467 | 					   *abort_on_error, 0, TYPE_flt, BATgroupsum, NULL, | 
| 468 | 					   NULL, NULL, "aggr.subsum" ); | 
| 469 | } | 
| 470 |  | 
| 471 | mal_export str AGGRsubsumcand_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 472 | str | 
| 473 | AGGRsubsumcand_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 474 | { | 
| 475 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 476 | 					   *abort_on_error, 0, TYPE_dbl, BATgroupsum, NULL, | 
| 477 | 					   NULL, NULL, "aggr.subsum" ); | 
| 478 | } | 
| 479 |  | 
| 480 | mal_export str AGGRsubprod_bte(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error); | 
| 481 | str | 
| 482 | AGGRsubprod_bte(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error) | 
| 483 | { | 
| 484 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 485 | 					   *abort_on_error, 0, TYPE_bte, BATgroupprod, NULL, | 
| 486 | 					   NULL, NULL, "aggr.subprod" ); | 
| 487 | } | 
| 488 |  | 
| 489 | mal_export str AGGRsubprod_sht(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error); | 
| 490 | str | 
| 491 | AGGRsubprod_sht(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error) | 
| 492 | { | 
| 493 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 494 | 					   *abort_on_error, 0, TYPE_sht, BATgroupprod, NULL, | 
| 495 | 					   NULL, NULL, "aggr.subprod" ); | 
| 496 | } | 
| 497 |  | 
| 498 | mal_export str AGGRsubprod_int(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error); | 
| 499 | str | 
| 500 | AGGRsubprod_int(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error) | 
| 501 | { | 
| 502 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 503 | 					   *abort_on_error, 0, TYPE_int, BATgroupprod, NULL, | 
| 504 | 					   NULL, NULL, "aggr.subprod" ); | 
| 505 | } | 
| 506 |  | 
| 507 | mal_export str AGGRsubprod_lng(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error); | 
| 508 | str | 
| 509 | AGGRsubprod_lng(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error) | 
| 510 | { | 
| 511 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 512 | 					   *abort_on_error, 0, TYPE_lng, BATgroupprod, NULL, | 
| 513 | 					   NULL, NULL, "aggr.subprod" ); | 
| 514 | } | 
| 515 |  | 
| 516 | #ifdef HAVE_HGE | 
| 517 | mal_export str AGGRsubprod_hge(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error); | 
| 518 | str | 
| 519 | AGGRsubprod_hge(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error) | 
| 520 | { | 
| 521 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 522 | 					   *abort_on_error, 0, TYPE_hge, BATgroupprod, NULL, | 
| 523 | 					   NULL, NULL, "aggr.subprod" ); | 
| 524 | } | 
| 525 | #endif | 
| 526 |  | 
| 527 | mal_export str AGGRsubprod_flt(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error); | 
| 528 | str | 
| 529 | AGGRsubprod_flt(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error) | 
| 530 | { | 
| 531 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 532 | 					   *abort_on_error, 0, TYPE_flt, BATgroupprod, NULL, | 
| 533 | 					   NULL, NULL, "aggr.subprod" ); | 
| 534 | } | 
| 535 |  | 
| 536 | mal_export str AGGRsubprod_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error); | 
| 537 | str | 
| 538 | AGGRsubprod_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error) | 
| 539 | { | 
| 540 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 541 | 					   *abort_on_error, 0, TYPE_dbl, BATgroupprod, NULL, | 
| 542 | 					   NULL, NULL, "aggr.subprod" ); | 
| 543 | } | 
| 544 |  | 
| 545 | mal_export str AGGRsubprodcand_bte(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 546 | str | 
| 547 | AGGRsubprodcand_bte(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 548 | { | 
| 549 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 550 | 					   *abort_on_error, 0, TYPE_bte, BATgroupprod, NULL, | 
| 551 | 					   NULL, NULL, "aggr.subprod" ); | 
| 552 | } | 
| 553 |  | 
| 554 | mal_export str AGGRsubprodcand_sht(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 555 | str | 
| 556 | AGGRsubprodcand_sht(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 557 | { | 
| 558 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 559 | 					   *abort_on_error, 0, TYPE_sht, BATgroupprod, NULL, | 
| 560 | 					   NULL, NULL, "aggr.subprod" ); | 
| 561 | } | 
| 562 |  | 
| 563 | mal_export str AGGRsubprodcand_int(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 564 | str | 
| 565 | AGGRsubprodcand_int(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 566 | { | 
| 567 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 568 | 					   *abort_on_error, 0, TYPE_int, BATgroupprod, NULL, | 
| 569 | 					   NULL, NULL, "aggr.subprod" ); | 
| 570 | } | 
| 571 |  | 
| 572 | mal_export str AGGRsubprodcand_lng(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 573 | str | 
| 574 | AGGRsubprodcand_lng(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 575 | { | 
| 576 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 577 | 					   *abort_on_error, 0, TYPE_lng, BATgroupprod, NULL, | 
| 578 | 					   NULL, NULL, "aggr.subprod" ); | 
| 579 | } | 
| 580 |  | 
| 581 | #ifdef HAVE_HGE | 
| 582 | mal_export str AGGRsubprodcand_hge(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 583 | str | 
| 584 | AGGRsubprodcand_hge(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 585 | { | 
| 586 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 587 | 					   *abort_on_error, 0, TYPE_hge, BATgroupprod, NULL, | 
| 588 | 					   NULL, NULL, "aggr.subprod" ); | 
| 589 | } | 
| 590 | #endif | 
| 591 |  | 
| 592 | mal_export str AGGRsubprodcand_flt(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 593 | str | 
| 594 | AGGRsubprodcand_flt(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 595 | { | 
| 596 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 597 | 					   *abort_on_error, 0, TYPE_flt, BATgroupprod, NULL, | 
| 598 | 					   NULL, NULL, "aggr.subprod" ); | 
| 599 | } | 
| 600 |  | 
| 601 | mal_export str AGGRsubprodcand_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 602 | str | 
| 603 | AGGRsubprodcand_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 604 | { | 
| 605 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 606 | 					   *abort_on_error, 0, TYPE_dbl, BATgroupprod, NULL, | 
| 607 | 					   NULL, NULL, "aggr.subprod" ); | 
| 608 | } | 
| 609 |  | 
| 610 | mal_export str AGGRsubavg1_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error); | 
| 611 | str | 
| 612 | AGGRsubavg1_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error) | 
| 613 | { | 
| 614 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 615 | 					   *abort_on_error, 0, TYPE_dbl, NULL, BATgroupavg, | 
| 616 | 					   NULL, NULL, "aggr.subavg" ); | 
| 617 | } | 
| 618 |  | 
| 619 | mal_export str AGGRsubavg1cand_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 620 | str | 
| 621 | AGGRsubavg1cand_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 622 | { | 
| 623 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 624 | 					   *abort_on_error, 0, TYPE_dbl, NULL, BATgroupavg, | 
| 625 | 					   NULL, NULL, "aggr.subavg" ); | 
| 626 | } | 
| 627 |  | 
| 628 | mal_export str AGGRsubavg2_dbl(bat *retval1, bat *retval2, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error); | 
| 629 | str | 
| 630 | AGGRsubavg2_dbl(bat *retval1, bat *retval2, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error) | 
| 631 | { | 
| 632 | 	return AGGRgrouped(retval1, retval2, bid, gid, eid, NULL, *skip_nils, | 
| 633 | 					   *abort_on_error, 0, TYPE_dbl, NULL, BATgroupavg, | 
| 634 | 					   NULL, NULL, "aggr.subavg" ); | 
| 635 | } | 
| 636 |  | 
| 637 | mal_export str AGGRsubavg2cand_dbl(bat *retval1, bat *retval2, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 638 | str | 
| 639 | AGGRsubavg2cand_dbl(bat *retval1, bat *retval2, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 640 | { | 
| 641 | 	return AGGRgrouped(retval1, retval2, bid, gid, eid, sid, *skip_nils, | 
| 642 | 					   *abort_on_error, 0, TYPE_dbl, NULL, BATgroupavg, | 
| 643 | 					   NULL, NULL, "aggr.subavg" ); | 
| 644 | } | 
| 645 |  | 
| 646 | mal_export str AGGRsubavg1s_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error, int *scale); | 
| 647 | str | 
| 648 | AGGRsubavg1s_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error, int *scale) | 
| 649 | { | 
| 650 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 651 | 					   *abort_on_error, *scale, TYPE_dbl, NULL, BATgroupavg, | 
| 652 | 					   NULL, NULL, "aggr.subavg" ); | 
| 653 | } | 
| 654 |  | 
| 655 | mal_export str AGGRsubavg1scand_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error, int *scale); | 
| 656 | str | 
| 657 | AGGRsubavg1scand_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error, int *scale) | 
| 658 | { | 
| 659 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 660 | 					   *abort_on_error, *scale, TYPE_dbl, NULL, BATgroupavg, | 
| 661 | 					   NULL, NULL, "aggr.subavg" ); | 
| 662 | } | 
| 663 |  | 
| 664 | mal_export str AGGRsubavg2s_dbl(bat *retval1, bat *retval2, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error, int *scale); | 
| 665 | str | 
| 666 | AGGRsubavg2s_dbl(bat *retval1, bat *retval2, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error, int *scale) | 
| 667 | { | 
| 668 | 	return AGGRgrouped(retval1, retval2, bid, gid, eid, NULL, *skip_nils, | 
| 669 | 					   *abort_on_error, *scale, TYPE_dbl, NULL, BATgroupavg, | 
| 670 | 					   NULL, NULL, "aggr.subavg" ); | 
| 671 | } | 
| 672 |  | 
| 673 | mal_export str AGGRsubavg2scand_dbl(bat *retval1, bat *retval2, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error, int *scale); | 
| 674 | str | 
| 675 | AGGRsubavg2scand_dbl(bat *retval1, bat *retval2, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error, int *scale) | 
| 676 | { | 
| 677 | 	return AGGRgrouped(retval1, retval2, bid, gid, eid, sid, *skip_nils, | 
| 678 | 					   *abort_on_error, *scale, TYPE_dbl, NULL, BATgroupavg, | 
| 679 | 					   NULL, NULL, "aggr.subavg" ); | 
| 680 | } | 
| 681 |  | 
| 682 | mal_export str AGGRsubstdev_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error); | 
| 683 | str | 
| 684 | AGGRsubstdev_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error) | 
| 685 | { | 
| 686 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 687 | 					   *abort_on_error, 0, TYPE_dbl, BATgroupstdev_sample, | 
| 688 | 					   NULL, NULL, NULL, "aggr.substdev" ); | 
| 689 | } | 
| 690 |  | 
| 691 | mal_export str AGGRsubstdevcand_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 692 | str | 
| 693 | AGGRsubstdevcand_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 694 | { | 
| 695 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 696 | 					   *abort_on_error, 0, TYPE_dbl, BATgroupstdev_sample, | 
| 697 | 					   NULL, NULL, NULL, "aggr.substdev" ); | 
| 698 | } | 
| 699 |  | 
| 700 | mal_export str AGGRsubstdevp_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error); | 
| 701 | str | 
| 702 | AGGRsubstdevp_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error) | 
| 703 | { | 
| 704 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 705 | 					   *abort_on_error, 0, TYPE_dbl, | 
| 706 | 					   BATgroupstdev_population, NULL, NULL, NULL, | 
| 707 | 					   "aggr.substdevp" ); | 
| 708 | } | 
| 709 |  | 
| 710 | mal_export str AGGRsubstdevpcand_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 711 | str | 
| 712 | AGGRsubstdevpcand_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 713 | { | 
| 714 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 715 | 					   *abort_on_error, 0, TYPE_dbl, | 
| 716 | 					   BATgroupstdev_population, | 
| 717 | 					   NULL, NULL, NULL, "aggr.substdevp" ); | 
| 718 | } | 
| 719 |  | 
| 720 | mal_export str AGGRsubvariance_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error); | 
| 721 | str | 
| 722 | AGGRsubvariance_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error) | 
| 723 | { | 
| 724 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 725 | 					   *abort_on_error, 0, TYPE_dbl, BATgroupvariance_sample, | 
| 726 | 					   NULL, NULL, NULL, "aggr.subvariance" ); | 
| 727 | } | 
| 728 |  | 
| 729 | mal_export str AGGRsubvariancecand_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 730 | str | 
| 731 | AGGRsubvariancecand_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 732 | { | 
| 733 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 734 | 					   *abort_on_error, 0, TYPE_dbl, BATgroupvariance_sample, | 
| 735 | 					   NULL, NULL, NULL, "aggr.subvariance" ); | 
| 736 | } | 
| 737 |  | 
| 738 | mal_export str AGGRsubvariancep_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error); | 
| 739 | str | 
| 740 | AGGRsubvariancep_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error) | 
| 741 | { | 
| 742 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 743 | 					   *abort_on_error, 0, TYPE_dbl, | 
| 744 | 					   BATgroupvariance_population, NULL, | 
| 745 | 					   NULL, NULL, "aggr.subvariancep" ); | 
| 746 | } | 
| 747 |  | 
| 748 | mal_export str AGGRsubvariancepcand_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 749 | str | 
| 750 | AGGRsubvariancepcand_dbl(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 751 | { | 
| 752 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 753 | 					   *abort_on_error, 0, TYPE_dbl, | 
| 754 | 					   BATgroupvariance_population, NULL, | 
| 755 | 					   NULL, NULL, "aggr.subvariancep" ); | 
| 756 | } | 
| 757 |  | 
| 758 | mal_export str AGGRsubcount(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils); | 
| 759 | str | 
| 760 | AGGRsubcount(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils) | 
| 761 | { | 
| 762 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 763 | 					   0, 0, TYPE_lng, BATgroupcount, NULL, NULL, | 
| 764 | 					   NULL, "aggr.subcount" ); | 
| 765 | } | 
| 766 |  | 
| 767 | mal_export str AGGRsubcountcand(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils); | 
| 768 | str | 
| 769 | AGGRsubcountcand(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils) | 
| 770 | { | 
| 771 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 772 | 					   0, 0, TYPE_lng, BATgroupcount, NULL, | 
| 773 | 					   NULL, NULL, "aggr.subcount" ); | 
| 774 | } | 
| 775 |  | 
| 776 | mal_export str AGGRsubmin(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils); | 
| 777 | str | 
| 778 | AGGRsubmin(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils) | 
| 779 | { | 
| 780 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 781 | 					   0, 0, TYPE_oid, BATgroupmin, NULL, | 
| 782 | 					   NULL, NULL, "aggr.submin" ); | 
| 783 | } | 
| 784 |  | 
| 785 | mal_export str AGGRsubmincand(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils); | 
| 786 | str | 
| 787 | AGGRsubmincand(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils) | 
| 788 | { | 
| 789 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 790 | 					   0, 0, TYPE_oid, BATgroupmin, NULL, | 
| 791 | 					   NULL, NULL, "aggr.submin" ); | 
| 792 | } | 
| 793 |  | 
| 794 | mal_export str AGGRsubmax(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils); | 
| 795 | str | 
| 796 | AGGRsubmax(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils) | 
| 797 | { | 
| 798 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 799 | 					   0, 0, TYPE_oid, BATgroupmax, NULL, | 
| 800 | 					   NULL, NULL, "aggr.submax" ); | 
| 801 | } | 
| 802 |  | 
| 803 | mal_export str AGGRsubmaxcand(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils); | 
| 804 | str | 
| 805 | AGGRsubmaxcand(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils) | 
| 806 | { | 
| 807 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 808 | 					   0, 0, TYPE_oid, BATgroupmax, NULL, | 
| 809 | 					   NULL, NULL, "aggr.submax" ); | 
| 810 | } | 
| 811 |  | 
| 812 | mal_export str AGGRsubmincand_val(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils); | 
| 813 | str | 
| 814 | AGGRsubmincand_val(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils) | 
| 815 | { | 
| 816 | 	bat tmpid; | 
| 817 | 	str err; | 
| 818 |  | 
| 819 | 	err = AGGRgrouped(&tmpid, NULL, bid, gid, eid, sid, *skip_nils, 0, | 
| 820 | 					  0, TYPE_oid, BATgroupmin, NULL, NULL, NULL, "aggr.submin" ); | 
| 821 | 	if (err == MAL_SUCCEED) { | 
| 822 | 		err = ALGprojection(retval, &tmpid, bid); | 
| 823 | 		BBPrelease(tmpid); | 
| 824 | 	} | 
| 825 | 	return err; | 
| 826 | } | 
| 827 |  | 
| 828 | mal_export str AGGRsubmin_val(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils); | 
| 829 | str | 
| 830 | AGGRsubmin_val(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils) | 
| 831 | { | 
| 832 | 	return AGGRsubmincand_val(retval, bid, gid, eid, NULL, skip_nils); | 
| 833 | } | 
| 834 |  | 
| 835 | mal_export str AGGRsubmaxcand_val(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils); | 
| 836 | str | 
| 837 | AGGRsubmaxcand_val(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils) | 
| 838 | { | 
| 839 | 	bat tmpid; | 
| 840 | 	str err; | 
| 841 |  | 
| 842 | 	err = AGGRgrouped(&tmpid, NULL, bid, gid, eid, sid, *skip_nils, 0, | 
| 843 | 					  0, TYPE_oid, BATgroupmax, NULL, NULL, NULL, "aggr.submax" ); | 
| 844 | 	if (err == MAL_SUCCEED) { | 
| 845 | 		err = ALGprojection(retval, &tmpid, bid); | 
| 846 | 		BBPrelease(tmpid); | 
| 847 | 	} | 
| 848 | 	return err; | 
| 849 | } | 
| 850 |  | 
| 851 | mal_export str AGGRsubmax_val(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils); | 
| 852 | str | 
| 853 | AGGRsubmax_val(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils) | 
| 854 | { | 
| 855 | 	return AGGRsubmaxcand_val(retval, bid, gid, eid, NULL, skip_nils); | 
| 856 | } | 
| 857 |  | 
| 858 | mal_export str AGGRmedian(void *retval, const bat *bid); | 
| 859 | str | 
| 860 | AGGRmedian(void *retval, const bat *bid) | 
| 861 | { | 
| 862 | 	str err; | 
| 863 | 	bat rval; | 
| 864 | 	if ((err = AGGRgrouped(&rval, NULL, bid, NULL, NULL, NULL, 1, | 
| 865 | 						   0, 0, TYPE_any, BATgroupmedian, NULL, | 
| 866 | 						   NULL, NULL, "aggr.submedian" )) == MAL_SUCCEED) { | 
| 867 | 		oid pos = 0; | 
| 868 | 		err = ALGfetchoid(retval, &rval, &pos); | 
| 869 | 		BBPrelease(rval); | 
| 870 | 	} | 
| 871 | 	return err; | 
| 872 | } | 
| 873 |  | 
| 874 | mal_export str AGGRsubmedian(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils); | 
| 875 | str | 
| 876 | AGGRsubmedian(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils) | 
| 877 | { | 
| 878 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 879 | 					   0, 0, TYPE_any, BATgroupmedian, NULL, | 
| 880 | 					   NULL, NULL, "aggr.submedian" ); | 
| 881 | } | 
| 882 |  | 
| 883 | mal_export str AGGRsubmediancand(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils); | 
| 884 | str | 
| 885 | AGGRsubmediancand(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils) | 
| 886 | { | 
| 887 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 888 | 					   0, 0, TYPE_any, BATgroupmedian, NULL, | 
| 889 | 					   NULL, NULL, "aggr.submedian" ); | 
| 890 | } | 
| 891 |  | 
| 892 | /* quantile functions, could make median functions obsolete completely */ | 
| 893 | mal_export str AGGRquantile(void *retval, const bat *bid, const bat *qid); | 
| 894 | str | 
| 895 | AGGRquantile(void *retval, const bat *bid, const bat *qid) | 
| 896 | { | 
| 897 | 	str err; | 
| 898 | 	bat rval; | 
| 899 | 	if ((err = AGGRgrouped(&rval, NULL, bid, NULL, NULL, NULL, 1, | 
| 900 | 						   0, 0, TYPE_any, NULL, NULL, BATgroupquantile, | 
| 901 | 						   qid, "aggr.subquantile" )) == MAL_SUCCEED) { | 
| 902 | 		oid pos = 0; | 
| 903 | 		err = ALGfetchoid(retval, &rval, &pos); | 
| 904 | 		BBPrelease(rval); | 
| 905 | 	} | 
| 906 | 	return err; | 
| 907 | } | 
| 908 |  | 
| 909 | mal_export str AGGRsubquantile(bat *retval, const bat *bid, const bat *quantile, const bat *gid, const bat *eid, const bit *skip_nils); | 
| 910 | str | 
| 911 | AGGRsubquantile(bat *retval, const bat *bid, const bat *quantile, const bat *gid, const bat *eid, const bit *skip_nils) | 
| 912 | { | 
| 913 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 914 | 					   0, 0, TYPE_any, NULL, NULL, BATgroupquantile, | 
| 915 | 					   quantile, "aggr.subquantile" ); | 
| 916 | } | 
| 917 |  | 
| 918 | mal_export str AGGRsubquantilecand(bat *retval, const bat *bid, const bat *quantile, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils); | 
| 919 | str | 
| 920 | AGGRsubquantilecand(bat *retval, const bat *bid, const bat *quantile, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils) | 
| 921 | { | 
| 922 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 923 | 					   0, 0, TYPE_any, NULL, NULL, BATgroupquantile, | 
| 924 | 					   quantile, "aggr.subquantile" ); | 
| 925 | } | 
| 926 |  | 
| 927 | mal_export str AGGRmedian_avg(dbl *retval, const bat *bid); | 
| 928 | str | 
| 929 | AGGRmedian_avg(dbl *retval, const bat *bid) | 
| 930 | { | 
| 931 | 	str err; | 
| 932 | 	bat rval; | 
| 933 | 	if ((err = AGGRgrouped(&rval, NULL, bid, NULL, NULL, NULL, 1, | 
| 934 | 						   0, 0, TYPE_any, BATgroupmedian_avg, NULL, | 
| 935 | 						   NULL, NULL, "aggr.submedian_avg" )) == MAL_SUCCEED) { | 
| 936 | 		oid pos = 0; | 
| 937 | 		err = ALGfetchoid(retval, &rval, &pos); | 
| 938 | 		BBPrelease(rval); | 
| 939 | 	} | 
| 940 | 	return err; | 
| 941 | } | 
| 942 |  | 
| 943 | mal_export str AGGRsubmedian_avg(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils); | 
| 944 | str | 
| 945 | AGGRsubmedian_avg(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils) | 
| 946 | { | 
| 947 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 948 | 					   0, 0, TYPE_any, BATgroupmedian_avg, NULL, | 
| 949 | 					   NULL, NULL, "aggr.submedian_avg" ); | 
| 950 | } | 
| 951 |  | 
| 952 | mal_export str AGGRsubmediancand_avg(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils); | 
| 953 | str | 
| 954 | AGGRsubmediancand_avg(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils) | 
| 955 | { | 
| 956 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 957 | 					   0, 0, TYPE_any, BATgroupmedian_avg, NULL, | 
| 958 | 					   NULL, NULL, "aggr.submedian_avg" ); | 
| 959 | } | 
| 960 |  | 
| 961 | /* quantile functions, could make median functions obsolete completely */ | 
| 962 | mal_export str AGGRquantile_avg(dbl *retval, const bat *bid, const bat *qid); | 
| 963 | str | 
| 964 | AGGRquantile_avg(dbl *retval, const bat *bid, const bat *qid) | 
| 965 | { | 
| 966 | 	str err; | 
| 967 | 	bat rval; | 
| 968 | 	if ((err = AGGRgrouped(&rval, NULL, bid, NULL, NULL, NULL, 1, | 
| 969 | 						   0, 0, TYPE_any, NULL, NULL, BATgroupquantile_avg, | 
| 970 | 						   qid, "aggr.subquantile_avg" )) == MAL_SUCCEED) { | 
| 971 | 		oid pos = 0; | 
| 972 | 		err = ALGfetchoid(retval, &rval, &pos); | 
| 973 | 		BBPrelease(rval); | 
| 974 | 	} | 
| 975 | 	return err; | 
| 976 | } | 
| 977 |  | 
| 978 | mal_export str AGGRsubquantile_avg(bat *retval, const bat *bid, const bat *quantile, const bat *gid, const bat *eid, const bit *skip_nils); | 
| 979 | str | 
| 980 | AGGRsubquantile_avg(bat *retval, const bat *bid, const bat *quantile, const bat *gid, const bat *eid, const bit *skip_nils) | 
| 981 | { | 
| 982 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, NULL, *skip_nils, | 
| 983 | 					   0, 0, TYPE_any, NULL, NULL, BATgroupquantile_avg, | 
| 984 | 					   quantile, "aggr.subquantile_avg" ); | 
| 985 | } | 
| 986 |  | 
| 987 | mal_export str AGGRsubquantilecand_avg(bat *retval, const bat *bid, const bat *quantile, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils); | 
| 988 | str | 
| 989 | AGGRsubquantilecand_avg(bat *retval, const bat *bid, const bat *quantile, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils) | 
| 990 | { | 
| 991 | 	return AGGRgrouped(retval, NULL, bid, gid, eid, sid, *skip_nils, | 
| 992 | 					   0, 0, TYPE_any, NULL, NULL, BATgroupquantile_avg, | 
| 993 | 					   quantile, "aggr.subquantile_avg" ); | 
| 994 | } | 
| 995 |  | 
| 996 | static str | 
| 997 | AGGRgroup_str_concat(bat *retval1, const bat *bid, const bat *gid, const bat *eid, const bat *sid, bool skip_nils, | 
| 998 | 					 bool abort_on_error, BAT *(*str_func)(BAT *, BAT *, BAT *, BAT *, bool, bool, const char *), | 
| 999 | 					 const char *separator, const char *malfunc) | 
| 1000 | { | 
| 1001 | 	BAT *b, *g, *e, *s, *bn = NULL; | 
| 1002 |  | 
| 1003 | 	assert(str_func != NULL); | 
| 1004 |  | 
| 1005 | 	b = BATdescriptor(*bid); | 
| 1006 | 	g = gid ? BATdescriptor(*gid) : NULL; | 
| 1007 | 	e = eid ? BATdescriptor(*eid) : NULL; | 
| 1008 | 	s = sid ? BATdescriptor(*sid) : NULL; | 
| 1009 |  | 
| 1010 | 	if (b == NULL || (gid != NULL && g == NULL) || (eid != NULL && e == NULL) || | 
| 1011 | 		(sid != NULL && s == NULL)) { | 
| 1012 | 		if (b) | 
| 1013 | 			BBPunfix(b->batCacheid); | 
| 1014 | 		if (g) | 
| 1015 | 			BBPunfix(g->batCacheid); | 
| 1016 | 		if (e) | 
| 1017 | 			BBPunfix(e->batCacheid); | 
| 1018 | 		if (s) | 
| 1019 | 			BBPunfix(s->batCacheid); | 
| 1020 | 		throw(MAL, malfunc, SQLSTATE(HY002) RUNTIME_OBJECT_MISSING); | 
| 1021 | 	} | 
| 1022 |  | 
| 1023 | 	bn = (*str_func)(b, g, e, s, skip_nils, abort_on_error, separator); | 
| 1024 |  | 
| 1025 | 	BBPunfix(b->batCacheid); | 
| 1026 | 	if (g) | 
| 1027 | 		BBPunfix(g->batCacheid); | 
| 1028 | 	if (e) | 
| 1029 | 		BBPunfix(e->batCacheid); | 
| 1030 | 	if (s) | 
| 1031 | 		BBPunfix(s->batCacheid); | 
| 1032 | 	if (bn == NULL) | 
| 1033 | 		throw(MAL, malfunc, GDK_EXCEPTION); | 
| 1034 | 	*retval1 = bn->batCacheid; | 
| 1035 | 	BBPkeepref(bn->batCacheid); | 
| 1036 | 	return MAL_SUCCEED; | 
| 1037 | } | 
| 1038 |  | 
| 1039 | #define DEFAULT_SEPARATOR "," | 
| 1040 |  | 
| 1041 | mal_export str AGGRstr_group_concat(bat *retval, const bat *bid, const bat *gid, const bat *eid); | 
| 1042 | str | 
| 1043 | AGGRstr_group_concat(bat *retval, const bat *bid, const bat *gid, const bat *eid) | 
| 1044 | { | 
| 1045 | 	return AGGRgroup_str_concat(retval, bid, gid, eid, NULL, 1, 1, BATgroupstr_group_concat, DEFAULT_SEPARATOR, | 
| 1046 | 								"aggr.str_group_concat" ); | 
| 1047 | } | 
| 1048 |  | 
| 1049 | mal_export str AGGRsubstr_group_concat(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error); | 
| 1050 | str | 
| 1051 | AGGRsubstr_group_concat(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error) | 
| 1052 | { | 
| 1053 | 	return AGGRgroup_str_concat(retval, bid, gid, eid, NULL, *skip_nils, *abort_on_error, BATgroupstr_group_concat, | 
| 1054 | 								DEFAULT_SEPARATOR, "aggr.substr_group_concat" ); | 
| 1055 | } | 
| 1056 |  | 
| 1057 | mal_export str AGGRsubstr_group_concatcand(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 1058 | str | 
| 1059 | AGGRsubstr_group_concatcand(bat *retval, const bat *bid, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 1060 | { | 
| 1061 | 	return AGGRgroup_str_concat(retval, bid, gid, eid, sid, *skip_nils, *abort_on_error, BATgroupstr_group_concat, | 
| 1062 | 								DEFAULT_SEPARATOR, "aggr.substr_group_concat" ); | 
| 1063 | } | 
| 1064 |  | 
| 1065 | #define GET_SEPARATOR(MAL_FUNC)                                                  \ | 
| 1066 | 	do {                                                                         \ | 
| 1067 | 		BATiter bi;                                                              \ | 
| 1068 | 		sep = BATdescriptor(*sepp);                                              \ | 
| 1069 | 		if (sep == NULL)                                                         \ | 
| 1070 | 			throw(MAL, MAL_FUNC, SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);        \ | 
| 1071 | 		bi = bat_iterator(sep);                                                  \ | 
| 1072 | 		separator = BUNtvar(bi, 0);                                              \ | 
| 1073 | 	} while (0); | 
| 1074 |  | 
| 1075 | mal_export str AGGRstr_group_concat_sep(bat *retval, const bat *bid, const bat *sepp, const bat *gid, const bat *eid); | 
| 1076 | str | 
| 1077 | AGGRstr_group_concat_sep(bat *retval, const bat *bid, const bat *sepp, const bat *gid, const bat *eid) | 
| 1078 | { | 
| 1079 | 	BAT *sep = NULL; | 
| 1080 | 	str separator = DEFAULT_SEPARATOR, msg = MAL_SUCCEED; | 
| 1081 |  | 
| 1082 | 	GET_SEPARATOR("aggr.str_group_concat_sep" ) | 
| 1083 | 	msg = AGGRgroup_str_concat(retval, bid, gid, eid, NULL, 1, 1, BATgroupstr_group_concat, separator, | 
| 1084 | 								"aggr.str_group_concat_sep" ); | 
| 1085 | 	BBPunfix(sep->batCacheid); | 
| 1086 | 	return msg; | 
| 1087 | } | 
| 1088 |  | 
| 1089 | mal_export str AGGRsubstr_group_concat_sep(bat *retval, const bat *bid, const bat *sepp, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error); | 
| 1090 | str | 
| 1091 | AGGRsubstr_group_concat_sep(bat *retval, const bat *bid, const bat *sepp, const bat *gid, const bat *eid, const bit *skip_nils, const bit *abort_on_error) | 
| 1092 | { | 
| 1093 | 	BAT *sep = NULL; | 
| 1094 | 	str separator = DEFAULT_SEPARATOR, msg = MAL_SUCCEED; | 
| 1095 |  | 
| 1096 | 	GET_SEPARATOR("aggr.substr_group_concat_sep" ) | 
| 1097 | 	msg = AGGRgroup_str_concat(retval, bid, gid, eid, NULL, *skip_nils, *abort_on_error, BATgroupstr_group_concat, | 
| 1098 | 								separator, "aggr.substr_group_concat_sep" ); | 
| 1099 | 	BBPunfix(sep->batCacheid); | 
| 1100 | 	return msg; | 
| 1101 | } | 
| 1102 |  | 
| 1103 | mal_export str AGGRsubstr_group_concatcand_sep(bat *retval, const bat *bid, const bat *sepp, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error); | 
| 1104 | str | 
| 1105 | AGGRsubstr_group_concatcand_sep(bat *retval, const bat *bid, const bat *sepp, const bat *gid, const bat *eid, const bat *sid, const bit *skip_nils, const bit *abort_on_error) | 
| 1106 | { | 
| 1107 | 	BAT *sep = NULL; | 
| 1108 | 	str separator = DEFAULT_SEPARATOR, msg = MAL_SUCCEED; | 
| 1109 |  | 
| 1110 | 	GET_SEPARATOR("aggr.substr_group_concat_sep" ) | 
| 1111 | 	msg = AGGRgroup_str_concat(retval, bid, gid, eid, sid, *skip_nils, *abort_on_error, BATgroupstr_group_concat, | 
| 1112 | 								separator, "aggr.substr_group_concat_sep" ); | 
| 1113 | 	BBPunfix(sep->batCacheid); | 
| 1114 | 	return msg; | 
| 1115 | } | 
| 1116 |  |