Changeset: d793cd4b7e95 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d793cd4b7e95
Modified Files:
        monetdb5/mal/mal_box.c
        monetdb5/mal/mal_box.h
        monetdb5/modules/mal/bbp.c
        monetdb5/modules/mal/box.c
        monetdb5/modules/mal/const.c
        monetdb5/modules/mal/urlbox.c
        monetdb5/modules/mal/urlbox.mal
Branch: default
Log Message:

Move urlbox to headless


diffs (269 lines):

diff --git a/monetdb5/mal/mal_box.c b/monetdb5/mal/mal_box.c
--- a/monetdb5/mal/mal_box.c
+++ b/monetdb5/mal/mal_box.c
@@ -536,15 +536,15 @@ discardBox(Box box, str name)
  * The elements can be obtained using iterator, which returns the name
  * of the next element in the box.
  */
-int
-nextBoxElement(Box box, lng *cursor, ValPtr v)
+oid
+nextBoxElement(Box box, oid *cursor, ValPtr v)
 {
-       if (*cursor >= box->sym->vtop) {
-               *cursor = -1;
+       if (*cursor >= (oid) box->sym->vtop) {
+               *cursor = (oid) oid_nil;
                return 0;
        }
        if ( box->val == NULL)
-               return -1;
+               return oid_nil;
        v->vtype = TYPE_str;
        v->val.sval = getBoxName(box, *cursor);
        *cursor = *cursor + 1;
diff --git a/monetdb5/mal/mal_box.h b/monetdb5/mal/mal_box.h
--- a/monetdb5/mal/mal_box.h
+++ b/monetdb5/mal/mal_box.h
@@ -49,6 +49,6 @@ mal_export int discardBox(Box box, str n
 mal_export str getBoxName(Box box, lng i);
 mal_export str getBoxNames(int *bid);
 mal_export str toString(Box box, lng i);
-mal_export int nextBoxElement(Box box, lng *cursor, ValPtr v);
+mal_export oid nextBoxElement(Box box, oid *cursor, ValPtr v);
 
 #endif /* _MAL_BOX_H */
diff --git a/monetdb5/modules/mal/bbp.c b/monetdb5/modules/mal/bbp.c
--- a/monetdb5/modules/mal/bbp.c
+++ b/monetdb5/modules/mal/bbp.c
@@ -746,13 +746,13 @@ str
 CMDbbpiterator(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
        Box box;
-       lng *cursor;
+       oid *cursor;
        ValPtr v;
 
        (void) cntxt;
        (void) mb;              /* fool compiler */
        OpenBox("iterator");
-       cursor = (lng *) getArgReference(stk, pci, 0);
+       cursor = (oid *) getArgReference(stk, pci, 0);
        v = getArgReference(stk,pci,1);
        if (nextBoxElement(box, cursor, v))
                throw(MAL, "bbp.iterator", OPERATION_FAILED);
diff --git a/monetdb5/modules/mal/box.c b/monetdb5/modules/mal/box.c
--- a/monetdb5/modules/mal/box.c
+++ b/monetdb5/modules/mal/box.c
@@ -185,13 +185,13 @@ BOXiterator(Client cntxt, MalBlkPtr mb, 
 {
        str name;
        Box box;
-       lng *cursor;
+       oid *cursor;
        ValPtr v;
 
        (void) cntxt;
        (void) mb;              /*fool compiler */
        OpenBox("iterator");
-       cursor = (lng *) getArgReference(stk, pci, 0);
+       cursor = (oid *) getArgReference(stk, pci, 0);
        v = getArgReference(stk,pci,2); 
        (void) nextBoxElement(box, cursor, v);
        return MAL_SUCCEED;
diff --git a/monetdb5/modules/mal/const.c b/monetdb5/modules/mal/const.c
--- a/monetdb5/modules/mal/const.c
+++ b/monetdb5/modules/mal/const.c
@@ -247,15 +247,15 @@ str
 CSTnewIterator(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
        Box box;
-       lng *cursor;
+       oid *cursor;
        ValPtr v;
 
        (void) cntxt;
        (void) mb;              /* fool compiler */
        OpenBox("iterator");
-       cursor = (lng *) getArgReference(stk, pci, 0);
+       cursor = (oid *) getArgReference(stk, pci, 0);
        v = getArgReference(stk,pci,1);
-       if ( nextBoxElement(box, cursor, v) < 0)
+       if ( nextBoxElement(box, cursor, v)  == oid_nil)
                throw(MAL, "const.iterator", OPERATION_FAILED);
        return MAL_SUCCEED;
 }
@@ -264,15 +264,15 @@ str
 CSThasMoreElements(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
        Box box;
-       lng *cursor;
+       oid *cursor;
        ValPtr v;
 
        (void) cntxt;
        (void) mb;              /* fool compiler */
        OpenBox("iterator");
-       cursor = (lng *) getArgReference(stk, pci, 0);
+       cursor = (oid *) getArgReference(stk, pci, 0);
        v = getArgReference(stk,pci,1);
-       if ( nextBoxElement(box, cursor, v) < 0)
+       if ( nextBoxElement(box, cursor, v) == oid_nil)
                throw(MAL, "const.iterator", OPERATION_FAILED);
        return MAL_SUCCEED;
 }
diff --git a/monetdb5/modules/mal/urlbox.c b/monetdb5/modules/mal/urlbox.c
--- a/monetdb5/modules/mal/urlbox.c
+++ b/monetdb5/modules/mal/urlbox.c
@@ -150,9 +150,10 @@ URLBOXinsert(char *tuple)
                                continue;
                        }
 
-                       b = BATnew(TYPE_int, TYPE_str, 1024);
+                       b = BATnew(TYPE_void, TYPE_str, 1024);
                        if (b == NULL)
                                throw(MAL, "urlbox.deposit", MAL_MALLOC_FAIL);
+                       BATseqbase(b,0);
 
                        BATkey(b,TRUE);
                        BBPrename(b->batCacheid, buf);
@@ -394,15 +395,15 @@ str
 URLBOXnewIterator(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
        Box box;
-       lng *cursor;
+       oid *cursor;
        ValPtr v;
 
        (void) cntxt;
        (void) mb;              /* fool compiler */
        OpenBox("iterator");
-       cursor = (lng *) getArgReference(stk, pci, 0);
+       cursor = (oid *) getArgReference(stk, pci, 0);
        v = getArgReference(stk,pci,1);
-       if ( nextBoxElement(box, cursor, v) < 0)
+       if ( nextBoxElement(box, cursor, v) == oid_nil)
                throw(MAL, "urlbox.iterator", OPERATION_FAILED);
        return MAL_SUCCEED;
 }
@@ -411,15 +412,15 @@ str
 URLBOXhasMoreElements(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
        Box box;
-       lng *cursor;
+       oid *cursor;
        ValPtr v;
 
        (void) cntxt;
        (void) mb;              /* fool compiler */
        OpenBox("iterator");
-       cursor=  (lng *) getArgReference(stk, pci, 0);
+       cursor=  (oid *) getArgReference(stk, pci, 0);
        v = getArgReference(stk,pci,1);
-       if ( nextBoxElement(box, cursor, v) < 0)
+       if ( nextBoxElement(box, cursor, v) == oid_nil)
                throw(MAL, "urlbox.iterator", OPERATION_FAILED);
        return MAL_SUCCEED;
 }
@@ -437,11 +438,12 @@ str
 URLBOXgetNames(int *r){
        BAT *b;
        int i;
-       b= BATnew(TYPE_int,TYPE_str, urlDepth+1);
+       b= BATnew(TYPE_void,TYPE_str, urlDepth+1);
        if( b== NULL)
                throw(MAL, "urlbox.getNames", MAL_MALLOC_FAIL);
+       BATseqbase(b,0);
        for(i=0; i<urlDepth; i++){
-               BUNins(b,&i, BBPname(urlBAT[i]->batCacheid), FALSE);
+               BUNappend(b, BBPname(urlBAT[i]->batCacheid), FALSE);
        }
        *r = b->batCacheid;
        BBPkeepref(*r);
@@ -453,12 +455,13 @@ URLBOXgetCount(int *r){
        int i;
        lng cnt;
 
-       b= BATnew(TYPE_int,TYPE_lng, urlDepth+1);
+       b= BATnew(TYPE_oid,TYPE_lng, urlDepth+1);
        if( b== NULL)
                throw(MAL, "urlbox.getNames", MAL_MALLOC_FAIL);
+       BATseqbase(b,0);
        for(i=0; i<urlDepth; i++){
                cnt = (lng) BATcount(urlBAT[i]);
-               BUNins(b,&i, &cnt, FALSE);
+               BUNappend(b, &cnt, FALSE);
        }
        *r = b->batCacheid;
        BBPkeepref(*r);
@@ -470,12 +473,13 @@ URLBOXgetCardinality(int *r){
        int i;
        lng cnt;
 
-       b= BATnew(TYPE_int,TYPE_lng, urlDepth+1);
+       b= BATnew(TYPE_void,TYPE_lng, urlDepth+1);
        if( b== NULL)
                throw(MAL, "urlbox.getNames", MAL_MALLOC_FAIL);
+       BATseqbase(b,0);
        for(i=0; i<urlDepth; i++){
                bn = (BAT *) BATkunique(BATmirror(urlBAT[i]));
-               cnt = (lng) BATcount(bn);
+               cnt = (oid) BATcount(bn);
                BBPunfix(bn->batCacheid);
                BUNins(b,&i, &cnt, FALSE);
        }
@@ -494,9 +498,10 @@ URLBOXgetSize(int *r){
        lng tot;
        size_t size;
 
-       b= BATnew(TYPE_int,TYPE_lng, urlDepth+1);
+       b= BATnew(TYPE_void,TYPE_lng, urlDepth+1);
        if( b== NULL)
                throw(MAL, "urlbox.getNames", MAL_MALLOC_FAIL);
+       BATseqbase(b,0);
        for(i=0; i<urlDepth; i++){
                bn= urlBAT[i];
                size = ROUND_UP(sizeof(BATstore), blksize);
@@ -516,7 +521,7 @@ URLBOXgetSize(int *r){
                }
                tot = size;
                BBPunfix(bn->batCacheid);
-               BUNins(b,&i, &tot, FALSE);
+               BUNappend(b, &tot, FALSE);
        }
        *r = b->batCacheid;
        BBPkeepref(*r);
diff --git a/monetdb5/modules/mal/urlbox.mal b/monetdb5/modules/mal/urlbox.mal
--- a/monetdb5/modules/mal/urlbox.mal
+++ b/monetdb5/modules/mal/urlbox.mal
@@ -45,23 +45,23 @@ pattern discard():void
 address URLBOXdiscardAll
 comment "Remove all URLs from the box";
 
-pattern newIterator()(:int,:str)
+pattern newIterator()(:oid,:str)
 address URLBOXnewIterator
 comment "Locate next element in the box";
-pattern hasMoreElements()(:int,:str)
+pattern hasMoreElements()(:oid,:str)
 address URLBOXhasMoreElements
 comment "Locate next element in the box";
 
-command getLevel(i:int):bat[:int,:str]
+command getLevel(i:int):bat[:oid,:str]
 address URLBOXgetLevel;
 
-command getNames():bat[:int,:str]
+command getNames():bat[:oid,:str]
 address URLBOXgetNames;
-command getCount():bat[:int,:lng]
+command getCount():bat[:oid,:lng]
 address URLBOXgetCount;
-command getCardinality():bat[:int,:lng]
+command getCardinality():bat[:oid,:lng]
 address URLBOXgetCardinality;
-command getSize():bat[:int,:lng]
+command getSize():bat[:oid,:lng]
 address URLBOXgetSize;
 pattern prelude():void 
 address URLBOXprelude
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to