Update of /cvsroot/monetdb/pathfinder/backends/monet5
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv30055
Modified Files:
Tag: M5XQ
Makefile.ag xquery.mx xquery_shredder.mx
Added Files:
Tag: M5XQ
xquery_serialize.mx
Log Message:
- add the serializer (finally), in the end opted to leave the code
for now in M4, just added the wrappers
- propagated some bugs that got lost in the shredder
U xquery.mx
Index: xquery.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/backends/monet5/Attic/xquery.mx,v
retrieving revision 1.4.2.1
retrieving revision 1.4.2.2
diff -u -d -r1.4.2.1 -r1.4.2.2
--- xquery.mx 26 Apr 2009 18:54:12 -0000 1.4.2.1
+++ xquery.mx 28 Apr 2009 00:30:00 -0000 1.4.2.2
@@ -36,22 +36,64 @@
@- XQuery shredder interface (xquery_shredder.mx)
@mal
command shred_url(doc:bat[:str,:bat], url:str, percentage:lng) :void
-address XQUERYShredURL
+address XQUERY_ShredURL
comment "Shred an XML document from a URL. Parameters: URL - document located
at this URL is shredded, percentage - a number [0,100] indicating the amount of
free space to reserve for updates (percentage=0 leads to a read-only document)"
command shred_str(doc:bat[:str,:bat], buffer:str, percentage:lng) : void
-address XQUERYShredStr
+address XQUERY_ShredStr
comment "Shred an XML document from a string. Parameters: buffer - the XML
string to shred, percentage - a number [0,100] indicating the amount of free
space to reserve for updates (percentage=0 leads to a read-only document)"
-
command shred_stream(doc:bat[:str,:bat], s:streams, percentage:lng) : void
-address XQUERYShredStream
+address XQUERY_ShredStream
comment "Shred an XML document from a stream. Parameters: s - XML input
stream, percentage - a number [0,100] indicating the amount of free space to
reserve for updates (percentage=0 leads to a read-only document)"
+
+...@- XML print functions (serialize.mx)
+...@mal
+command print_doc(genType:str, ws:bat[:oid,:bat], docname:str) : void
+address XQUERY_PrintDocMain
+comment "C interface to Workset print routine"
+
+command print_result(genType:str, ws:bat[:oid,:bat],
+ loop:bat[:oid,:any], iter:bat[:oid,:oid],
item:bat[:oid,:oid] item, kind:BAT[:oid,int],
+ int_values:bat[:oid,:lng], dbl_values:bat[:oid,:dbl],
str_values:bat[:oid,:str]) : void
+address XQUERY_PrintResultLoop
+comment "C interface to Workset result print routine, that can print multiple
iters"
+
+command print_result(genType:str, ws:bat[:oid,:bat],
+ loop:bat[:oid,:any], iter:bat[:oid,:oid],
item:bat[:oid,:oid] item, kind:BAT[:oid,int],
+ int_values:bat[:oid,:lng], dbl_values:bat[:oid,:dbl],
str_values:bat[:oid,:str],
+ xrpc_module:str, xrpc_method:str, xrpc_qid:str,
xrpc_caller:str, xrpc_mode:str,
+ xrpc_hostport:str, xrpc_updating:bit, xrpc_seqnr:lng,
xrpc_timeout:lng, xrpc_start:lng) : void
+address XQUERY_PrintResultXRPC
+comment "C interface to Workset result print routine, that can print multiple
iters"
+
+command print_result(genType:str, ws:bat[:oid,:bat],
+ item:bat[:oid,:oid] item, kind:BAT[:oid,int],
+ int_values:bat[:oid,:lng], dbl_values:bat[:oid,:dbl],
str_values:bat[:oid,:str]) : void
+address XQUERY_PrintResultMain
+comment "C interface to Workset result print routine"
+
+command print_result(file:str, genType:str, ws:bat[:oid,:bat],
+ item:bat[:oid,:oid] item, kind:BAT[:oid,int],
+ int_values:bat[:oid,:lng], dbl_values:bat[:oid,:dbl],
str_values:bat[:oid,:str]) : void
+address XQUERY_PrintResultFile
+comment "C interface to Workset result print routine, but print to a file"
+
+command fn_deep_eq(ws:bat[:oid,:bat],
+ litem:bat[:oid,:oid], lkind bat[:oid,:int],
+ ritem:bat[:oid,:oid], rkind:bat[:oid,:int]) :
bat[:oid,:bit]
+address XQUERY_fn_deep_eq
+command "C interface to fn:deep_eq() implementation using the serializer"
+
@h
#ifndef _XQUERY_H
#define _XQUERY_H
+#include "pf_config.h"
+#include <mal_exception.h>
+#include "temp.h" /* TEMPORY DEFINITIONS TO MAKE THE M42M5 WORK */
+
#define DEBUG_XQ
#ifdef WIN32
U Makefile.ag
Index: Makefile.ag
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/backends/monet5/Attic/Makefile.ag,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -d -r1.3 -r1.3.2.1
--- Makefile.ag 16 Apr 2009 11:26:50 -0000 1.3
+++ Makefile.ag 28 Apr 2009 00:30:00 -0000 1.3.2.1
@@ -30,9 +30,7 @@
lib__xquery = {
DIR = libdir/MonetDB5
- SOURCES = \
- xquery.mx temp.h \
- xquery_shredder.mx
+ SOURCES = xquery.mx temp.h xquery_shredder.mx xquery_serialize.mx
LIBS = \
$(PF_LIBS) \
$(MONETDB5_MODS) -l_optimizer -l_bat5 \
U xquery_shredder.mx
Index: xquery_shredder.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/backends/monet5/Attic/xquery_shredder.mx,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -d -r1.3 -r1.3.2.1
--- xquery_shredder.mx 21 Apr 2009 08:39:14 -0000 1.3
+++ xquery_shredder.mx 28 Apr 2009 00:30:00 -0000 1.3.2.1
@@ -43,18 +43,15 @@
#include "xquery.h"
/* MAL commands to shred XML from a {uri,string,stream} */
-xquery_export str XQUERYShredUrl(int retval, bat *doc, str location, lng
*percentage);
-xquery_export str XQUERYShredStr(int retval, bat *doc, str buffer, lng
*percentage);
-xquery_export str XQUERYShredStream(int retval, bat *doc, stream *s, lng
*percentage);
+xquery_export str XQUERY_ShredUrl(int retval, bat *doc, str location, lng
*percentage);
+xquery_export str XQUERY_ShredStr(int retval, bat *doc, str buffer, lng
*percentage);
+xquery_export str XQUERY_ShredStream(int retval, bat *doc, stream *s, lng
*percentage);
#endif /* _XQ_SHREDDER_H */
@c
-#include "pf_config.h"
-#include <mal_exception.h>
#include "xquery_shredder.h"
#include "libxml/parser.h" /* SAX parser interface(libxml2) */
#include "libxml/parserInternals.h"
-#include "temp.h" /* TEMPORY DEFINITIONS TO MAKE THE M42M5 WORK */
#include "serialize.h" /* for struct serializeFunStruct & struct XqueryCtx */
@@ -1536,10 +1533,10 @@
sb->bat->theap->free = sb->heapSize;
if (sb->heapBackup) {
/* restore internal hash table to pre-state */
- memcpy(sb->bat->theap->base, sb->heapBackup,
GDK_STRHASHTABLE*sizeof(var_t));
+ memcpy(sb->bat->theap->base, sb->heapBackup,
GDK_STRHASHTABLE*sizeof(stridx_t));
} else {
/* zap internal hash table. is not critical */
- memset(sb->bat->theap->base, 0,
GDK_STRHASHTABLE*sizeof(var_t));
+ memset(sb->bat->theap->base, 0,
GDK_STRHASHTABLE*sizeof(stridx_t));
}
}
shredBAT_setcount(sb, sb->abortSize);
@@ -1642,12 +1639,12 @@
if (sb->def->tailType == TYPE_str) {
sb->heapSize = sb->bat->theap->free;
if (GDK_ELIMDOUBLES(sb->bat->theap)) {
- sb->heapBackup = GDKmalloc(GDK_STRHASHTABLE*sizeof(var_t));
+ sb->heapBackup =
GDKmalloc(GDK_STRHASHTABLE*sizeof(stridx_t));
if (!sb->heapBackup) {
GDKerror("shredder_create: malloc failure\n");
return shredder_free(shredCtx,0);
}
- memcpy(sb->heapBackup, sb->bat->theap->base,
GDK_STRHASHTABLE*sizeof(var_t));
+ memcpy(sb->heapBackup, sb->bat->theap->base,
GDK_STRHASHTABLE*sizeof(stridx_t));
}
}
} else {
@@ -1987,7 +1984,7 @@
}
str
-XQUERYShredUrl (int retval, bat *doc, str location, lng *percentage)
+XQUERY_ShredUrl (int retval, bat *doc, str location, lng *percentage)
{
int res;
BAT *docBAT;
@@ -2000,6 +1997,7 @@
}
res = shred(docBAT, location, NULL, NULL, *percentage, NULL, NULL);
+ BBPreleaseref(*doc);
if (res == GDK_FAIL)
throw(XQUERY, "xquery.shred_url", "unable to shred the specified url");
@@ -2007,7 +2005,7 @@
}
str
-XQUERYShredStr (int retval, bat *doc, str buffer, lng *percentage)
+XQUERY_ShredStr (int retval, bat *doc, str buffer, lng *percentage)
{
int res;
BAT *docBAT;
@@ -2020,6 +2018,7 @@
}
res = shred(docBAT, NULL, buffer, NULL, *percentage, NULL, NULL);
+ BBPreleaseref(*doc);
if (res == GDK_FAIL)
throw(XQUERY, "xquery.shred_str",
@@ -2028,7 +2027,7 @@
}
str
-XQUERYShredStream (int retval, bat *doc, stream *s, lng *percentage)
+XQUERY_ShredStream (int retval, bat *doc, stream *s, lng *percentage)
{
int res;
BAT *docBAT;
@@ -2041,6 +2040,7 @@
}
res = shred(docBAT, NULL, NULL, s, *percentage, NULL, NULL);
+ BBPreleaseref(*doc);
if (res == GDK_FAIL)
throw(XQUERY, "xquery.shred_stream",
--- NEW FILE: xquery_serialize.mx ---
@' Copyright Notice:
@' -----------------
@'
@' The contents of this file are subject to the Pathfinder Public License
@' Version 1.1 (the "License"); you may not use this file except in
@' compliance with the License. You may obtain a copy of the License at
@' http://monetdb.cwi.nl/Legal/PathfinderLicense-1.1.html
@'
@' Software distributed under the License is distributed on an "AS IS"
@' basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
@' the License for the specific language governing rights and limitations
@' under the License.
@'
@' The Original Code is the Pathfinder system.
@'
@' The Original Code has initially been developed by the Database &
@' Information Systems Group at the University of Konstanz, Germany and
@' the Database Group at the Technische Universitaet Muenchen, Germany.
@' It is now maintained by the Database Systems Group at the Eberhard
@' Karls Universitaet Tuebingen, Germany. Portions created by the
@' University of Konstanz, the Technische Universitaet Muenchen, and the
@' Universitaet Tuebingen are Copyright (C) 2000-2005 University of
@' Konstanz, (C) 2005-2008 Technische Universitaet Muenchen, and (C)
@' 2008-2009 Eberhard Karls Universitaet Tuebingen, respectively. All
@' Rights Reserved.
@'
@f xquery_serialize
@a Peter Boncz
@t MAL serialize wrappers
@h
#ifndef _XQ_SERIALIZE_H
#define _XQ_SERIALIZE_H
#include "xquery.h"
/* MAL commands to serialize XML */
xquery_export str
XQUERY_PrintResultXRPC(
str mode,
bat* ws_batid,
bat* loop_batid,
bat* iter_batid,
bat* item_batid,
bat* kind_batid,
bat* intVAL_batid,
bat* dblVAL_batid,
bat* strVAL_batid,
/* xrpc response header things */
str xrpc_module,
str xrpc_method,
str xrpc_qid,
str xrpc_caller,
str xrpc_mode,
str xrpc_hostport,
bit *xrpc_updating,
lng *xrpc_seqnr,
lng *xrpc_timeout,
lng *xrpc_start);
xquery_export str
XQUERY_PrintResultLoop(
str mode,
bat* ws_batid,
bat* loop_batid,
bat* iter_batid,
bat* item_batid,
bat* kind_batid,
bat* intVAL_batid,
bat* dblVAL_batid,
bat* strVAL_batid);
xquery_export str
XQUERY_PrintResultMain(
str mode,
bat* ws_batid,
bat* item_batid,
bat* kind_batid,
bat* intVAL_batid,
bat* dblVAL_batid,
bat* strVAL_batid);
xquery_export str
XQUERY_PrintResultFile (
str file,
str mode,
bat* ws_batid,
oid* item,
int* kind,
bat* intVAL_batid,
bat* dblVAL_batid,
bat* strVAL_batid);
xquery_export str
XQUERY_PrintDocMain (
str mode,
bat* ws_batid,
str docName);
xquery_export str
XQUERY_fn_deep_eq(
bat* res_batid,
bat* ws_batid,
bat* litem_batid,
bat* lkind_batid,
bat* ritem_batid,
bat* rkind_batid);
#endif /* _XQ_SERIALIZE_H */
@c
#include "xquery_serialize.h"
#include "serialize.h"
/* the main MAL wrapper with all BAT fixing/Unfixing */
static str
XQUERY_PrintResult(
BUN niters,
str mode,
bat* ws_batid,
bat* loop_batid,
bat* iter_batid,
bat* item_batid,
bat* kind_batid,
bat* intVAL_batid,
bat* dblVAL_batid,
bat* strVAL_batid,
/* xrpc response header things */
str xrpc_module,
str xrpc_method,
str xrpc_qid,
str xrpc_caller,
str xrpc_mode,
str xrpc_hostport,
bit *xrpc_updating,
lng *xrpc_seqnr,
lng *xrpc_timeout,
lng *xrpc_start)
{
int ret = GDK_FAIL;
BAT* ws;
assert(ws_batid);
assert(loop_batid);
assert(iter_batid);
assert(item_batid);
assert(kind_batid);
assert(intVAL_batid);
assert(dblVAL_batid);
assert(strVAL_batid);
ws = BATdescriptor(*ws_batid);
if (ws) {
BAT* loop = BATdescriptor(*loop_batid);
if (loop) {
BAT* iter = BATdescriptor(*iter_batid);
if (niters == 0) niters = BATcount (loop);
if (iter) {
BAT* item = BATdescriptor(*item_batid);
if (item) {
BAT* kind = BATdescriptor(*kind_batid);
if (kind) {
BAT* intVAL = BATdescriptor(*intVAL_batid);
if (intVAL) {
BAT* dblVAL = BATdescriptor(*dblVAL_batid);
if (dblVAL) {
BAT* strVAL = BATdescriptor(*strVAL_batid);
if (strVAL) {
ret = xquery_print_result_DRIVER (
mode,
NULL, /* set of printing
callback function */
NULL, /* optional arguments for
the callback functions */
ws,
niters?niters:1, /* number of
iterations */
loop, /* loop relation */
iter, /* iter relation */
item, /* item relation */
kind, /* kind relation */
intVAL,
dblVAL,
strVAL,
xrpc_module,
xrpc_method,
xrpc_qid,
xrpc_caller,
xrpc_mode,
xrpc_hostport,
xrpc_updating,
xrpc_seqnr,
xrpc_timeout,
xrpc_start);
}
BBPreleaseref(*strVAL_batid);
}
BBPreleaseref(*dblVAL_batid);
}
BBPreleaseref(*intVAL_batid);
}
BBPreleaseref(*kind_batid);
}
BBPreleaseref(*item_batid);
}
BBPreleaseref(*iter_batid);
}
BBPreleaseref(*loop_batid);
}
BBPreleaseref(*ws_batid);
if (ret == GDK_FAIL)
throw(XQUERY, "xquery.print_result", "unable to print XML");
return MAL_SUCCEED;
}
str
XQUERY_PrintResultXRPC(
str mode,
bat* ws_batid,
bat* loop_batid,
bat* iter_batid,
bat* item_batid,
bat* kind_batid,
bat* intVAL_batid,
bat* dblVAL_batid,
bat* strVAL_batid,
/* xrpc response header things */
str xrpc_module,
str xrpc_method,
str xrpc_qid,
str xrpc_caller,
str xrpc_mode,
str xrpc_hostport,
bit *xrpc_updating,
lng *xrpc_seqnr,
lng *xrpc_timeout,
lng *xrpc_start)
{
assert(xrpc_module);
assert(xrpc_method);
assert(xrpc_qid);
assert(xrpc_caller);
assert(xrpc_mode);
assert(xrpc_hostport);
assert(xrpc_updating);
assert(xrpc_seqnr);
assert(xrpc_timeout);
assert(xrpc_start);
return XQUERY_PrintResult(0, mode,
ws_batid,
loop_batid,
iter_batid,
item_batid,
kind_batid,
intVAL_batid,
dblVAL_batid,
strVAL_batid,
xrpc_module,
xrpc_method,
xrpc_qid,
xrpc_caller,
xrpc_mode,
xrpc_hostport,
xrpc_updating,
xrpc_seqnr,
xrpc_timeout,
xrpc_start);
}
str
XQUERY_PrintResultLoop(
str mode,
bat* ws_batid,
bat* loop_batid,
bat* iter_batid,
bat* item_batid,
bat* kind_batid,
bat* intVAL_batid,
bat* dblVAL_batid,
bat* strVAL_batid)
{
return XQUERY_PrintResult(0,
mode,
ws_batid,
loop_batid, /* loop relation */
iter_batid, /* iter relation */
item_batid, /* item relation */
kind_batid, /* kind relation */
intVAL_batid,
dblVAL_batid,
strVAL_batid,
NULL, /* xrpc_module */
NULL, /* xrpc_method */
NULL, /* xrpc_qid */
NULL, /* xrpc_caller */
NULL, /* xrpc_mode */
NULL, /* xrpc_hostport */
NULL, /* xrpc_updating */
NULL, /* xrpc_seqnr */
NULL, /* xrpc_timeout */
NULL);/* xrpc_start */
}
str
XQUERY_PrintResultMain(
str mode,
bat* ws_batid,
bat* item_batid,
bat* kind_batid,
bat* intVAL_batid,
bat* dblVAL_batid,
bat* strVAL_batid)
{
return XQUERY_PrintResult(1,
mode,
ws_batid,
item_batid, /* loop relation */
item_batid, /* iter relation */
item_batid, /* item relation */
kind_batid, /* kind relation */
intVAL_batid,
dblVAL_batid,
strVAL_batid,
NULL, /* xrpc_module */
NULL, /* xrpc_method */
NULL, /* xrpc_qid */
NULL, /* xrpc_caller */
NULL, /* xrpc_mode */
NULL, /* xrpc_hostport */
NULL, /* xrpc_updating */
NULL, /* xrpc_seqnr */
NULL, /* xrpc_timeout */
NULL);/* xrpc_start */
}
str
XQUERY_PrintResultFile (
str file,
str mode,
bat* ws_batid,
oid* item,
int* kind,
bat* intVAL_batid,
bat* dblVAL_batid,
bat* strVAL_batid)
{
int ret = GDK_FAIL;
BAT *ws;
assert(file);
assert(mode);
assert(ws_batid);
assert(item);
assert(kind);
assert(intVAL_batid);
assert(dblVAL_batid);
assert(strVAL_batid);
ws = BATdescriptor(*ws_batid);
if (ws) {
BAT* intVAL = BATdescriptor(*intVAL_batid);
if (intVAL) {
BAT* dblVAL = BATdescriptor(*dblVAL_batid);
if (dblVAL) {
BAT* strVAL = BATdescriptor(*strVAL_batid);
if (strVAL) {
int len = strlen(file);
if (DIR_SEP != '/') {
char *s = file; /* normalize path on windows to windows
DIR_SEP */
do { if (*s == '/') *s = DIR_SEP; } while(*(++s));
}
if (*file == DIR_SEP) {
GDKerror("xquery_print_result_file: %s cannot have an
absolute name.\n", file);
} else if (len < 4 || (strcmp(file+len-4, ".xml") &&
strcmp(file+len-4, ".XML"))) {
GDKerror("xquery_print_result_file: %s name does not
end in .xml\n", file);
} else if (GDKcreatedir(file)) {
FILE *fp = fopen(file, "wb");
if (fp) {
stream *s = file_wastream(fp, file);
if (s) {
BAT* i = BATnew(TYPE_void,TYPE_oid,1);
if (i) {
BAT* k = BATnew(TYPE_void,TYPE_int,1);
if (k) {
BATseqbase(k, 0);
BATseqbase(i, 0);
BUNappend(k, kind, FALSE);
BUNappend(i, item, FALSE);
ret = xquery_print_result_driver (
s,
mode,
NULL, /* set of printing callback
function */
NULL, /* optional arguments for
the callback functions */
ws,
1, /* number of iterations */
i, /* loop relation */
i, /* iter relation */
i, /* item relation */
k, /* kind relation */
intVAL,
dblVAL,
strVAL,
NULL, /* xrpc_module */
NULL, /* xrpc_method */
NULL, /* xrpc_qid */
NULL, /* xrpc_caller */
NULL, /* xrpc_mode */
NULL, /* xrpc_hostport */
NULL, /* xrpc_updating */
NULL, /* xrpc_seqnr */
NULL, /* xrpc_timeout */
NULL);/* xrpc_start */
stream_destroy(s);
}
BBPreclaim(k);
}
BBPreclaim(i);
}
fclose(fp);
} else {
GDKsyserror("xquery_print_result_file: %s", file);
}
}
BBPreleaseref(*strVAL_batid);
}
BBPreleaseref(*dblVAL_batid);
}
BBPreleaseref(*intVAL_batid);
}
BBPreleaseref(*ws_batid);
}
if (ret == GDK_FAIL)
throw(XQUERY, "xquery.print_result", "unable to write XML to file");
return MAL_SUCCEED;
}
str
XQUERY_PrintDocMain (
str mode,
bat* ws_batid,
str docName)
{
int ret = GDK_FAIL;
BAT *ws;
assert(mode);
assert(ws_batid);
assert(docName);
ws = BATdescriptor(*ws_batid);
if (ws) {
ret = xquery_print_doc_DRIVER(mode,NULL,NULL,ws,docName);
BBPreleaseref(*ws_batid);
}
if (ret == GDK_FAIL)
throw(XQUERY, "xquery.print_doc", "unable to print XML document");
return MAL_SUCCEED;
}
xquery_export str
XQUERY_fn_deep_eq(
bat* res_batid,
bat* ws_batid,
bat* litem_batid,
bat* lkind_batid,
bat* ritem_batid,
bat* rkind_batid)
{
int ret = GDK_FAIL;
BAT *ws = BATdescriptor(*ws_batid);
if (ws) {
BAT *litem = BATdescriptor(*litem_batid);
if (litem) {
BAT *lkind = BATdescriptor(*lkind_batid);
if (lkind) {
BAT *ritem = BATdescriptor(*ritem_batid);
if (ritem) {
BAT *rkind = BATdescriptor(*rkind_batid);
if (rkind) {
BAT *resbat = NULL;
ret = do_fn_deep_eq(&resbat, ws, litem, lkind, ritem,
rkind);
if (ret == GDK_SUCCEED) {
*res_batid = resbat->batCacheid;
BBPkeepref(*res_batid);
}
BBPreleaseref(*rkind_batid);
}
BBPreleaseref(*ritem_batid);
}
BBPreleaseref(*lkind_batid);
}
BBPreleaseref(*litem_batid);
}
BBPreleaseref(*ws_batid);
}
if (ret == GDK_FAIL)
throw(XQUERY, "xquery.fn_deep_eq", "unable compare sequences");
return MAL_SUCCEED;
}
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins