Changeset: d5f4ed3c4d79 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d5f4ed3c4d79
Modified Files:
        monetdb5/extras/rdf/rdf.h
        monetdb5/extras/rdf/rdfalgebra.c
        monetdb5/extras/rdf/rdfalgebra.mal
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql_rdf.h
Branch: rdf
Log Message:

Add rdf merge-join algorithm for the experiment


diffs (135 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
@@ -69,6 +69,9 @@ rdf_export str
 RDFexception_join(bat *ret1, bat *ret2, bat *sdense, bat *o1, bat *s2, bat 
*o2, bat *scand); 
 
 rdf_export str
+RDFdense_join(bat *ret1, bat *ret2, bat *sdenseid, bat *o1id, bat *scandid); 
+
+rdf_export str
 RDFmerge_join(bat *ret1, bat *ret2, bat *s1id, bat *o1id, bat *scandid); 
 
 #define RDF_MIN_LITERAL (((oid) 1) << ((sizeof(oid)==8)?59:27))
diff --git a/monetdb5/extras/rdf/rdfalgebra.c b/monetdb5/extras/rdf/rdfalgebra.c
--- a/monetdb5/extras/rdf/rdfalgebra.c
+++ b/monetdb5/extras/rdf/rdfalgebra.c
@@ -216,6 +216,80 @@ RDFexception_join(bat *ret1, bat *ret2, 
 }
 
 /* 
+ * This function performs the join given the set of S candidates with a dense 
S column
+ * NO exception handling
+ * Input: 
+ * - S1 BAT (dense bat), o1 BAT 
+ * */
+str 
+RDFdense_join(bat *ret1, bat *ret2, bat *sdenseid, bat *o1id, bat *scandid){
+       BAT *resS = NULL, *resO = NULL;         
+       BAT *sdense, *o1, *scand; 
+       oid *sdensept, *o1pt, *scandpt, *resSpt, *resOpt; 
+       BUN estimate  = 0; 
+       int cnt1 = 0, cntcand = 0; 
+       int i = 0; 
+       BUN min_sdense, max_sdense; 
+       int rescnt = 0;
+
+       if ((sdense = BATdescriptor(*sdenseid)) == NULL) {
+               throw(MAL, "rdf.RDFexception_join", RUNTIME_OBJECT_MISSING);
+       }
+       if ((o1 = BATdescriptor(*o1id)) == NULL) {
+               BBPunfix(sdense->batCacheid); 
+               throw(MAL, "rdf.RDFexception_join", RUNTIME_OBJECT_MISSING);
+       }
+       if ((scand = BATdescriptor(*scandid)) == NULL) { 
+               BBPunfix(sdense->batCacheid); 
+               BBPunfix(o1->batCacheid);       
+               throw(MAL, "rdf.RDFexception_join", RUNTIME_OBJECT_MISSING);
+       }
+
+       sdensept = (oid *) Tloc(sdense, BUNfirst(sdense));
+       o1pt = (oid *) Tloc(o1, BUNfirst(o1)); 
+       scandpt = (oid *) Tloc(scand, BUNfirst(scand)); 
+
+       /*Estimate the total size of the output = the size of 
+         the candidate BAT and the exception BAT */
+
+       estimate = BATcount(scand);  
+
+       resS = BATnew(TYPE_void, TYPE_oid, estimate, TRANSIENT);
+       resO = BATnew(TYPE_void, TYPE_oid, estimate, TRANSIENT);
+       resSpt = (oid *) Tloc(resS, BUNfirst(resS)); 
+       resOpt = (oid *) Tloc(resO, BUNfirst(resO));
+
+       cnt1 = (int) BATcount(sdense); 
+       cntcand = (int) BATcount(scand); 
+       min_sdense = sdensept[0]; 
+       max_sdense = sdensept[cnt1-1]; 
+
+       i = 0;
+       //printf("Number of cand = %d | Number of input = %d | Number of 
exception = %d\n", cntcand, cnt1, cnt2);       
+
+       while (i < cntcand){
+               //fetch the result from dense
+               if (scandpt[i] >= min_sdense && scandpt[i] <= max_sdense){
+                       resSpt[rescnt] = scandpt[i]; 
+                       resOpt[rescnt] = o1pt[scandpt[i] - min_sdense]; 
+                       rescnt++;
+               }
+               i++; 
+       }
+
+       //printf("Number of results %d\n", rescnt);     
+       BATsetcount(resS,rescnt);
+       BATsetcount(resO,rescnt);
+       *ret1 = resS->batCacheid;
+       *ret2 = resO->batCacheid; 
+       BBPkeepref(*ret1);
+       BBPkeepref(*ret2);
+
+       return MAL_SUCCEED; 
+}
+
+
+/* 
  * This function performs the join given the set of S candidates with a S 
column
  * considering the exception data. 
  * Input: 
diff --git a/monetdb5/extras/rdf/rdfalgebra.mal 
b/monetdb5/extras/rdf/rdfalgebra.mal
--- a/monetdb5/extras/rdf/rdfalgebra.mal
+++ b/monetdb5/extras/rdf/rdfalgebra.mal
@@ -33,6 +33,10 @@ command rdf_exception_join(s1:bat[:oid],
 address RDFexception_join
 comment "Union join with the input consists of a dense S bat and an exception 
S. The output are two BATs S and O of satisfied S and corresponding O's"
 
+command rdf_dense_join(s1:bat[:oid], o1:bat[:oid], 
scand:bat[:oid])(:bat[:oid],:bat[:oid])
+address RDFdense_join
+comment "Join with dense gAT. s1 is the dense BAT"
+
 command rdf_merge_join(s1:bat[:oid], o1:bat[:oid], 
scand:bat[:oid])(:bat[:oid],:bat[:oid])
 address RDFmerge_join
 comment "Merge join between a set of candidate S's and . The output are two 
BATs S and O of statisfied S and corresponding O's"
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -177,7 +177,9 @@ sql_symbol2relation(mvc *c, symbol *sym)
                #endif
                eT = clock(); 
                printf("----- Optimization time: %f mseconds.\n", 
1000*((float)(eT - sT))/CLOCKS_PER_SEC);
-               
+               #if ONLY_COMPUTE_OPT_TIME
+               return NULL; 
+               #endif
                }
        }
        return r;
diff --git a/sql/backends/monet5/sql_rdf.h b/sql/backends/monet5/sql_rdf.h
--- a/sql/backends/monet5/sql_rdf.h
+++ b/sql/backends/monet5/sql_rdf.h
@@ -89,4 +89,6 @@ extern int need_handling_exception;
 
 #define PRINT_FOR_DEBUG 0
 
+#define ONLY_COMPUTE_OPT_TIME 0
+
 #endif /*_SQL_RDF_H */
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to