Update of /cvsroot/monetdb/MonetDB5/src/modules/mal
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6644/src/modules/mal
Modified Files:
Tag: GDK-2
batxml.mx clients.mx
Log Message:
propagated changes of Thursday Sep 06 2007 - Monday Sep 10 2007
from the development trunk to the GDK-2 branch
Index: clients.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/modules/mal/clients.mx,v
retrieving revision 1.67.2.1
retrieving revision 1.67.2.2
diff -u -d -r1.67.2.1 -r1.67.2.2
--- clients.mx 6 Sep 2007 13:52:38 -0000 1.67.2.1
+++ clients.mx 10 Sep 2007 14:26:51 -0000 1.67.2.2
@@ -66,13 +66,17 @@
address CLTLogin
comment "Pseudo bat of client login time.";
+command getLastCommand( ):bat[:int,:str]
+address CLTLastCommand
+comment "Pseudo bat of client's last command time.";
+
command getActions( ):bat[:int,:int]
address CLTActions
-comment "Pseudo bat of client command counts.";
+comment "Pseudo bat of client's command counts.";
command getTime( ):bat[:int,:lng]
address CLTTime
-comment "Pseudo bat of client total time usage(in usec).";
+comment "Pseudo bat of client's total time usage(in usec).";
command getUsers( ):bat[:int,:str]
address CLTusers
@@ -125,6 +129,7 @@
clients_export str CLTexit(int *ret);
clients_export str CLTquit(int *ret);
clients_export str CLTLogin(int *ret);
+clients_export str CLTLastCommand(int *ret);
clients_export str CLTActions(int *ret);
clients_export str CLTTime(int *ret);
clients_export str CLTInfo(int *ret);
@@ -288,6 +293,28 @@
@:Pseudo(client,login,)@
return MAL_SUCCEED;
}
+
+str
+CLTLastCommand(int *ret)
+{
+ BAT *b = BATnew(TYPE_int, TYPE_str, 12);
+ int i;
+ char s[26];
+
+ if (b == 0)
+ throw(MAL, "clients.getLastCommand", "failed to create BAT");
+ for (i = 0; i < MAL_MAXCLIENTS; i++) {
+ Client c = mal_clients+i;
+ if (c->mode >= CLAIMED && c->user != oid_nil) {
+ CLTtimeConvert((time_t) c->lastcmd,s);
+ BUNins(b, &i, s, FALSE);
+ }
+ }
+ if (!(b->batDirty&2)) b = BATsetaccess(b, BAT_READ);
+ @:Pseudo(client,lastcommand,)@
+ return MAL_SUCCEED;
+}
+
str
CLTActions(int *ret)
{
Index: batxml.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/modules/mal/batxml.mx,v
retrieving revision 1.4.2.5
retrieving revision 1.4.2.6
diff -u -d -r1.4.2.5 -r1.4.2.6
--- batxml.mx 6 Sep 2007 13:52:37 -0000 1.4.2.5
+++ batxml.mx 10 Sep 2007 14:26:51 -0000 1.4.2.6
@@ -104,7 +104,11 @@
address BATXMLforest
comment "Construct an element list";
-command xml.agg(grp:bat[:oid,:oid],val:bat[:oid,:xml]):bat[:oid,:xml]
+command
xml.agg(val:bat[:oid,:xml],grp:bat[:oid,:oid],e:bat[:oid,:any_1]):bat[:oid,:xml]
+address BATXMLagg3
+comment "Aggregate the XML values over grouping specified";
+
+command xml.agg(val:bat[:oid,:xml],grp:bat[:oid,:oid]):bat[:oid,:xml]
address BATXMLagg
comment "Aggregate the XML values over grouping specified";
@@ -168,7 +172,8 @@
batxml_export str BATXMLelement(int *ret, str *name, str *ns, str *attr, int
*bid);
batxml_export str BATXMLconcat(int *ret, int *bid, int *rid);
batxml_export str BATXMLforest(MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
-batxml_export str BATXMLagg(int *ret, int *grp,int *bid);
+batxml_export str BATXMLagg(int *ret, int *bid, int *grp);
+batxml_export str BATXMLagg3(int *ret, int *bid, int *grp, int *e);
batxml_export str BATXMLgroup(int *ret, int *bid);
#endif /* _BATXML_H_ */
@c
@@ -724,7 +729,83 @@
}
str
-BATXMLagg(int *ret, int *grp,int *bid)
+BATXMLagg3(int *ret, int *bid,int *grp, int *ext)
+{
+ BAT *j, *r, *g, *b, *bn, *e;
+ BUN p,q;
+ int xx;
+ oid gid = 0,o=0;
+ int first= 1;
+ str t;
+ str buf= GDKmalloc(BUFSIZ);
+ int len, size=BUFSIZ,offset;
+
+ @:getBATdescriptor(ext,e,"xml.agg")@
+ @:getBATdescriptor(grp,g,"xml.agg",BBPunfix(e->batCacheid))@
+
@:getBATdescriptor(bid,b,"xml.agg",BBPunfix(e->batCacheid);BBPunfix(g->batCacheid))@
+
+ bn= BATnew(TYPE_oid, b->ttype,BATcount(e));
+ if( bn== NULL){
+ BBPunfix(b->batCacheid);
+ BBPunfix(g->batCacheid);
+ BBPunfix(e->batCacheid);
+ throw(MAL,"xml.agg","Could not create BAT");
+ }
+
+ /* this will not work as it will corrupt the order of the column, ie
+ the order in which the data will be generated */
+ j= BATjoin(BATmirror(g),b,oid_nil);
+ r= BATsort(j);
+
+ /* now we can perform a simple scan and emit the group*/
+
+ buf[0]=0;
+ offset=0;
+ first=1;
+ BATloopFast(r,p,q,xx){
+ o= *(oid*) BUNhead(r,p);
+ t= (str) BUNtail(r,p);
+
+ if( gid != o && first==0){
+ /* flush */
+ bunfastins(bn,&gid,buf);
+ buf[0]=0;
+ offset =0;
+ }
+ gid=o;
+ first=0;
+ len= strlen(t)+1;
+ if( len >= size-offset){
+ if(buf) GDKfree(buf);
+ buf= GDKrealloc(buf,size+len);
+ size= size+len;
+ }
+ snprintf(buf+offset,size-offset,"%s",t);
+ offset+= len-1;
+ }
+ /* end the leftover element */
+ if( first ==0)
+ bunfastins(bn,&gid,buf);
+
+ BBPunfix(r->batCacheid);
+ BBPunfix(j->batCacheid);
+ GDKfree(buf);
+ BBPunfix(e->batCacheid);
+ BBPunfix(g->batCacheid);
+ BBPunfix(b->batCacheid);
+ BBPkeepref(*ret=bn->batCacheid);
+ return MAL_SUCCEED;
+bunins_failed:
+ BBPunfix(e->batCacheid);
+ BBPunfix(g->batCacheid);
+ BBPunfix(b->batCacheid);
+ BBPunfix(bn->batCacheid);
+ GDKfree(buf);
+ throw(MAL, "xml.agg", "bunins failed");
+}
+
+str
+BATXMLagg(int *ret, int *bid,int *grp)
{
BAT *j, *r, *g, *b, *bn;
BUN p,q;
@@ -745,8 +826,9 @@
throw(MAL,"xml.agg","Could not create BAT");
}
- j= BATjoin(g,b,oid_nil);
- r= BATsort(j);
+ j= BATjoin(BATmirror(g),b,oid_nil);
+ r= BATsort(j);
+
/* now we can perform a simple scan and emit the group*/
buf[0]=0;
@@ -755,6 +837,7 @@
BATloopFast(r,p,q,xx){
o= *(oid*) BUNhead(r,p);
t= (str) BUNtail(r,p);
+
if( gid != o && first==0){
/* flush */
bunfastins(bn,&gid,buf);
@@ -794,12 +877,21 @@
{
BAT *b, *g;
str msg= MAL_SUCCEED;
- oid o= oid_nil;
+ oid o= 0;
+ BUN p,q;
+ int xx;
@:getBATdescriptor(bid,b,"xml.group")@
- g= BATmirror(BATconst(b,TYPE_oid,(ptr) &o));
- msg= BATXMLagg(ret,&g->batCacheid,bid);
+
+ g= BATnew(BAThtype(b),TYPE_oid,BATcount(b));
+ BATloopFast(b, p, q, xx) {
+ ptr v = BUNhead(b,p);
+ bunfastins(g,v, &o);
+ }
+ msg= BATXMLagg(ret,bid,&g->batCacheid);
+ bunins_failed:
BBPunfix(g->batCacheid);
+ BBPunfix(b->batCacheid);
return msg;
}
str
@@ -813,3 +905,6 @@
}
@}
+
[EMAIL PROTECTED]
+CREATE AGGREGATE "xmlagg"( x xml ) RETURNS xml external name xml.agg;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins