Changeset: 62acfcecc9fa for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=62acfcecc9fa
Removed Files:
monetdb5/modules/atoms/batxml.h
Modified Files:
clients/Tests/exports.stable.out
gdk/gdk_aggr.c
gdk/gdk_calc.h
monetdb5/modules/atoms/Makefile.ag
monetdb5/modules/atoms/batxml.c
monetdb5/modules/atoms/batxml.mal
Branch: default
Log Message:
Implemented grouped aggregate (xml.subaggr) for SQL/XML.
The old XML aggregate code is unchanged, the new interface uses the
"sub" techniques.
This code is untested.
diffs (truncated from 687 to 300 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
@@ -116,6 +116,7 @@ BAT *BATfetchjoin(BAT *b, BAT *s, BUN es
int BATgetaccess(BAT *b);
PROPrec *BATgetprop(BAT *b, int idx);
gdk_return BATgroup(BAT **groups, BAT **extents, BAT **histo, BAT *b, BAT *g,
BAT *e, BAT *h);
+const char *BATgroupaggrinit(const BAT *b, const BAT *g, const BAT *e, const
BAT *s, oid *minp, oid *maxp, BUN *ngrpp, BUN *startp, BUN *endp, BUN *cntp,
const oid **candp, const oid **candendp);
BAT *BATgroupavg(BAT *b, BAT *g, BAT *e, BAT *s, int tp, int skip_nils, int
abort_on_error);
BAT *BATgroupcount(BAT *b, BAT *g, BAT *e, BAT *s, int tp, int skip_nils, int
abort_on_error);
BAT *BATgroupmax(BAT *b, BAT *g, BAT *e, BAT *s, int tp, int skip_nils, int
abort_on_error);
@@ -653,6 +654,8 @@ str AGGRsubsumcand_int(bat *retval, bat
str AGGRsubsumcand_lng(bat *retval, bat *bid, bat *gid, bat *eid, bat *sid,
int *skip_nils, int *abort_on_error);
str AGGRsubsumcand_sht(bat *retval, bat *bid, bat *gid, bat *eid, bat *sid,
int *skip_nils, int *abort_on_error);
str AGGRsubsumcand_wrd(bat *retval, bat *bid, bat *gid, bat *eid, bat *sid,
int *skip_nils, int *abort_on_error);
+str AGGRsubxml(bat *retval, bat *bid, bat *gid, bat *eid, int *skip_nils);
+str AGGRsubxmlcand(bat *retval, bat *bid, bat *gid, bat *eid, bat *sid, int
*skip_nils);
str AGGRsum2_bte(bat *retval, bat *bid, bat *eid);
str AGGRsum2_dbl(bat *retval, bat *bid, bat *eid);
str AGGRsum2_flt(bat *retval, bat *bid, bat *eid);
@@ -667,6 +670,7 @@ str AGGRsum3_int(bat *retval, bat *bid,
str AGGRsum3_lng(bat *retval, bat *bid, bat *gid, bat *eid);
str AGGRsum3_sht(bat *retval, bat *bid, bat *gid, bat *eid);
str AGGRsum3_wrd(bat *retval, bat *bid, bat *gid, bat *eid);
+str AGGRxml(bat *retval, bat *bid, int *skip_nils);
str ALARMctime(str *res);
str ALARMepilogue(void);
str ALARMepoch(int *res);
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -69,13 +69,11 @@
* number of groups) and initializes the variables for candidates
* selection.
*/
-static gdk_return
-initgroupaggr(const BAT *b, const BAT *g, const BAT *e, const BAT *s,
- /* on whose behalf we're doing this */
- const char *func,
- /* outputs: */
- oid *minp, oid *maxp, BUN *ngrpp, BUN *startp, BUN *endp,
- BUN *cntp, const oid **candp, const oid **candendp)
+const char *
+BATgroupaggrinit(const BAT *b, const BAT *g, const BAT *e, const BAT *s,
+ /* outputs: */
+ oid *minp, oid *maxp, BUN *ngrpp, BUN *startp, BUN *endp,
+ BUN *cntp, const oid **candp, const oid **candendp)
{
oid min, max;
BUN i, ngrp;
@@ -83,22 +81,16 @@ initgroupaggr(const BAT *b, const BAT *g
BUN start, end, cnt;
const oid *cand = NULL, *candend = NULL;
- if (b == NULL || !BAThdense(b)) {
- GDKerror("%s: b must be dense-headed\n", func);
- return GDK_FAIL;
- }
+ if (b == NULL || !BAThdense(b))
+ return "b must be dense-headed";
if (g) {
if (!BAThdense(g) || BATcount(b) != BATcount(g) ||
- (BATcount(b) != 0 && b->hseqbase != g->hseqbase)) {
- GDKerror("%s: b and g must be aligned\n", func);
- return GDK_FAIL;
- }
+ (BATcount(b) != 0 && b->hseqbase != g->hseqbase))
+ return "b and g must be aligned";
assert(BATttype(g) == TYPE_oid);
}
- if (e != NULL && !BAThdense(e)) {
- GDKerror("%s: e must be dense-headed\n", func);
- return GDK_FAIL;
- }
+ if (e != NULL && !BAThdense(e))
+ return "e must be dense-headed";
if (g == NULL) {
min = 0;
max = 0;
@@ -156,7 +148,7 @@ initgroupaggr(const BAT *b, const BAT *g
*candp = cand;
*candendp = candend;
- return GDK_SUCCEED;
+ return NULL;
}
#define AGGR_SUM(TYPE1, TYPE2) \
@@ -210,10 +202,13 @@ BATgroupsum(BAT *b, BAT *g, BAT *e, BAT
unsigned int *seen; /* bitmask for groups that we've seen */
BUN start, end, cnt;
const oid *cand = NULL, *candend = NULL;
+ const char *err;
- if (initgroupaggr(b, g, e, s, "BATgroupsum", &min, &max, &ngrp,
- &start, &end, &cnt, &cand, &candend) == GDK_FAIL)
+ if ((err = BATgroupaggrinit(b, g, e, s, &min, &max, &ngrp, &start, &end,
+ &cnt, &cand, &candend)) != NULL) {
+ GDKerror("BATgroupsum: %s\n", err);
return NULL;
+ }
if (g == NULL) {
GDKerror("BATgroupsum: b and g must be aligned\n");
return NULL;
@@ -525,10 +520,13 @@ BATgroupprod(BAT *b, BAT *g, BAT *e, BAT
unsigned int *seen; /* bitmask for groups that we've seen */
BUN start, end, cnt;
const oid *cand = NULL, *candend = NULL;
+ const char *err;
- if (initgroupaggr(b, g, e, s, "BATgroupprod", &min, &max, &ngrp,
- &start, &end, &cnt, &cand, &candend) == GDK_FAIL)
+ if ((err = BATgroupaggrinit(b, g, e, s, &min, &max, &ngrp, &start, &end,
+ &cnt, &cand, &candend)) != NULL) {
+ GDKerror("BATgroupprod: %s\n", err);
return NULL;
+ }
if (g == NULL) {
GDKerror("BATgroupprod: b and g must be aligned\n");
return NULL;
@@ -804,14 +802,17 @@ BATgroupavg(BAT *b, BAT *g, BAT *e, BAT
BAT *bn = NULL;
BUN start, end, cnt;
const oid *cand = NULL, *candend = NULL;
+ const char *err;
assert(tp == TYPE_dbl);
(void) tp; /* compatibility (with other BATgroup*
* functions) argument */
- if (initgroupaggr(b, g, e, s, "BATgroupavg", &min, &max, &ngrp,
- &start, &end, &cnt, &cand, &candend) == GDK_FAIL)
+ if ((err = BATgroupaggrinit(b, g, e, s, &min, &max, &ngrp, &start, &end,
+ &cnt, &cand, &candend)) != NULL) {
+ GDKerror("BATgroupavg: %s\n", err);
return NULL;
+ }
if (g == NULL) {
GDKerror("BATgroupavg: b and g must be aligned\n");
return NULL;
@@ -949,14 +950,17 @@ BATgroupcount(BAT *b, BAT *g, BAT *e, BA
BATiter bi;
BUN start, end, cnt;
const oid *cand = NULL, *candend = NULL;
+ const char *err;
assert(tp == TYPE_wrd);
(void) tp; /* compatibility (with other BATgroup* */
(void) abort_on_error; /* functions) argument */
- if (initgroupaggr(b, g, e, s, "BATgroupcount", &min, &max, &ngrp,
- &start, &end, &cnt, &cand, &candend) == GDK_FAIL)
+ if ((err = BATgroupaggrinit(b, g, e, s, &min, &max, &ngrp, &start, &end,
+ &cnt, &cand, &candend)) != NULL) {
+ GDKerror("BATgroupcount: %s\n", err);
return NULL;
+ }
if (g == NULL) {
GDKerror("BATgroupcount: b and g must be aligned\n");
return NULL;
@@ -1059,6 +1063,7 @@ BATgroupsize(BAT *b, BAT *g, BAT *e, BAT
BAT *bn = NULL;
BUN start, end, cnt;
const oid *cand = NULL, *candend = NULL;
+ const char *err;
assert(tp == TYPE_wrd);
assert(b->ttype == TYPE_bit);
@@ -1067,9 +1072,11 @@ BATgroupsize(BAT *b, BAT *g, BAT *e, BAT
(void) abort_on_error;
(void) skip_nils;
- if (initgroupaggr(b, g, e, s, "BATgroupsize", &min, &max, &ngrp,
- &start, &end, &cnt, &cand, &candend) == GDK_FAIL)
+ if ((err = BATgroupaggrinit(b, g, e, s, &min, &max, &ngrp, &start, &end,
+ &cnt, &cand, &candend)) != NULL) {
+ GDKerror("BATgroupsize: %s\n", err);
return NULL;
+ }
if (g == NULL) {
GDKerror("BATgroupsize: b and g must be aligned\n");
return NULL;
@@ -1177,6 +1184,7 @@ BATgroupmin(BAT *b, BAT *g, BAT *e, BAT
BATiter bi;
BUN start, end, cnt;
const oid *cand = NULL, *candend = NULL;
+ const char *err;
assert(tp == TYPE_oid);
(void) tp; /* compatibility (with other BATgroup* */
@@ -1188,9 +1196,11 @@ BATgroupmin(BAT *b, BAT *g, BAT *e, BAT
return NULL;
}
- if (initgroupaggr(b, g, e, s, "BATgroupmin", &min, &max, &ngrp,
- &start, &end, &cnt, &cand, &candend) == GDK_FAIL)
+ if ((err = BATgroupaggrinit(b, g, e, s, &min, &max, &ngrp, &start, &end,
+ &cnt, &cand, &candend)) != NULL) {
+ GDKerror("BATgroupmin: %s\n", err);
return NULL;
+ }
if (g == NULL) {
GDKerror("BATgroupmin: b and g must be aligned\n");
return NULL;
@@ -1313,6 +1323,7 @@ BATgroupmax(BAT *b, BAT *g, BAT *e, BAT
BATiter bi;
BUN start, end, cnt;
const oid *cand = NULL, *candend = NULL;
+ const char *err;
assert(tp == TYPE_oid);
(void) tp; /* compatibility (with other BATgroup* */
@@ -1324,9 +1335,11 @@ BATgroupmax(BAT *b, BAT *g, BAT *e, BAT
return NULL;
}
- if (initgroupaggr(b, g, e, s, "BATgroupmax", &min, &max, &ngrp,
- &start, &end, &cnt, &cand, &candend) == GDK_FAIL)
+ if ((err = BATgroupaggrinit(b, g, e, s, &min, &max, &ngrp, &start, &end,
+ &cnt, &cand, &candend)) != NULL) {
+ GDKerror("BATgroupmax: %s\n", err);
return NULL;
+ }
if (g == NULL) {
GDKerror("BATgroupmax: b and g must be aligned\n");
return NULL;
@@ -1444,12 +1457,15 @@ BATgroupmedian(BAT *b, BAT *g, BAT *e, B
const void *v;
const void *nil;
int (*atomcmp)(const void *, const void *);
+ const char *err;
(void) abort_on_error;
- if (initgroupaggr(b, g, e, s, "BATgroupmedian", &min, &max, &ngrp,
- &start, &end, &cnt, &cand, &candend) == GDK_FAIL)
+ if ((err = BATgroupaggrinit(b, g, e, s, &min, &max, &ngrp, &start, &end,
+ &cnt, &cand, &candend)) != NULL) {
+ GDKerror("BATgroupmedian: %s\n", err);
return NULL;
+ }
assert(tp == b->ttype);
if (!ATOMlinear(b->ttype)) {
GDKerror("BATgroupmedian: cannot determine median on "
diff --git a/gdk/gdk_calc.h b/gdk/gdk_calc.h
--- a/gdk/gdk_calc.h
+++ b/gdk/gdk_calc.h
@@ -126,3 +126,9 @@ gdk_export BAT *BATgroupsize(BAT *b, BAT
gdk_export BAT *BATgroupmin(BAT *b, BAT *g, BAT *e, BAT *s, int tp, int
skip_nils, int abort_on_error);
gdk_export BAT *BATgroupmax(BAT *b, BAT *g, BAT *e, BAT *s, int tp, int
skip_nils, int abort_on_error);
gdk_export BAT *BATgroupmedian(BAT *b, BAT *g, BAT *e, BAT *s, int tp, int
skip_nils, int abort_on_error);
+/* helper function for grouped aggregates */
+gdk_export const char *BATgroupaggrinit(
+ const BAT *b, const BAT *g, const BAT *e, const BAT *s,
+ /* outputs: */
+ oid *minp, oid *maxp, BUN *ngrpp, BUN *startp, BUN *endp, BUN *cntp,
+ const oid **candp, const oid **candendp);
diff --git a/monetdb5/modules/atoms/Makefile.ag
b/monetdb5/modules/atoms/Makefile.ag
--- a/monetdb5/modules/atoms/Makefile.ag
+++ b/monetdb5/modules/atoms/Makefile.ag
@@ -25,7 +25,7 @@ MTSAFE
lib_atoms = {
NOINST
SOURCES = \
- batxml.c batxml.h \
+ batxml.c \
blob.c blob.h \
color.c color.h \
identifier.c identifier.h \
diff --git a/monetdb5/modules/atoms/batxml.c b/monetdb5/modules/atoms/batxml.c
--- a/monetdb5/modules/atoms/batxml.c
+++ b/monetdb5/modules/atoms/batxml.c
@@ -40,9 +40,48 @@
}
#include "monetdb_config.h"
-#include "batxml.h"
+#include <gdk.h>
+#include "ctype.h"
+#include <string.h>
+#include <libxml/parser.h>
+#include "mal_interpreter.h"
+#include "mal_function.h"
+#include "xml.h"
-#include <libxml/parser.h>
+#ifdef WIN32
+#ifndef LIBATOMS
+#define batxml_export extern __declspec(dllimport)
+#else
+#define batxml_export extern __declspec(dllexport)
+#endif
+#else
+#define batxml_export extern
+#endif
+
+batxml_export str BATXMLxml2str(int *ret, int *bid);
+batxml_export str BATXMLxmltext(int *ret, int *bid);
+batxml_export str BATXMLstr2xml(int *x, int *s);
+batxml_export str BATXMLdocument(int *x, int *s);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list