Changeset: 12210fcd12be for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=12210fcd12be
Modified Files:
monetdb5/extras/rdf/hashmap/hashmap.c
monetdb5/extras/rdf/hashmap/hashmap.h
monetdb5/extras/rdf/rdfschema.c
Branch: rdf
Log Message:
Add function for collecting the number of CSs for a range of support values.
diffs (177 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
@@ -254,7 +254,6 @@ int hashmap_iterate_threshold(map_t in,
for(i = 0; i< m->table_size; i++)
if(m->data[i].in_use != 0) {
if (m->data[i].freq > freqthreshold){
- //any_t data = (any_t) (m->data[i].data);
count++;
}
}
@@ -263,6 +262,65 @@ int hashmap_iterate_threshold(map_t in,
/*
+ * Collect the number of CSs for each support value ranging
+ * from 1 to maxfreqthreshold
+ *
+ * */
+
+int hashmap_statistic_CSbysupport(map_t in, int* ret, int maxfreqthreshold){
+
+ int i ;
+
+ /* Cast the hashmap */
+ hashmap_map* m = (hashmap_map*) in;
+
+ /* On empty hashmap, return immediately */
+ if (hashmap_length(m) <= 0)
+ return MAP_MISSING;
+
+ /* Linear probing */
+ for(i = 0; i< m->table_size; i++)
+ if(m->data[i].in_use != 0) {
+ if (maxfreqthreshold > m->data[i].freq)
+ ret[m->data[i].freq]++;
+ }
+ return MAP_OK;
+}
+
+
+/*
+ * Collect the number of CSs cummulatively for support values ranging
+ * from 1 to maxfreqthreshold
+ *
+ * */
+
+int hashmap_statistic_CSbysupport_cummulative(map_t in, int* ret, int
maxfreqthreshold){
+
+ int i,j ;
+
+ /* Cast the hashmap */
+ hashmap_map* m = (hashmap_map*) in;
+
+ /* On empty hashmap, return immediately */
+ if (hashmap_length(m) <= 0)
+ return MAP_MISSING;
+
+ /* Linear probing */
+ for(i = 0; i< m->table_size; i++)
+ if(m->data[i].in_use != 0) {
+ if (maxfreqthreshold > m->data[i].freq)
+ for (j = 1; j <= m->data[i].freq; j++){
+ ret[j]++;
+ }
+ else
+ for (j = 1; j <= maxfreqthreshold ; j++){
+ ret[j]++;
+ }
+ }
+ return MAP_OK;
+}
+
+/*
* This function is retrieve list of <num of CSs with the same size>
* e.g., <3,4,5> ==> 3 CSs has size 1,
*
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
@@ -80,6 +80,23 @@ extern int hashmap_iterate_threshold(map
/*
+ * Collect the number of CSs for each support value ranging
+ * from 1 to maxfreqthreshold
+ *
+ * */
+
+int hashmap_statistic_CSbysupport_cummulative(map_t in, int* ret, int
maxfreqthreshold);
+
+
+/*
+ * Collect the number of CSs for each support value ranging
+ * from 1 to maxfreqthreshold
+ *
+ * */
+
+int hashmap_statistic_CSbysupport(map_t in, int* ret, int maxfreqthreshold);
+
+/*
* This function is retrieve list of <num of CSs with the same size>
* e.g., <3,4,5> ==> 3 CSs has size 1,
*
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
@@ -92,6 +92,8 @@ static void getStatisticCSsBySize(map_t
statCS = (int *) malloc(sizeof(int) * (maximumNumP + 1));
+ for (i = 0; i <= maximumNumP; i++) statCS[i] = 0;
+
hashmap_statistic_groupcs_by_size(csmap, statCS);
/* Print the result */
@@ -100,9 +102,52 @@ static void getStatisticCSsBySize(map_t
for (i = 1; i <= maximumNumP; i++){
printf("%d : %d \n", i, statCS[i]);
}
+
+ free(statCS);
}
+static void getStatisticCSsBySupports(map_t csmap, int maxSupport, char
isWriteToFile, char isCummulative){
+
+ int* statCS;
+ int i;
+ FILE *fout;
+
+ statCS = (int *) malloc(sizeof(int) * (maxSupport + 1));
+
+ for (i = 0; i <= maxSupport; i++) statCS[i] = 0;
+
+ if (isCummulative == 1)
+ hashmap_statistic_CSbysupport_cummulative(csmap, statCS,
maxSupport);
+ else
+ hashmap_statistic_CSbysupport(csmap, statCS, maxSupport);
+
+ /* Output the result */
+
+ if (isWriteToFile == 0){
+ printf(" --- Number of CS per support (Max = %d)--- \n",
maxSupport);
+ for (i = 1; i <= maxSupport; i++){
+ printf("%d : %d \n", i, statCS[i]);
+ }
+ }
+ else {
+ if (isCummulative == 1)
+ fout = fopen("cummulativeNumCSbySupport.txt","wt");
+ else
+ fout = fopen("numCSbySupport.txt","wt");
+
+ fprintf(fout, " --- Number of CS per support (Max = %d)--- \n",
maxSupport);
+
+ for (i = 1; i <= maxSupport; i++){
+ fprintf(fout, "%d\t:\t%d \n", i, statCS[i]);
+ }
+ fclose(fout);
+
+ }
+
+ free(statCS);
+}
+
str
RDFextractCS(int *ret, bat *sbatid, bat *pbatid){
BUN p, q;
@@ -177,6 +222,7 @@ RDFextractCS(int *ret, bat *sbatid, bat
getStatisticCSsBySize(csMap,maxNumProp);
+ getStatisticCSsBySupports(csMap, 5000, 1, 0);
BBPreclaim(sbat);
BBPreclaim(pbat);
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list