Update of /cvsroot/monetdb/MonetDB5/src/modules/mal
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22749/src/modules/mal

Modified Files:
      Tag: GDK-2
        batxml.mx bpm.mx 
Log Message:
propagated changes of Tuesday Aug 28 2007 - Monday Sep 03 2007
from the development trunk to the GDK-2 branch


Index: bpm.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/modules/mal/bpm.mx,v
retrieving revision 1.118.2.3
retrieving revision 1.118.2.4
diff -u -d -r1.118.2.3 -r1.118.2.4
--- bpm.mx      17 Aug 2007 15:36:57 -0000      1.118.2.3
+++ bpm.mx      3 Sep 2007 13:08:19 -0000       1.118.2.4
@@ -108,9 +108,10 @@
 is translated to the plan:
 @example
        bpm.open();
-       R0:bat[:oid,:int]:= bpm.take("myversion", nil:oid,nil:oid, 0,100);
-       R1:bat[:oid,:int]:= bpm.take("myversion", nil:oid,nil:oid, 101,200);
-       R2:bat[:oid,:int]:= bpm.take("myversion", nil:oid,nil:oid, 201,nil:int);
+       R:bat[:oid,:int]:= bpm.take("myversion"); # get the partition alias
+       R0:bat[:oid,:int]:= bpm.take(R,0, nil:oid,nil:oid, 0,100);
+       R1:bat[:oid,:int]:= bpm.take(R,1, nil:oid,nil:oid, 101,200);
+       R2:bat[:oid,:int]:= bpm.take(R,2, nil:oid,nil:oid, 201,nil:int);
        R:= mat.new(R0,R1,R2);
        T:= algebra.select(R,0,100);
        optimizer.multitable();
@@ -335,13 +336,21 @@
 comment "Re-organize segment s using the selection (val1,val2) stored in bat 
rs";
 
 
+command take(pb:int):bat[:any_1,:any_2]
+address BPMtakeIndexed
+comment "Retrieve the partition given the its index ";
 command take(pb:str):bat[:any_1,:any_2]
 address BPMtake
 comment "Retrieve the alias given the name of a partitioned BAT";
+
 command take(nme:str, hl:any_1, hh:any_1, tl:any_2, th:any_2) 
:bat[:any_1,:any_2]
 address BPMtakePartition
 comment "Retrieve a single component of a partitioned BAT by index";
 
+command take(nme:bat[:any_1,:any_2],idx:int, hl:any_1, hh:any_1, tl:any_2, 
th:any_2) :bat[:any_1,:any_2]
+address BPMtakePartitionIndexed
+comment "Retrieve a single component of a partitioned BAT by index";
+
 command insert(pb:bat[:any_1,:any_2],b:bat[:any_1,:any_2]) :void
 address BPMinsert
 comment "Insert elements into the BAT partitions";
@@ -529,10 +538,12 @@
 bpm_export str BPMadapt(bat *ret, bat *bid, ptr low, ptr hgh, bat *rs, int 
*pol);
 bpm_export str BPMoracle(bat *ret, bat *bid, ptr low, ptr hgh, bat *rs );
 
+bpm_export str BPMtakeIndexed(bat *ret, int *nme);
 bpm_export str BPMtake(bat *ret, str *nme);
 bpm_export str BPMtakePartition(bat *ret, str *nme, ptr *hl, ptr *hh, ptr *tl, 
ptr *th);
+bpm_export str BPMtakePartitionIndexed(bat *ret, int *bid, int *idx, ptr *hl, 
ptr *hh, ptr *tl, ptr *th);
 
-bpm_export str BPMexpand(MalBlkPtr mb, int alias);
+bpm_export str BPMexpand(MalBlkPtr mb, int varid, int bid);
 
 bpm_export str BPMunfold(bat *ret, bat *bid);
 bpm_export str BPMfold(int *ret, bat *src);
@@ -2084,6 +2095,15 @@
 Takeing out partitions.
 @c
 str
+BPMtakeIndexed(bat *ret, int *nme)
+{
+       BAT *b= BATdescriptor(*nme);
+       if( b==0 )
+               throw(MAL,"bpm.take","BAT partition  does not exist");
+       BBPkeepref(*ret= b->batCacheid);
+       return MAL_SUCCEED;
+}
+str
 BPMtake(bat *ret, str *nme)
 {
        Partition p;
@@ -2097,50 +2117,56 @@
 str
 BPMtakePartition(bat *ret, str *nme, ptr *hl, ptr *hh, ptr *tl, ptr *th)
 {
-       int i,j;
        Partition p;
-       str msg= MAL_SUCCEED;
+       int index=0;
 
        BPMopen();
        p= getByName(*nme);
        if( p== 0)
                throw(MAL,"bpm.take","Partitioned BAT does not exist");
+       return BPMtakePartitionIndexed(ret,&p->alias, &index,hl,hh,tl,th);
+}
 
-       for(j=1,i=bpmcat[p->alias]->nxt; 
-               i!= p->alias ; 
-               i= bpmcat[i]->nxt){
-                       /* determine matching partition */
-                       (void) hl;
-                       (void) hh;
-                       (void) tl;
-                       (void) th;
-                       if( (msg=materializePartition(bpmcat[i])) )
-                               return msg; 
-                       j++;
-       }
-       *ret =i;
-       throw(MAL,"bpm.takePartition","not yet implemented");
+str
+BPMtakePartitionIndexed(bat *ret, int *bid, int *idx, ptr *hl, ptr *hh, ptr 
*tl, ptr *th)
+{
+       /* for the time being assume that the index is correct */
+       BAT *b= BATdescriptor(*bid);
+       if( b== NULL)
+               throw(MAL,"bpm.take","Could not access partition");
+       (void) idx;
+       (void) hl;
+       (void) hh;
+       (void) tl;
+       (void) th;
+       BBPkeepref(*ret= b->batCacheid);
+       return MAL_SUCCEED;
 }
 @-
 The Mergetable optimizer may request a list of fragments
 to be included.
 @c
 str
-BPMexpand(MalBlkPtr mb, int alias){
+BPMexpand(MalBlkPtr mb, int varid, int bid){
        Partition p;
        InstrPtr q;
-       int i;
+       int i,fragment=0;
 
-       BPMunfold( &i, &alias);
-       p= getByNumber(alias);
-       if( p==0)
-               return MAL_SUCCEED;
+       /* fake the partitioned version */
+       BPMunfold( &i, &bid);
+       p= getByNumber(bid);
        
+       if(p)
        for(i= p->nxt ; i!=p->bid && bpmcat[i] ; i= bpmcat[i]->nxt) {
                q = newStmt(mb,"bpm","take");
-               setVarType(mb, getArg(q,0), p->type);
-               pushInt(mb,q,alias);
-               pushInt(mb,q,i);
+               q=pushArgument(mb,q,varid);
+               /* add the fragmentation dimension properties */
+               q=pushInt(mb,q,fragment);
+               q=pushValue(mb,q,&p->hlow);
+               q=pushValue(mb,q,&p->hhgh);
+               q=pushValue(mb,q,&p->tlow);
+               q=pushValue(mb,q,&p->thgh);
+               fragment++;
        }
        return MAL_SUCCEED;
 }
@@ -3136,6 +3162,7 @@
        }
        return MAL_SUCCEED;
 }
+
 str
 BPMprelude(int *ret)
 {

Index: batxml.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/modules/mal/batxml.mx,v
retrieving revision 1.4.2.3
retrieving revision 1.4.2.4
diff -u -d -r1.4.2.3 -r1.4.2.4
--- batxml.mx   28 Aug 2007 13:15:26 -0000      1.4.2.3
+++ batxml.mx   3 Sep 2007 13:08:18 -0000       1.4.2.4
@@ -86,20 +86,15 @@
 
 command xml.element(name:str, s:bat[:oid,:xml]) :bat[:oid,:xml]
 address BATXMLtag
-comment "The basic building block for XML elements are namespaces, 
-attributes and a sequence of xml elements. The name space and 
-the attributes may be left unspecified."; 
+comment "The basic building block for XML elements are namespaces, attributes 
and a sequence of xml elements. The name space and the attributes may be left 
unspecified."; 
 
 command xml.options(tag:str, option:str,left:bat[:oid,:xml]):bat[:oid,:xml]
 address BATXMLoptions
 comment "Create the components including NULL conversions";
 
-
 command xml.element(name:str, ns:xml, attr:xml, 
s:bat[:oid,:xml]):bat[:oid,:xml]
 address BATXMLelement
-comment "The basic building block for XML elements are namespaces, 
-attributes and a sequence of xml elements. The name space and the 
-attributes may be left unspecified(=nilt).";
+comment "The basic building block for XML elements are namespaces, attributes 
and a sequence of xml elements. The name space and the attributes may be left 
unspecified(=nilt).";
 
 command xml.concat(left:bat[:oid,:xml],right:bat[:oid,:xml] ):bat[:oid,:xml]
 address BATXMLconcat
@@ -107,7 +102,7 @@
 
 pattern xml.forest(val:bat[:oid,:xml]...):bat[:oid,:xml]
 address BATXMLforest
-comment "Construct an element list");
+comment "Construct an element list";
 
 command xml.agg(grp:bat[:oid,:oid],val:bat[:oid,:xml]):bat[:oid,:xml]
 address BATXMLagg
@@ -117,14 +112,17 @@
 address BATXMLgroup
 comment "Aggregate the XML values over grouping specified";
 
-
 command xml.root(val:bat[:oid,:xml], version:str, 
standalone:str):bat[:oid,:xml]
 address BATXMLroot
 comment "Contruct the root nodes";
 
 command xml.isdocument(val:bat[:oid,:str]):bat[:oid,:bit]
 address BATXMLisdocument
-comment "Validate the string as a document"
+comment "Validate the string as a document";
+
+module batcalc;
+command xml(src:bat[:oid,:str]):bat[:oid,:xml] address BATXMLstr2xml;
+
 @{
 @include ../kernel/kprelude.mx
 
@@ -246,40 +244,40 @@
        int elm,len,size= BUFSIZ;
 
        prepareOperand(b,bid,"str");
-       prepareResult(bn,b,TYPE_str,"str");
+       prepareResult(bn,b,TYPE_xml,"str");
        BATloopFast(b,p,q,xx){
                ptr h= BUNhead(b,p);
                str t= (str) BUNtail(b,p);
                if( (elm=BATXMLcountEscape(t)) ){
                        if( (len=strlen(t)+6*elm+1) >= size){
+                               assert(0);
                                buf= GDKrealloc(buf, len);
                                size= len;
                        }
-                       for(s=buf ; *t; t++)
+                       for(s=buf, *s=0; *t; t++)
                        if (*t == '&'){
-                               strcat(s,"&"); 
-                               while(*s) s++;
+                               *s++ = '&'; *s++ = 'a'; *s++ = 'm'; *s++ = 'p';
+                               *s++ = ';';
                        } else if (*t == '<'){
-                               strcat(s,"&lt;"); 
-                               while(*s) s++;
+                               *s++ = '&'; *s++ = 'l'; *s++ = 't'; *s++ = ';';
                        } else if (*t == '>'){
-                               strcat(s,"&gt;");
-                               while(*s) s++;
-                       }else if (*t == '"'){
-                               strcat(s,"&quot;");
-                               while(*s) s++;
+                               *s++ = '&'; *s++ = 'g'; *s++ = 't'; *s++ = ';';
+                       } else if (*t == '"'){
+                               *s++ = '&'; *s++ = 'q'; *s++ = 'u'; *s++ = 'o';
+                               *s++ = 't'; *s++ = ';';
                        } else if (*t == '\''){
-                               strcat(s,"&apos;");
-                               while(*s) s++;
+                               *s++ = '&'; *s++ = 'a'; *s++ = 'p'; *s++ = 'o';
+                               *s++ = 's'; *s++ = ';';
                        } else if ((*t & 0xFF) < 0x20){
-                               sprintf(s, "&#%d;", *t & 0xFF);
-                               while(*s) s++;
-                       } else
+                               s+=sprintf(s, "&#%d;", *t & 0xFF);
+                       } else {
                                *s++= *t;
+                       }
                        *s=0;
                        bunfastins(bn,h,buf);
-               } else 
+               } else {
                        bunfastins(bn,h,t);
+               }
        }
        GDKfree(buf);
        finalizeResult(ret,bn,b);
@@ -326,7 +324,7 @@
        int tlen= strlen(*name)+2, len, size= BUFSIZ;
 
        prepareOperand(b,bid,"tag");
-       prepareResult(bn,b,TYPE_str,"tag");
+       prepareResult(bn,b,TYPE_xml,"tag");
        snprintf(buf,size,"<%s>",*name);
 
        BATloopFast(b,p,q,xx){
@@ -372,7 +370,7 @@
        int size= BUFSIZ, len=strlen(*name);
 
        prepareOperand(b,bid,"options");
-       prepareResult(bn,b,TYPE_str,"options");
+       prepareResult(bn,b,TYPE_xml,"options");
 
        if( strcmp(*options,"abscent")==0)
                buf[0]=0;
@@ -424,7 +422,7 @@
        int len,size= BUFSIZ;
 
        prepareOperand(b,bid,"comment");
-       prepareResult(bn,b,TYPE_str,"comment");
+       prepareResult(bn,b,TYPE_xml,"comment");
        BATloopFast(b,p,q,xx){
                ptr h= BUNhead(b,p);
                str t= (str) BUNtail(b,p);
@@ -453,7 +451,7 @@
        int xx;
 
        prepareOperand(b,bid,"parse");
-       prepareResult(bn,b,TYPE_str,"parse");
+       prepareResult(bn,b,TYPE_xml,"parse");
        BATloopFast(b,p,q,xx){
        }
        finalizeResult(ret,bn,b);
@@ -469,7 +467,7 @@
 
        (void) operator;
        prepareOperand(b,bid,"pi");
-       prepareResult(bn,b,TYPE_str,"pi");
+       prepareResult(bn,b,TYPE_xml,"pi");
        BATloopFast(b,p,q,xx){
        }
        finalizeResult(ret,bn,b);
@@ -486,7 +484,7 @@
        int len,size= BUFSIZ;
 
        prepareOperand(b,bid,"root");
-       prepareResult(bn,b,TYPE_str,"root");
+       prepareResult(bn,b,TYPE_xml,"root");
 
        len= strlen(*version)+strlen(*standalone)+
                        strlen("<? version=\"\" standalone=\"\"?>");
@@ -521,7 +519,7 @@
        int len,size= BUFSIZ;
 
        prepareOperand(b,bid,"attribute");
-       prepareResult(bn,b,TYPE_str,"attribute");
+       prepareResult(bn,b,TYPE_xml,"attribute");
        BATloopFast(b,p,q,xx){
                ptr h= BUNhead(b,p);
                str t= (str) BUNtail(b,p);
@@ -559,7 +557,7 @@
        if( b== NULL)
                throw(MAL,"xml.element","Can not access BAT");
 
-       prepareResult(bn,b,TYPE_str,"element");
+       prepareResult(bn,b,TYPE_xml,"element");
 
        BATloopFast(b,p,q,xx){
                str t= (str) BUNtail(b,p);
@@ -631,7 +629,7 @@
                throw(MAL,"xml.forest","Can not access BAT");
        }
 
-       prepareResult(bn,b[pci->retc],TYPE_str,"attribute");
+       prepareResult(bn,b[pci->retc],TYPE_xml,"attribute");
 
        while(p[pci->retc] < q[pci->retc]){
                str t;
@@ -696,7 +694,7 @@
                throw(MAL,"xml.concat","Can not access BAT");
        }
 
-       prepareResult(bn,b,TYPE_str,"concat");
+       prepareResult(bn,b,TYPE_xml,"concat");
 
        while(p < q){
                str t= (str) BUNtail(b,p);


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to