Changeset: ee517c72d0fc for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ee517c72d0fc
Modified Files:
monetdb5/extras/rdf/hashmap/hashmap.c
monetdb5/extras/rdf/hashmap/hashmap.h
monetdb5/extras/rdf/rdfschema.c
monetdb5/extras/rdf/rdfschema.h
Branch: rdf
Log Message:
Fix the problem of wrong frequency due to rehashing the hashmap.
diffs (212 lines):
diff --git a/monetdb5/extras/rdf/hashmap/hashmap.c
b/monetdb5/extras/rdf/hashmap/hashmap.c
--- a/monetdb5/extras/rdf/hashmap/hashmap.c
+++ b/monetdb5/extras/rdf/hashmap/hashmap.c
@@ -124,7 +124,7 @@ static int hashmap_rehash(map_t in){
if (curr[i].in_use == 0)
continue;
- status = hashmap_put(m, curr[i].key, curr[i].num, curr[i].data);
+ status = hashmap_put(m, curr[i].key, curr[i].num, curr[i].freq,
curr[i].data);
if (status != MAP_OK)
return status;
}
@@ -137,7 +137,7 @@ static int hashmap_rehash(map_t in){
/*
* Add a pointer to the hashmap with some key
*/
-int hashmap_put(map_t in, int* key, int num, any_t value){
+int hashmap_put(map_t in, int* key, int num, int freq, any_t value){
int index;
hashmap_map* m;
@@ -158,7 +158,7 @@ int hashmap_put(map_t in, int* key, int
m->data[index].key = key;
m->data[index].num = num;
m->data[index].in_use = 1;
- m->data[index].freq = 1;
+ m->data[index].freq = freq;
m->size++;
return MAP_OK;
@@ -323,7 +323,7 @@ int hashmap_iterate_threshold(map_t in,
/* Linear probing */
for(i = 0; i< m->table_size; i++)
if(m->data[i].in_use != 0) {
- if (m->data[i].freq > freqthreshold){
+ if (m->data[i].freq >= freqthreshold){
count++;
}
}
diff --git a/monetdb5/extras/rdf/hashmap/hashmap.h
b/monetdb5/extras/rdf/hashmap/hashmap.h
--- a/monetdb5/extras/rdf/hashmap/hashmap.h
+++ b/monetdb5/extras/rdf/hashmap/hashmap.h
@@ -105,7 +105,7 @@ extern int hashmap_statistic_groupcs_by_
/*
* Add an element to the hashmap. Return MAP_OK or MAP_OMEM.
*/
-extern int hashmap_put(map_t in, int* key, int num, any_t value);
+extern int hashmap_put(map_t in, int* key, int num, int freq, any_t value);
/*
* Add a pointer to the hashmap with some key
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
@@ -114,12 +114,12 @@ CS* creatCS(int subId, int numP, int* bu
* If yes, add that frequent CS to the freqCSset.
*
* */
-static void putaCStoHash(map_t csmap, int* buff, int num, oid *csoid, char
isStoreFreqCS, int freqThreshold, CSset *freqCSset){
+static void putaCStoHash(map_t csmap, int* buff, int num, oid *csoid, char
isStoreFreqCS, int freqThreshold, CSset **freqCSset){
oid *getCSoid;
oid *putCSoid;
int err;
int* cs;
- int freq;
+ int freq = 0;
CS *freqCS;
cs = (int*) malloc(sizeof(int) * num);
@@ -133,17 +133,17 @@ static void putaCStoHash(map_t csmap, in
putCSoid = malloc(sizeof(oid));
*putCSoid = *csoid;
- err = hashmap_put(csmap, cs, num, putCSoid);
+ err = hashmap_put(csmap, cs, num, 1, putCSoid);
assert(err == MAP_OK);
(*csoid)++;
}
else{
if (isStoreFreqCS == 1){ /* Store the frequent CS to the
CSset*/
- printf("FreqCS: Support = %d, Threshold %d \n ", freq,
freqThreshold);
+ //printf("FreqCS: Support = %d, Threshold %d \n ",
freq, freqThreshold);
if (freq == freqThreshold){
freqCS = creatCS(*getCSoid, num, buff);
- addCStoSet(freqCSset, *freqCS);
+ addCStoSet(*freqCSset, *freqCS);
}
}
free(cs);
@@ -181,6 +181,7 @@ static int isSubset(int* arr1, int* arr2
return 1;
}
+/*
static
void printCS(CS cs){
int i;
@@ -190,6 +191,7 @@ void printCS(CS cs){
}
printf("\n");
}
+*/
/*
* Get the maximum frequent CSs from a CSset
@@ -200,8 +202,9 @@ void getMaximumFreqCSs(CSset *freqCSset)
int numCS = freqCSset->numCSadded;
int i, j;
+ int numMaxCSs = 0;
- printf("Maximum frequent CSs: \n");
+ printf("Retrieving maximum frequent CSs: \n");
for (i = 0; i < numCS; i++){
if (freqCSset->items[i].isSubset == 1) continue;
@@ -220,8 +223,12 @@ void getMaximumFreqCSs(CSset *freqCSset)
}
/* By the end, if this CS is not a subset of any other CS */
- if (freqCSset->items[i].isSubset == 0) printCS(
freqCSset->items[i]);
+ if (freqCSset->items[i].isSubset == 0){
+ numMaxCSs++;
+ //printCS( freqCSset->items[i]);
+ }
}
+ printf("Number of maximum CSs: %d \n", numMaxCSs);
}
@@ -263,6 +270,7 @@ static void getTopFreqCSs(map_t csmap, i
}
+/*
static void getStatisticCSsBySize(map_t csmap, int maximumNumP){
int* statCS;
@@ -274,7 +282,7 @@ static void getStatisticCSsBySize(map_t
hashmap_statistic_groupcs_by_size(csmap, statCS);
- /* Print the result */
+ // Print the result
printf(" --- Number of CS per size (Max = %d)--- \n", maximumNumP);
for (i = 1; i <= maximumNumP; i++){
@@ -283,7 +291,7 @@ static void getStatisticCSsBySize(map_t
free(statCS);
}
-
+*/
static void getStatisticCSsBySupports(map_t csmap, int maxSupport, char
isWriteToFile, char isCummulative){
@@ -339,7 +347,7 @@ RDFextractCS(int *ret, bat *sbatid, bat
int numP; /* Number of properties for current S */
map_t csMap;
int* buff;
- int INIT_PROPERTY_NUM = 50000;
+ int INIT_PROPERTY_NUM = 5000;
int maxNumProp = 0;
CSset *freqCSset; /* Set of frequent CSs */
@@ -367,7 +375,7 @@ RDFextractCS(int *ret, bat *sbatid, bat
bt = (oid *) BUNtloc(si, p);
if (*bt != curS){
if (p != 0){ /* Not the first S */
- putaCStoHash(csMap, buff, numP, &CSoid, 1,
*freqThreshold, freqCSset);
+ putaCStoHash(csMap, buff, numP, &CSoid, 1,
*freqThreshold, &freqCSset);
if (numP > maxNumProp)
maxNumProp = numP;
@@ -393,21 +401,21 @@ RDFextractCS(int *ret, bat *sbatid, bat
}
/*put the last CS */
- putaCStoHash(csMap, buff, numP, &CSoid, 1, *freqThreshold, freqCSset );
+ putaCStoHash(csMap, buff, numP, &CSoid, 1, *freqThreshold, &freqCSset
);
if (numP > maxNumProp)
maxNumProp = numP;
-
+ printf("Last CS oid is: %d \n", (int)CSoid);
printf("Number of frequent CSs is: %d \n", freqCSset->numCSadded);
/*get the statistic */
+ getTopFreqCSs(csMap,*freqThreshold);
+
getMaximumFreqCSs(freqCSset);
- getTopFreqCSs(csMap,20);
-
- getStatisticCSsBySize(csMap,maxNumProp);
+ //getStatisticCSsBySize(csMap,maxNumProp);
getStatisticCSsBySupports(csMap, 5000, 1, 0);
diff --git a/monetdb5/extras/rdf/rdfschema.h b/monetdb5/extras/rdf/rdfschema.h
--- a/monetdb5/extras/rdf/rdfschema.h
+++ b/monetdb5/extras/rdf/rdfschema.h
@@ -46,6 +46,4 @@ typedef struct CSset{
int numAllocation;
} CSset;
-CSset *freqCSs;
-
#endif /* _RDFSCHEMA_H_ */
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list