Changeset: f4bd7e93a31c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f4bd7e93a31c
Modified Files:
        monetdb5/extras/rdf/rdf.h
        monetdb5/extras/rdf/rdfalgebra.c
        monetdb5/extras/rdf/rdfalgebra.mal
        monetdb5/extras/rdf/rdfschema.c
        monetdb5/modules/mal/tokenizer.c
        monetdb5/modules/mal/tokenizer.h
        monetdb5/modules/mal/tokenizer.mal
Branch: rdf
Log Message:

Apply the changes in Feb2013 for moving all rdf-related stuffs from tokenizer 
to rdf module


diffs (238 lines):

diff --git a/monetdb5/extras/rdf/rdf.h b/monetdb5/extras/rdf/rdf.h
--- a/monetdb5/extras/rdf/rdf.h
+++ b/monetdb5/extras/rdf/rdf.h
@@ -51,6 +51,11 @@ RDFleftfetchjoin_sortedestimate(int *res
 rdf_export str 
 RDFleftfetchjoin_sorted(int *result, int* lid, int *rid);
 
+rdf_export str
+TKNZRrdf2str (bat *res, bat *bid, bat *map);
+
+#define RDF_MIN_LITERAL (((oid) 1) << ((sizeof(oid)==8)?60:28))
+
 typedef enum {
        URI,
        DATETIME, 
diff --git a/monetdb5/extras/rdf/rdfalgebra.c b/monetdb5/extras/rdf/rdfalgebra.c
--- a/monetdb5/extras/rdf/rdfalgebra.c
+++ b/monetdb5/extras/rdf/rdfalgebra.c
@@ -23,6 +23,7 @@
 #include "rdf.h"
 #include "algebra.h"
 #include <gdk.h>
+#include "tokenizer.h"
 
 str
 RDFleftfetchjoin_sorted(bat *result, bat *lid, bat *rid)
@@ -50,3 +51,66 @@ RDFleftfetchjoin_sorted(bat *result, bat
        BBPkeepref(*result);
        return MAL_SUCCEED;
 }
+
+
+str
+TKNZRrdf2str(bat *res, bat *bid, bat *map)
+{
+       BAT *r, *b, *m;
+       BATiter bi, mi;
+       BUN p, q;
+       str s = NULL;
+
+       b = BATdescriptor(*bid);
+       if (b == NULL) {
+               throw(MAL, "rdf.rdf2str", RUNTIME_OBJECT_MISSING " null bat b");
+       }
+       m = BATdescriptor(*map);
+       if (m == NULL) {
+               BBPunfix(*bid);
+               throw(MAL, "rdf.rdf2str", RUNTIME_OBJECT_MISSING "null bat m");
+       }
+       if (!BAThdense(b)) {
+               BBPunfix(*bid);
+               BBPunfix(*map);
+               throw(MAL, "rdf.rdf2str", SEMANTIC_TYPE_ERROR " semantic 
error");
+       }
+       r = BATnew(TYPE_void, TYPE_str, BATcount(b));
+       if (r == NULL) {
+               BBPunfix(*bid);
+               BBPunfix(*map);
+               throw(MAL, "rdf.rdf2str", RUNTIME_OBJECT_MISSING "null bat r");
+       }
+       *res = r->batCacheid;
+       BATseqbase(r, b->hseqbase);
+       bi = bat_iterator(b);
+       mi = bat_iterator(m);
+
+       BATloop(b, p, q)
+       {
+               oid id = *(oid *) BUNtloc(bi, p);
+               if (id >= RDF_MIN_LITERAL) {
+                       BUN pos = BUNfirst(m) + (id - RDF_MIN_LITERAL);
+                       if (pos < BUNfirst(m) || pos >= BUNlast(m)) {
+                               BBPunfix(*bid);
+                               BBPunfix(*map);
+                               BBPunfix(*res);
+                               throw(MAL, "rdf.rdf2str", OPERATION_FAILED " 
illegal oid");
+                       }
+                       s = (str) BUNtail(mi, pos);
+               } else {
+                       str ret = takeOid(id, &s);
+                       if (ret != MAL_SUCCEED) {
+                               BBPunfix(*bid);
+                               BBPunfix(*map);
+                               BBPunfix(*res);
+                               return ret;
+                       }
+               }
+               BUNappend(r, s, FALSE);
+       }
+       BBPunfix(*bid);
+       BBPunfix(*map);
+       BBPkeepref(*res);
+       return MAL_SUCCEED;
+}
diff --git a/monetdb5/extras/rdf/rdfalgebra.mal 
b/monetdb5/extras/rdf/rdfalgebra.mal
--- a/monetdb5/extras/rdf/rdfalgebra.mal
+++ b/monetdb5/extras/rdf/rdfalgebra.mal
@@ -19,4 +19,8 @@ module rdf;
 
 command leftfetchjoin_sorted ( left:bat[:any_1,:oid], right:bat[:oid,:any_3] ) 
:bat[:any_1,:any_3]
 address RDFleftfetchjoin_sorted
-comment "like algebra_leftfetchjoin(), but asserts that the resulting tail 
column is sorted -- ONLY USE IF YOU ARE SURE OF THIS!!! also requires sorted 
tail left input";
+comment "like algebra_leftfetchjoin(), but asserts that the resulting tail 
column is sorted -- ONLY USE IF YOU ARE SURE OF THIS!!! also requires sorted 
tail left input"
+
+command rdf2str(i:bat[:oid,:oid],map:bat[:oid,:str]):bat[:oid,:str]
+address TKNZRrdf2str
+comment "converts id's into strings using the dictionary, but if (id >= 
RDF_MIN_LITERAL) look it up in a literal map bat";
diff --git a/monetdb5/extras/rdf/rdfschema.c b/monetdb5/extras/rdf/rdfschema.c
--- a/monetdb5/extras/rdf/rdfschema.c
+++ b/monetdb5/extras/rdf/rdfschema.c
@@ -478,7 +478,7 @@ RDFextractCSwithTypes(int *ret, bat *sba
        //BAT   *hsValueBat;
        BAT     *pOffsetBat;    /* BAT storing the offset for set of 
properties, refer to fullPBat */
        BAT     *fullPBat;      /* Stores all set of properties */
-       int     *subjCSMap;     /* Store the correspoinding CS Id for each 
subject */
+       //int   *subjCSMap;     /* Store the correspoinding CS Id for each 
subject */
        
        buff = (int *) malloc (sizeof(int) * INIT_PROPERTY_NUM);
 
diff --git a/monetdb5/modules/mal/tokenizer.c b/monetdb5/modules/mal/tokenizer.c
--- a/monetdb5/modules/mal/tokenizer.c
+++ b/monetdb5/modules/mal/tokenizer.c
@@ -448,7 +448,7 @@ TKNZRlocate(Client cntxt, MalBlkPtr mb, 
        return MAL_SUCCEED;
 }
 
-static str
+str
 takeOid(oid id, str *val)
 {
        int i, depth;
@@ -505,68 +505,6 @@ TKNZRtakeOid(Client cntxt, MalBlkPtr mb,
 }
 
 str
-TKNZRrdf2str(bat *res, bat *bid, bat *map)
-{
-       BAT *r, *b, *m;
-       BATiter bi, mi;
-       BUN p, q;
-       str s = NULL;
-
-       b = BATdescriptor(*bid);
-       if (b == NULL) {
-               throw(MAL, "tokenizer.rdf2str", RUNTIME_OBJECT_MISSING " null 
bat b");
-       }
-       m = BATdescriptor(*map);
-       if (m == NULL) {
-               BBPunfix(*bid);
-               throw(MAL, "tokenizer.rdf2str", RUNTIME_OBJECT_MISSING "null 
bat m");
-       }
-       if (!BAThdense(b)) {
-               BBPunfix(*bid);
-               BBPunfix(*map);
-               throw(MAL, "tokenizer.rdf2str", SEMANTIC_TYPE_ERROR " semantic 
error");
-       }
-       r = BATnew(TYPE_void, TYPE_str, BATcount(b));
-       if (r == NULL) {
-               BBPunfix(*bid);
-               BBPunfix(*map);
-               throw(MAL, "tokenizer.rdf2str", RUNTIME_OBJECT_MISSING "null 
bat r");
-       }
-       *res = r->batCacheid;
-       BATseqbase(r, b->hseqbase);
-       bi = bat_iterator(b);
-       mi = bat_iterator(m);
-
-       BATloop(b, p, q)
-       {
-               oid id = *(oid *) BUNtloc(bi, p);
-               if (id >= RDF_MIN_LITERAL) {
-                       BUN pos = BUNfirst(m) + (id - RDF_MIN_LITERAL);
-                       if (pos < BUNfirst(m) || pos >= BUNlast(m)) {
-                               BBPunfix(*bid);
-                               BBPunfix(*map);
-                               BBPunfix(*res);
-                               throw(MAL, "tokenizer.rdf2str", 
OPERATION_FAILED " illegal oid");
-                       }
-                       s = (str) BUNtail(mi, pos);
-               } else {
-                       str ret = takeOid(id, &s);
-                       if (ret != MAL_SUCCEED) {
-                               BBPunfix(*bid);
-                               BBPunfix(*map);
-                               BBPunfix(*res);
-                               return ret;
-                       }
-               }
-               BUNappend(r, s, FALSE);
-       }
-       BBPunfix(*bid);
-       BBPunfix(*map);
-       BBPkeepref(*res);
-       return MAL_SUCCEED;
-}
-
-str
 TKNZRgetIndex(int *r)
 {
        if (TRANS == NULL)
diff --git a/monetdb5/modules/mal/tokenizer.h b/monetdb5/modules/mal/tokenizer.h
--- a/monetdb5/modules/mal/tokenizer.h
+++ b/monetdb5/modules/mal/tokenizer.h
@@ -22,8 +22,6 @@
 #include "mal_client.h"
 #include "mal_interpreter.h"
 
-#define RDF_MIN_LITERAL (((oid) 1) << ((sizeof(oid)==8)?60:28))
-
 #ifdef WIN32
 #if !defined(LIBMAL) && !defined(LIBATOMS) && !defined(LIBKERNEL) && 
!defined(LIBMAL) && !defined(LIBOPTIMIZER) && !defined(LIBSCHEDULER) && 
!defined(LIBMONETDB5)
 #define tokenizer_export extern __declspec(dllimport)
@@ -39,11 +37,11 @@ tokenizer_export str TKNZRclose         
 tokenizer_export str TKNZRappend          (oid *pos, str *tuple);
 tokenizer_export str TKNZRlocate           (Client cntxt, MalBlkPtr mb, 
MalStkPtr stk, InstrPtr pci);
 tokenizer_export str TKNZRtakeOid          (Client cntxt, MalBlkPtr mb, 
MalStkPtr stk, InstrPtr pci);
-tokenizer_export str TKNZRrdf2str          (bat *res, bat *bid, bat *map);
 tokenizer_export str TKNZRdepositFile      (int *r, str *fnme);
 tokenizer_export str TKNZRgetLevel         (int *r, int *level);
 tokenizer_export str TKNZRgetIndex         (int *r);
 tokenizer_export str TKNZRgetCount         (int *r);
 tokenizer_export str TKNZRgetCardinality   (int *r);
+tokenizer_export str takeOid              (oid id, str *val);                  
 
 #endif /* _TKNZR_H */
diff --git a/monetdb5/modules/mal/tokenizer.mal 
b/monetdb5/modules/mal/tokenizer.mal
--- a/monetdb5/modules/mal/tokenizer.mal
+++ b/monetdb5/modules/mal/tokenizer.mal
@@ -14,10 +14,6 @@ pattern take(i:oid):str
 address TKNZRtakeOid
 comment "reconstruct and returns the i-th string";
 
-command rdf2str(i:bat[:oid,:oid],map:bat[:oid,:str]):bat[:oid,:str]
-address TKNZRrdf2str
-comment "converts id's into strings using the dictionary, but if (id >= 
RDF_MIN_LITERAL) look it up in a literal map bat";
-
 pattern locate(s:str):oid
 address TKNZRlocate
 comment "if the given string is in the store returns its oid, otherwise 
oid_nil";
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to