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

Remove mappings from CS to SuperCS including the frequency and the coverage 
maps.


diffs (truncated from 586 to 300 lines):

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
@@ -85,13 +85,21 @@ static void initArray(oid* inputArr, int
 }
 
 
-static void initIntArray(int* inputArr, int num, oid defaultValue){
+
+static void initcsIdFreqIdxMap(int* inputArr, int num, int defaultValue, CSset 
*freqCSset){
        int i; 
        for (i = 0; i < num; i++){
                inputArr[i] = defaultValue;
        }
+
+       for (i = 0; i < freqCSset->numCSadded; i++){
+               inputArr[freqCSset->items[i].csId] = i; 
+       }
+
 }
 
+
+
 static void initCharArray(char* inputArr, int num, char defaultValue){
        int i; 
        for (i = 0; i < num; i++){
@@ -348,12 +356,34 @@ void printCSrelSet(CSrel *csrelSet, char
        
 }
 
+static 
+oid getMaxCSIdFromCSId(oid csId, int* csIdFreqIdxMap, CSset *freqCSset){
+       
+       int freqIdx; 
+       oid maxCSoid; 
+
+       freqIdx = csIdFreqIdxMap[csId];
+       if (freqIdx != -1){ //A freqCS
+               if (freqCSset->items[freqIdx].type == MAXCS){
+                       maxCSoid = freqCSset->items[freqIdx].csId; 
+               }
+               else 
+                       maxCSoid = 
freqCSset->items[freqCSset->items[freqIdx].parentFreqIdx].csId;  
+       }
+       else{
+               maxCSoid = BUN_NONE;  
+       }
+
+       return maxCSoid; 
+}
+
 /*
  * Show the relationship from each CS to maximumFreqCSs
  * */
 
+
 static 
-str printCSrelWithMaxSet(oid* csSuperCSMap, CSrel *csrelToMaxSet, CSrel 
*csrelFromMaxSet, CSrel *csrelBetweenMaxSet, CSrel *csrelSet, char *csFreqMap, 
BAT* freqBat, int num, int freqThreshold){
+str printCSrelWithMaxSet(CSset *freqCSset, int* csIdFreqIdxMap, CSrel 
*csrelToMaxSet, CSrel *csrelFromMaxSet, CSrel *csrelBetweenMaxSet, CSrel 
*csrelSet, char *csFreqMap, BAT* freqBat, int num, int freqThreshold){
 
        int     i; 
        int     j; 
@@ -379,11 +409,11 @@ str printCSrelWithMaxSet(oid* csSuperCSM
 
        // Merge the relationships to create csrelToMaxSet, csrelFromMaxSet
        for (i = 0; i < num; i++){
-               maxCSoid = csSuperCSMap[csrelSet[i].origCSoid];
+               maxCSoid = getMaxCSIdFromCSId(csrelSet[i].origCSoid, 
csIdFreqIdxMap,freqCSset); 
                if (csrelSet[i].numRef != 0){
                        for (j = 0; j < csrelSet[i].numRef; j++){               
-                               if (csSuperCSMap[csrelSet[i].lstRefCSoid[j]] != 
BUN_NONE){
-                                       
addReltoCSRelWithFreq(csrelSet[i].origCSoid, 
csSuperCSMap[csrelSet[i].lstRefCSoid[j]], csrelSet[i].lstPropId[j], 
csrelSet[i].lstCnt[j], csrelSet[i].lstBlankCnt[j], &csrelToMaxSet[i]);
+                               if 
(getMaxCSIdFromCSId(csrelSet[i].lstRefCSoid[j],csIdFreqIdxMap,freqCSset) != 
BUN_NONE){
+                                       
addReltoCSRelWithFreq(csrelSet[i].origCSoid, 
getMaxCSIdFromCSId(csrelSet[i].lstRefCSoid[j], csIdFreqIdxMap,freqCSset), 
csrelSet[i].lstPropId[j], csrelSet[i].lstCnt[j], csrelSet[i].lstBlankCnt[j], 
&csrelToMaxSet[i]);
                                }
                        }
 
@@ -393,8 +423,8 @@ str printCSrelWithMaxSet(oid* csSuperCSM
                        // Else, use its csoid
                        if (maxCSoid != BUN_NONE){
                                for (j = 0; j < csrelSet[i].numRef; j++){       
        
-                                       if 
(csSuperCSMap[csrelSet[i].lstRefCSoid[j]] != BUN_NONE){
-                                               addReltoCSRelWithFreq(maxCSoid, 
csSuperCSMap[csrelSet[i].lstRefCSoid[j]], csrelSet[i].lstPropId[j], 
csrelSet[i].lstCnt[j],csrelSet[i].lstBlankCnt[j], &csrelFromMaxSet[maxCSoid]);
+                                       if 
(getMaxCSIdFromCSId(csrelSet[i].lstRefCSoid[j], csIdFreqIdxMap,freqCSset) != 
BUN_NONE){
+                                               addReltoCSRelWithFreq(maxCSoid, 
getMaxCSIdFromCSId(csrelSet[i].lstRefCSoid[j], csIdFreqIdxMap,freqCSset), 
csrelSet[i].lstPropId[j], csrelSet[i].lstCnt[j],csrelSet[i].lstBlankCnt[j], 
&csrelFromMaxSet[maxCSoid]);
                                        }
                                        else{
                                                addReltoCSRelWithFreq(maxCSoid, 
csrelSet[i].lstRefCSoid[j], csrelSet[i].lstPropId[j], csrelSet[i].lstCnt[j], 
csrelSet[i].lstBlankCnt[j], &csrelFromMaxSet[maxCSoid]);
@@ -462,7 +492,6 @@ str printCSrelWithMaxSet(oid* csSuperCSM
        fclose(fout1);
        fclose(fout1filter);
 
-       /*------------------------*/
 
        strcpy(filename2, "csRelationshipBetweenMaxFreqCS");
        sprintf(tmpStr, "%d", freqThreshold);
@@ -475,11 +504,11 @@ str printCSrelWithMaxSet(oid* csSuperCSM
 
        // Merge the csrelToMaxSet --> csrelBetweenMaxSet
        for (i = 0; i < num; i++){
-               maxCSoid = csSuperCSMap[csrelToMaxSet[i].origCSoid];
+               maxCSoid = getMaxCSIdFromCSId(csrelToMaxSet[i].origCSoid, 
csIdFreqIdxMap,freqCSset);
                if (csrelToMaxSet[i].numRef != 0 && maxCSoid != BUN_NONE){
                        for (j = 0; j < csrelToMaxSet[i].numRef; j++){          
-                               
assert(csSuperCSMap[csrelToMaxSet[i].lstRefCSoid[j]] == 
csrelToMaxSet[i].lstRefCSoid[j]);
-                               addReltoCSRelWithFreq(maxCSoid, 
csSuperCSMap[csrelToMaxSet[i].lstRefCSoid[j]], csrelToMaxSet[i].lstPropId[j], 
csrelToMaxSet[i].lstCnt[j],csrelToMaxSet[i].lstBlankCnt[j], 
&csrelBetweenMaxSet[maxCSoid]);
+                               
assert(getMaxCSIdFromCSId(csrelToMaxSet[i].lstRefCSoid[j], 
csIdFreqIdxMap,freqCSset) == csrelToMaxSet[i].lstRefCSoid[j]);
+                               addReltoCSRelWithFreq(maxCSoid, 
getMaxCSIdFromCSId(csrelToMaxSet[i].lstRefCSoid[j], csIdFreqIdxMap,freqCSset), 
csrelToMaxSet[i].lstPropId[j], 
csrelToMaxSet[i].lstCnt[j],csrelToMaxSet[i].lstBlankCnt[j], 
&csrelBetweenMaxSet[maxCSoid]);
                        }
                }
        }
@@ -519,6 +548,8 @@ str printCSrelWithMaxSet(oid* csSuperCSM
        return MAL_SUCCEED; 
 }
 
+
+
 static 
 void printSubCSInformation(SubCSSet *subcsset, BAT* freqBat, int num, char 
isWriteTofile, int freqThreshold){
 
@@ -779,10 +810,10 @@ void freeCS(CS *cs){
 */
 #if STOREFULLCS
 static
-CS* creatCS(oid csId, int numP, oid* buff, oid subjectId, oid* lstObject)
+CS* creatCS(oid csId, int numP, oid* buff, oid subjectId, oid* lstObject, char 
type, int parentfreqIdx, int support, int coverage)
 #else
 static 
-CS* creatCS(oid csId, int numP, oid* buff)
+CS* creatCS(oid csId, int numP, oid* buff, char type,  int parentfreqIdx, int 
support, int coverage)
 #endif 
 {
        CS *cs = (CS*)malloc(sizeof(CS)); 
@@ -798,7 +829,6 @@ CS* creatCS(oid csId, int numP, oid* buf
        cs->numProp = numP; 
        cs->numAllocation = numP; 
        /*By default, this CS is not known to be a subset of any other CS*/
-       cs->parent = BUN_NONE; 
        #if STOREFULLCS
        cs->lstObj =  (oid*) malloc(sizeof(oid) * numP);
        if (cs->lstObj == NULL){
@@ -809,6 +839,14 @@ CS* creatCS(oid csId, int numP, oid* buf
        cs->subject = subjectId; 
        //printf("Create a CS with subjectId: " BUNFMT "\n", subjectId);
        #endif
+
+       cs->type = type; 
+
+       // This value is set for the 
+       cs->parentFreqIdx = parentfreqIdx; 
+       cs->support = support;
+       cs->coverage = coverage; 
+
        return cs; 
 }
 
@@ -1000,7 +1038,7 @@ void mergeTwomergeCS(mergeCS *mergecs1, 
 }
 
 static 
-str printFreqCSSet(CSset *freqCSset, oid* csSuperCSMap, BAT *freqBat, BAT 
*mapbat, char isWriteTofile, int freqThreshold){
+str printFreqCSSet(CSset *freqCSset, BAT *freqBat, BAT *mapbat, char 
isWriteTofile, int freqThreshold){
 
        int     i; 
        int     j; 
@@ -1037,7 +1075,7 @@ str printFreqCSSet(CSset *freqCSset, oid
 
                        takeOid(cs.csId, &subStr);      
 
-                       printf("CS " BUNFMT " (Freq: %d) | Subject: %s  | 
ConsistsOf " BUNFMT " \n", cs.csId, *freq, subStr, csSuperCSMap[cs.csId]);
+                       printf("CS " BUNFMT " (Freq: %d) | Subject: %s  |  
Parent " BUNFMT " \n", cs.csId, *freq, subStr, 
freqCSset->items[cs.parentFreqIdx].csId);
                        for (j = 0; j < cs.numProp; j++){
                                printf("  P:" BUNFMT " --> \n", cs.lstProp[j]); 
                        }       
@@ -1064,18 +1102,18 @@ str printFreqCSSet(CSset *freqCSset, oid
 
                        takeOid(cs.subject, &subStr);   
                        
-                       fprintf(fout,"CS " BUNFMT " (Freq: %d) | Subject: %s  | 
ConsistsOf " BUNFMT " \n", cs.csId, *freq, subStr, csSuperCSMap[cs.csId]);
+                       fprintf(fout,"CS " BUNFMT " (Freq: %d) | Subject: %s  | 
FreqParentIdx %d \n", cs.csId, *freq, subStr, cs.parentFreqIdx);
 
                        // Filter max freq cs set
-                       if (csSuperCSMap[cs.csId] == cs.csId){
-                               fprintf(fout2,"CS " BUNFMT " (Freq: %d) | 
Subject: %s  | ConsistsOf " BUNFMT " \n", cs.csId, *freq, subStr, 
csSuperCSMap[cs.csId]);
+                       if (cs.type == MAXCS){
+                               fprintf(fout2,"CS " BUNFMT " (Freq: %d) | 
Subject: %s  | Parent " BUNFMT " \n", cs.csId, *freq, subStr, cs.csId);
                        }
 
                        for (j = 0; j < cs.numProp; j++){
                                takeOid(cs.lstProp[j], &propStr);
                                //fprintf(fout, "  P:" BUNFMT " --> ", 
cs.lstProp[j]);  
                                fprintf(fout, "  P:%s --> ", propStr);  
-                               if (csSuperCSMap[cs.csId] == cs.csId){
+                               if (cs.type == MAXCS){
                                        fprintf(fout2, "  P:%s --> ", propStr);
                                }
 
@@ -1095,14 +1133,14 @@ str printFreqCSSet(CSset *freqCSset, oid
                                }
 
                                fprintf(fout, "  O: %s \n", objStr);
-                               if (csSuperCSMap[cs.csId] == cs.csId){
+                               if (cs.type == MAXCS){
                                        fprintf(fout2, "  O: %s \n", objStr);
                                }
 
 
                        }       
                        fprintf(fout, "\n");
-                       if (csSuperCSMap[cs.csId] == cs.csId){
+                       if (cs.type == MAXCS){
                                fprintf(fout2, "\n");
                        }
                }
@@ -1390,9 +1428,9 @@ oid putaCStoHash(CSBats *csBats, oid* ke
                //Handle the case when freqThreshold == 1 
                if (isStoreFreqCS ==1 && freqThreshold == 1){
                        #if STOREFULLCS
-                       freqCS = creatCS(csId, num, key, subjectId, buffObjs);  
        
+                       freqCS = creatCS(csId, num, key, subjectId, buffObjs, 
FREQCS, -1, 0,0);         
                        #else
-                       freqCS = creatCS(csId, num, key);                       
+                       freqCS = creatCS(csId, num, key, FREQCS,-1,0,0);        
                
                        #endif
                        addCStoSet(freqCSset, *freqCS);
                }
@@ -1412,9 +1450,9 @@ oid putaCStoHash(CSBats *csBats, oid* ke
                        if (isStoreFreqCS ==1 && freqThreshold == 1){
                                
                                #if STOREFULLCS
-                               freqCS = creatCS(csId, num, key, subjectId, 
buffObjs);          
+                               freqCS = creatCS(csId, num, key, subjectId, 
buffObjs, FREQCS,-1,0,0);           
                                #else
-                               freqCS = creatCS(csId, num, key);               
        
+                               freqCS = creatCS(csId, num, key, 
FREQCS,-1,0,0);                        
                                #endif
                                addCStoSet(freqCSset, *freqCS);
                        }
@@ -1434,9 +1472,9 @@ oid putaCStoHash(CSBats *csBats, oid* ke
                                //printf("FreqCS: Support = %d, Threshold %d  
\n ", freq, freqThreshold);
                                if (*freq == freqThreshold){
                                        #if STOREFULLCS
-                                       freqCS = creatCS(csId, num, key, 
subjectId, buffObjs);          
+                                       freqCS = creatCS(csId, num, key, 
subjectId, buffObjs, FREQCS,-1,0,0);           
                                        #else
-                                       freqCS = creatCS(csId, num, key);       
                
+                                       freqCS = creatCS(csId, num, key, 
FREQCS,-1,0,0);                        
                                        #endif
                                        addCStoSet(freqCSset, *freqCS);
                                }
@@ -1633,40 +1671,37 @@ void printCS(CS cs){
  * Here maximum frequent CS is a CS that there exist no other CS which 
contains that CS
  * */
 static 
-void getMaximumFreqCSs(CSset *freqCSset, oid* csSuperCSMap, BAT* coverageBat, 
int* superCSCoverage, BAT* freqBat, int* superCSFrequency, int numCS, int 
*nMaxCSs){
+void getMaximumFreqCSs(CSset *freqCSset, BAT* coverageBat, BAT* freqBat, int 
numCS, int *nMaxCSs){
 
        int     numFreqCS = freqCSset->numCSadded; 
        int     i, j; 
        int     numMaxCSs = 0;
 
-       oid     tmpCSId; 
+       int     tmpParentIdx; 
        int*    coverage; 
        int*    freq; 
 
        printf("Retrieving maximum frequent CSs: \n");
 
        for (i = 0; i < numFreqCS; i++){
-               if (freqCSset->items[i].parent != BUN_NONE) continue;
+               if (freqCSset->items[i].parentFreqIdx != -1) continue;
                for (j = (i+1); j < numFreqCS; j++){
                        if (isSubset(freqCSset->items[i].lstProp, 
freqCSset->items[j].lstProp,  
                                        
freqCSset->items[i].numProp,freqCSset->items[j].numProp) == 1) { 
                                /* CSj is a subset of CSi */
-                               freqCSset->items[j].parent = 
freqCSset->items[i].csId; 
-                               csSuperCSMap[freqCSset->items[j].csId] = 
freqCSset->items[i].csId;
+                               freqCSset->items[j].parentFreqIdx = i; 
                        }
                        else if (isSubset(freqCSset->items[j].lstProp, 
freqCSset->items[i].lstProp,  
                                        
freqCSset->items[j].numProp,freqCSset->items[i].numProp) == 1) { 
                                /* CSj is a subset of CSi */
-                               freqCSset->items[i].parent = 
freqCSset->items[j].csId;; 
-                               csSuperCSMap[freqCSset->items[i].csId] = 
freqCSset->items[j].csId;
+                               freqCSset->items[i].parentFreqIdx = j; 
                                break; 
                        }
                        
                } 
                /* By the end, if this CS is not a subset of any other CS */
-               if (freqCSset->items[i].parent == BUN_NONE){
+               if (freqCSset->items[i].parentFreqIdx == -1){
                        numMaxCSs++;
-                       csSuperCSMap[freqCSset->items[i].csId] = 
freqCSset->items[i].csId;
                        //printCS( freqCSset->items[i]); 
                }
        }
@@ -1674,46 +1709,44 @@ void getMaximumFreqCSs(CSset *freqCSset,
        *nMaxCSs = numMaxCSs;
        printf("Number of maximum CSs: %d / %d CSs \n", numMaxCSs, numCS);
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to