Changeset: 5741e439d1f8 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5741e439d1f8
Modified Files:
monetdb5/extras/rdf/hashmap/hashmap.c
monetdb5/extras/rdf/hashmap/hashmap.h
monetdb5/extras/rdf/rdf_shredder.mx
monetdb5/extras/rdf/rdfschema.c
Branch: rdf
Log Message:
Create function for collecting statistic on the set of CSs
- hashmap_statistic_groupcs_by_size
Group CS by size ==> get the number of CSs for each size
diffs (144 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
@@ -258,10 +258,40 @@ int hashmap_iterate_threshold(map_t in,
count++;
}
}
-
return count;
}
+
+/*
+ * This function is retrieve list of <num of CSs with the same size>
+ * e.g., <3,4,5> ==> 3 CSs has size 1,
+ *
+ * Note: size of ret >= maximum number of items (properties) in one CS
+ *
+ * */
+
+int hashmap_statistic_groupcs_by_size(map_t in, int* ret){
+
+ 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) {
+ ret[m->data[i].num]++;
+ }
+
+ return MAP_OK;
+}
+
+
+
/*
* Remove an element with that key from the map
*/
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
@@ -78,6 +78,17 @@ extern int hashmap_iterate(map_t in, PFa
* */
extern int hashmap_iterate_threshold(map_t in, int freqthreshold);
+
+/*
+ * This function is retrieve list of <num of CSs with the same size>
+ * e.g., <3,4,5> ==> 3 CSs has size 1,
+ *
+ * Note: size of ret >= maximum number of items (properties) in one CS
+ *
+ * */
+
+extern int hashmap_statistic_groupcs_by_size(map_t in, int* ret);
+
/*
* Add an element to the hashmap. Return MAP_OK or MAP_OMEM.
*/
diff --git a/monetdb5/extras/rdf/rdf_shredder.mx
b/monetdb5/extras/rdf/rdf_shredder.mx
--- a/monetdb5/extras/rdf/rdf_shredder.mx
+++ b/monetdb5/extras/rdf/rdf_shredder.mx
@@ -21,7 +21,7 @@ All Rights Reserved.
@c
/*
- * @a L.Sidirourgos
+ * @a L.Sidirourgos, Minh-Duc Pham
*
* @+ Shredder for RDF Documents
*/
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,6 +85,23 @@ static void getTopFreqCSs(map_t csmap, i
}
+static void getStatisticCSsBySize(map_t csmap, int maximumNumP){
+
+ int* statCS;
+ int i;
+
+ statCS = (int *) malloc(sizeof(int) * (maximumNumP + 1));
+
+ hashmap_statistic_groupcs_by_size(csmap, statCS);
+
+ /* Print the result */
+
+ printf(" --- Number of CS per size (Max = %d)--- \n", maximumNumP);
+ for (i = 1; i <= maximumNumP; i++){
+ printf("%d : %d \n", i, statCS[i]);
+ }
+}
+
str
RDFextractCS(int *ret, bat *sbatid, bat *pbatid){
@@ -99,6 +116,7 @@ RDFextractCS(int *ret, bat *sbatid, bat
map_t csMap;
int* buff;
int INIT_PROPERTY_NUM = 50000;
+ int maxNumProp = 0;
buff = (int *) malloc (sizeof(int) * INIT_PROPERTY_NUM);
@@ -122,6 +140,10 @@ RDFextractCS(int *ret, bat *sbatid, bat
if (*bt != curS){
if (p != 0){ /* Not the first S */
putCStoHash(csMap, buff, numP, &CSoid);
+
+ if (numP > maxNumProp)
+ maxNumProp = numP;
+
}
curS = *bt;
@@ -147,15 +169,13 @@ RDFextractCS(int *ret, bat *sbatid, bat
/*put the last CS */
putCStoHash(csMap, buff, numP, &CSoid);
+ if (numP > maxNumProp)
+ maxNumProp = numP;
+
/*get the statistic */
-
getTopFreqCSs(csMap,20);
- getTopFreqCSs(csMap,10);
-
- getTopFreqCSs(csMap,5);
-
- getTopFreqCSs(csMap,2);
+ getStatisticCSsBySize(csMap,maxNumProp);
BBPreclaim(sbat);
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list