Update of /cvsroot/monetdb/pathfinder/runtime5
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv32394/runtime5

Modified Files:
        Makefile.ag xquery.mx xquery_scenario.mx 
Log Message:
moved all serialization into a library libserialize
moved ll_* into library libpf

this is needed as this introduces the second (very very small) part of
the m5 runtime.

xquery.mx now has the functions

        xquery.doc
                    ( lookup rootid(s) as needed by the bind function)
        xquery.print
                    ( print function, still requires the m4 ws)
        xquery.ll_child
                    (simple wrapper of the m4 version)
        xquery.bind (bind a column using a document_idx (rootid) and
                        table and column names)

(this needs more work, but nayden needs it and I'm on holiday the coming
        week)

(beware this probably breaks windows compilation as some export's are missing)


Index: xquery.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime5/xquery.mx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- xquery.mx   9 Jan 2007 08:56:35 -0000       1.3
+++ xquery.mx   23 Feb 2007 12:51:43 -0000      1.4
@@ -28,6 +28,30 @@
 address XQUERYsession
 comment "Switch to processing XQUERY statements";
 
+command start2():void 
+address XQUERYsession2
+comment "Switch to processing pre-cooked XQUERY statements";
+
+command bind( rootid:oid, tname:str, cname:str ):bat[:oid,:any_1]
+address xquery_bind
+comment "Bind to the xquery column";
+
+command doc( iter:bat[:oid,:oid], name:bat[:oid,:str] ) 
+               (resiter:bat[:oid,:oid], root:bat[:oid,:oid])
+address xquery_doc
+comment "Find the document roots";
+
+command ll_child( iter:bat[:oid,:oid], ctx:bat[:oid,:oid], 
preSize:bat[:oid,:oid], preKind:bat[:oid,:oid], oneIter:bit, oneCtx:bit, 
minIter:oid, maxIter:oid, noIterOrder:bit, kindTest:chr):bat[:oid,:oid]
+address ll_child
+comment "Loop Lifted child step";
+
+command print(mode:str, ws:bat[:oid,:bat],
+       item:bat[:oid,:oid], kind:bat[:oid,:int],
+        int_values:bat[:oid,:lng], dbl_values:bat[:oid,:dbl],
+        dec_values:bat[:oid,:dbl], str_values:bat[:oid,:str]) :void
+address xquery_print_result_main_wrap
+comment "C interface to Workset result print routine";
+
 command prelude()
 address XQUERYprelude;
 
@@ -65,8 +89,146 @@
     xquery_inplace = 7
 } modes_xquery;
 
+xquery_export str xquery_doc( bat *resiter, bat *root, bat *iter, bat *name );
+xquery_export str xquery_bind( bat *res, oid *rootid, str *tname, str *cname 
/*, int access */ );
+xquery_export str ll_child( bat *res, bat *iter, bat *ctx, bat *preSize, bat 
*preKind, bit *oneIter, bit *oneCtx, oid *minIter, oid *maxIter, bit 
*noIterOrder, chr *kindTest);
+xquery_export str xquery_print_result_main_wrap(int *res /*dummy*/, str *mode, 
bat *ws, bat *item, bat *kind, bat *int_values, bat *dbl_values, bat 
*dec_values, bat *str_values); 
+
 #endif /* _XQUERY_H */
 
 @c
 #include "pf_config.h"
 #include "xquery.h"
+
+static BAT *
+BATfinddescriptor( str name ) 
+{
+       int bid = BBPindex(name);
+
+       if (bid != 0)
+               return BATdescriptor(bid);
+       return NULL;
+}
+
+/* loop lifted doc function, per iter find the rootid (if it exists) */
+str
+xquery_doc( bat *resiter, bat *root, bat *iter, bat *name )
+{
+       BAT *iterb, *nameb, *resiterb, *rootb;
+       BAT *doc_name, *doc_collection, *docids, *colids;
+
+       if( (iterb = BATdescriptor(*iter)) == NULL )
+               throw(MAL, "xquery.doc", "Cannot access (iter) descriptor");
+       if( (nameb = BATdescriptor(*name)) == NULL )
+               throw(MAL, "xquery.doc", "Cannot access (name) descriptor");
+       if ((doc_name = BATfinddescriptor("doc_name")) == NULL) 
+               throw(MAL, "xquery.doc", "Cannot access (doc_name) descriptor");
+       if ((doc_collection = BATfinddescriptor("doc_collection")) == NULL) 
+               throw(MAL, "xquery.doc", "Cannot access (doc_collection) 
descriptor");
+       docids = BATjoin( nameb, BATmirror(doc_name), BATcount(nameb));
+       colids = BATjoin( docids, doc_collection, BATcount(docids));
+       BBPunfix(docids->batCacheid);
+       
+       resiterb = BATmirror(BATmark(colids, 0));
+       rootb = BATmirror(BATmark(BATmirror(colids), 0));
+
+       BBPkeepref(*resiter = resiterb->batCacheid);
+       BBPkeepref(*root = rootb->batCacheid);
+       BBPunfix(doc_collection->batCacheid);
+       BBPunfix(doc_name->batCacheid);
+       BBPunfix(*iter);
+       BBPunfix(*name);
+       return MAL_SUCCEED;
+}
+
+str
+xquery_bind( bat *res, oid *rootid, str *Tname, str *cname /*, int access */ )
+{
+       char name[BUFSIZ+1];
+       char *tname = *Tname;
+
+       /* for readonly tables pre==rid (and currently we only have readonly) */
+       if (strcmp(tname, "pre") == 0)
+               tname = "rid";
+
+       snprintf(name, BUFSIZ, SSZFMT "_%s_%s", *rootid, tname, *cname);
+
+       *res = BBPindex(name);
+       if (!*res) {
+               *res = bat_nil;
+               throw(MAL, "xquery.bind", "xquery column (%s,%s) for document 
(" OIDFMT ") not found\n", tname, *cname, *rootid);
+       }
+       BBPincref(*res, TRUE);
+       return MAL_SUCCEED;
+}
+
+extern int PFll_child(BAT** res, BAT* iter, BAT* ctx, BAT* pre_size, BAT* 
cands, bit* one_iter, bit* one_ctx, oid* min_iter, oid* max_iter, bit* 
no_iter_order, chr* kind_test);
+
+str
+ll_child( bat *res, bat *iter, bat *ctx, bat *preSize, bat *preKind, bit 
*oneIter, bit *oneCtx, oid *minIter, oid *maxIter, bit *noIterOrder, chr 
*kindTest)
+{
+       BAT *resb, *iterb, *ctxb, *preSizeB, *preKindB; 
+
+       if( (iterb = BATdescriptor(*iter)) == NULL )
+               throw(MAL, "xquery.ll_child", "Cannot access (iter) 
descriptor");
+       if( (ctxb = BATdescriptor(*ctx)) == NULL )
+               throw(MAL, "xquery.ll_child", "Cannot access (ctx) descriptor");
+       if( (preSizeB = BATdescriptor(*preSize)) == NULL )
+               throw(MAL, "xquery.ll_child", "Cannot access (preSize) 
descriptor");
+       if( (preKindB = BATdescriptor(*preKind)) == NULL )
+               throw(MAL, "xquery.ll_child", "Cannot access (preKind) 
descriptor");
+       if (PFll_child(&resb, iterb, ctxb, preSizeB, preKindB, oneIter, oneCtx, 
minIter, maxIter, noIterOrder, kindTest) == GDK_FAIL) 
+               throw(MAL, "xquery.ll_child", "failed");
+       BBPunfix(*iter);
+       BBPunfix(*ctx);
+       BBPunfix(*preSize);
+       BBPunfix(*preKind);
+       BBPkeepref(*res = resb->batCacheid);
+       return MAL_SUCCEED;
+}
+
+extern int
+xquery_print_result_main (
+    str  mode,
+    BAT* ws,
+    BAT* item, 
+    BAT* kind,
+    BAT* intVAL,
+    BAT* dblVAL,
+    BAT* decVAL,
+    BAT* strVAL);
+
+str
+xquery_print_result_main_wrap(int *res /*dummy*/, str *mode, bat *ws, bat 
*item, bat *kind,  bat *int_values, bat *dbl_values, bat *dec_values, bat 
*str_values)
+{
+       BAT *wsb, *itemb, *kindb, *intb, *dblb, *decb, *strb;
+
+       
+       if( (wsb = BATdescriptor(*ws)) == NULL )
+               throw(MAL, "xquery.print", "Cannot access (ws) descriptor");
+       if( (itemb = BATdescriptor(*item)) == NULL )
+               throw(MAL, "xquery.print", "Cannot access (item) descriptor");
+       if( (kindb = BATdescriptor(*kind)) == NULL )
+               throw(MAL, "xquery.print", "Cannot access (kind) descriptor");
+       if( (intb = BATdescriptor(*int_values)) == NULL )
+               throw(MAL, "xquery.print", "Cannot access (int_values) 
descriptor");
+       if( (dblb = BATdescriptor(*dbl_values)) == NULL )
+               throw(MAL, "xquery.print", "Cannot access (dbl_values) 
descriptor");
+       if( (decb = BATdescriptor(*dec_values)) == NULL )
+               throw(MAL, "xquery.print", "Cannot access (dec_values) 
descriptor");
+       if( (strb = BATdescriptor(*str_values)) == NULL )
+               throw(MAL, "xquery.print", "Cannot access (str_values) 
descriptor");
+       
+       if (xquery_print_result_main(*mode, wsb, itemb, kindb, intb, dblb, 
decb, strb) == GDK_FAIL) {
+               throw(MAL, "xquery.print", "print failed");
+       }
+       BBPunfix(*ws);
+       BBPunfix(*item);
+       BBPunfix(*kind);
+       BBPunfix(*int_values);
+       BBPunfix(*dbl_values);
+       BBPunfix(*dec_values);
+       BBPunfix(*str_values);
+       (void)res;
+       return MAL_SUCCEED;
+}

Index: Makefile.ag
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime5/Makefile.ag,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Makefile.ag 12 Jan 2007 14:04:20 -0000      1.4
+++ Makefile.ag 23 Feb 2007 12:51:43 -0000      1.5
@@ -23,7 +23,7 @@
 # Universitaet Muenchen, respectively.  All Rights Reserved.
 #
 
-INCLUDES = $(MONETDB5_INCS) $(MONETDB_INCS) $(LIBXML2_CFLAGS) 
../compiler/include
+INCLUDES = $(MONETDB5_INCS) $(MONETDB_INCS) $(LIBXML2_CFLAGS) 
../compiler/include ../runtime
 PF_LIBS = $(LIBXML2_LDADD) $(LIBXML2_LIBS) $(DL_LIBS)
 
 lib__xquery = {
@@ -35,6 +35,7 @@
         LIBS = \
                 $(PF_LIBS) \
                 $(MONETDB5_MODS) -l_optimizer -l_bat5 \
+               ../runtime/libserialize ../runtime/libpf \
                $(MONETDB_LIBS) -lmal -lbat -lstream $(READLINE_LIBS) 
$(PTHREAD_LIBS)
 }
 

Index: xquery_scenario.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime5/xquery_scenario.mx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- xquery_scenario.mx  17 Jan 2007 08:17:16 -0000      1.5
+++ xquery_scenario.mx  23 Feb 2007 12:51:43 -0000      1.6
@@ -30,6 +30,7 @@
 /* #define _XQUERY_PARSER_DEBUG */
 
 xquery_export str XQUERYsession(str *ret);
+xquery_export str XQUERYsession2(str *ret);
 xquery_export str XQUERYprelude(void);
 xquery_export str XQUERYepilogue(void);
 
@@ -63,11 +64,21 @@
 }
 
 str
+XQUERYsession2(str *ret)
+{
+       str msg = MAL_SUCCEED;
+
+       msg = setScenario(MCgetClient(), "mxquery");
+       *ret = 0;
+       return msg;
+}
+
+str
 XQUERYprelude()
 {
        Scenario s = getFreeScenario();
        if (!s)
-               return NULL; /* should be an error */
+               throw(MAL, "xquery.start", "out of scenario slots");
        s->name = "xquery";
        s->language = "xq";
        s->initSystem = "XQUERYinit";
@@ -80,6 +91,21 @@
        /* s->tactics = .. */
        s->engine = "XQUERYengine";
 
+       s = getFreeScenario();
+       if (!s)
+               throw(MAL, "xquery.start", "out of scenario slots");
+
+       s->name = "mxquery";
+       s->language = "xq";
+       s->initSystem = "XQUERYinit";
+       s->exitSystem = "XQUERYexit";
+       s->initClient = "XQUERYinitClient";
+       s->exitClient = "XQUERYexitClient";
+       s->reader = "MALreader";
+       s->parser = "MALparser";
+       s->optimizer = "MALoptimizer";
+       /* s->tactics = .. */
+       s->engine = "MALengine";
        return MAL_SUCCEED;
 }
 str


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to