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

Fix a bug in extracting type-specific CS (i.e., subCS).

This bug generates a lot of subCSs. After fixing, one CS has a few subCSs which 
is reasonably good.


diffs (113 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
@@ -60,7 +60,8 @@ typedef enum {
        DATETIME, 
        NUMERIC, 
        STRING,
-       BLANKNODE       
+       BLANKNODE,
+       MULTIVALUES             // For the multi-value property 
 } ObjectType; 
 
 #define IS_DUPLICATE_FREE 0            /* 0: Duplications have not been 
removed, otherwise 1 */
@@ -68,6 +69,8 @@ typedef enum {
 #define TRIPLE_STORE 1
 #define MLA_STORE    2
 #define NOT_IGNORE_ERROR_TRIPLE 0
+#define USE_MULTIPLICITY 1             /* Properties having >= 2 values are 
being considered as having 
+                                       the same type, i.e., MULTIVALUES */
 
 #define STORE TRIPLE_STORE /* this should become a compile time option */
 
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
@@ -596,7 +596,7 @@ void printSubCSInformation(SubCSSet *sub
                        if (subcsset[i].numSubCS != 0){ 
                                freq  = (int *) Tloc(freqBat, i);
                                fprintf(fout, "CS " BUNFMT ": ", 
subcsset[i].csId);
-
+                                       
                                if (*freq > freqThreshold){
                                        fprintf(foutfreq, BUNFMT "  ", 
subcsset[i].csId);
                                        fprintf(foutfreqfilter, BUNFMT "  ", 
subcsset[i].csId);
@@ -2391,6 +2391,7 @@ str RDFrelationships(int *ret, BAT *sbat
        char*           buffTypes; 
        oid             realObjOid;     
        char            isBlankNode; 
+       oid             curP; 
 
        if (BATcount(sbat) == 0) {
                throw(RDF, "rdf.RDFrelationships", "sbat must not be empty");
@@ -2402,39 +2403,54 @@ str RDFrelationships(int *ret, BAT *sbat
 
        numPwithDup = 0;
        curS = 0; 
+       curP = 0; 
 
        BATloop(sbat, p, q){
                sbt = (oid *) BUNtloc(si, p);           
                if (*sbt != curS){
                        if (p != 0){    /* Not the first S */
-                               returnSubCSid = addSubCS(buffTypes, 
numPwithDup, subjCSMap[*sbt], csSubCSMap);
+                               returnSubCSid = addSubCS(buffTypes, 
numPwithDup, subjCSMap[curS], csSubCSMap);
+
                                //Get the subCSId
                                subjSubCSMap[*sbt] = returnSubCSid; 
 
                        }
                        curS = *sbt; 
                        numPwithDup = 0;
+                       curP = 0; 
                }
                                
                obt = (oid *) BUNtloc(oi, p); 
                /* Check type of object */
                objType = (char) ((*obt) >> (sizeof(BUN)*8 - 4))  &  7 ;        
/* Get two bits 63th, 62nd from object oid */
-
-               buffTypes[numPwithDup] = objType; 
-               numPwithDup++; 
-               
+       
+               pbt = (oid *) BUNtloc(pi, p);
+
                /* Look at the referenced CS Id using subjCSMap */
                isBlankNode = 0;
                if (objType == URI || objType == BLANKNODE){
-                       pbt = (oid *) BUNtloc(pi, p); 
                        realObjOid = (*obt) - ((oid) objType << (sizeof(BUN)*8 
- 4));
 
                        if (realObjOid <= maxSoid && subjCSMap[realObjOid] != 
BUN_NONE){
                                if (objType == BLANKNODE) isBlankNode = 1;
-                               ////printf(" Subject " BUNFMT " refer to CS " 
BUNFMT " \n",*sbt, subjCSMap[*obt]);
                                addReltoCSRel(subjCSMap[*sbt], 
subjCSMap[realObjOid], *pbt, &csrelSet[subjCSMap[*sbt]], isBlankNode);
                        }
                }
+
+               if (curP == *pbt){
+                       #if USE_MULTIPLICITY == 1       
+                       // Update the object type for this P as MULTIVALUES     
+                       buffTypes[numPwithDup-1] = MULTIVALUES; 
+                       #else
+                       buffTypes[numPwithDup] = objType;
+                       numPwithDup++;
+                       #endif
+               }
+               else{                   
+                       buffTypes[numPwithDup] = objType; 
+                       numPwithDup++; 
+                       curP = *pbt; 
+               }
        }
        
        /* Check for the last CS */
@@ -2443,8 +2459,6 @@ str RDFrelationships(int *ret, BAT *sbat
 
        free (buffTypes); 
 
-
-
        *ret = 1; 
 
        return MAL_SUCCEED; 
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to