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

Build triple-based (spo) relational table in which S's are ordered/grouped by 
CS.


diffs (127 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
@@ -10292,6 +10292,13 @@ void freeCStableStat(CStableStat* cstabl
        BBPunfix(cstablestat->pbat->batCacheid); 
        BBPunfix(cstablestat->sbat->batCacheid); 
        BBPunfix(cstablestat->obat->batCacheid); 
+#if TRIPLEBASED_TABLE
+       BBPunfix(cstablestat->resbat->batCacheid); 
+       BBPunfix(cstablestat->repbat->batCacheid); 
+       BBPunfix(cstablestat->reobat->batCacheid); 
+#endif
+
+
        free(cstablestat->lstbatid); 
        free(cstablestat->lastInsertedS); 
        free(cstablestat->lstcstable); 
@@ -11692,6 +11699,17 @@ RDFreorganize(int *ret, CStableStat *cst
        }       
        printf("Done  \n");
 
+       #if TRIPLEBASED_TABLE
+       printf("Build triple-based relational BATs .."); 
+       cstablestat->resbat = BATcopy(sNewBat, sNewBat->htype, sNewBat->ttype, 
TRUE, TRANSIENT);        
+       cstablestat->repbat = BATcopy(pNewBat, pNewBat->htype, pNewBat->ttype, 
TRUE, TRANSIENT);        
+       cstablestat->reobat = BATcopy(oNewBat, oNewBat->htype, oNewBat->ttype, 
TRUE, TRANSIENT);        
+       if (RDFtriplesubsort(&cstablestat->resbat, &cstablestat->repbat, 
&cstablestat->reobat) != MAL_SUCCEED){
+               throw(RDF, "rdf.RDFreorganize", "Problem in sorting reorganized 
SPO");
+       }
+       printf("Done\n");
+       #endif
+
        //BATprint(pNewBat);
        //BATprint(sNewBat);
 
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
@@ -37,7 +37,8 @@ struct CSmergeRel; // forward declaratio
 
 typedef enum{
        EXPLOREONLY, 
-       REORGANIZE
+       REORGANIZEONLY,
+       BUILDTABLE
 } ExpMode; 
 
 typedef enum{
@@ -396,6 +397,7 @@ typedef struct CStableEx {          /* For non-d
        oid             tblname;        /* Label of the table */
 } CStableEx; 
 
+#define TRIPLEBASED_TABLE 1
 
 typedef struct CStableStat {
        bat**           lstbatid;
@@ -412,6 +414,11 @@ typedef struct CStableStat {
        BAT*            pbat; 
        BAT*            sbat; 
        BAT*            obat; 
+#if TRIPLEBASED_TABLE
+       BAT*            resbat; /* Re-organized sbat */
+       BAT*            repbat; /* Re-organized pbat */
+       BAT*            reobat; /* Re-organized obat */
+#endif 
 } CStableStat; 
 
 typedef struct PropTypes{
diff --git a/sql/backends/monet5/sql_rdf.c b/sql/backends/monet5/sql_rdf.c
--- a/sql/backends/monet5/sql_rdf.c
+++ b/sql/backends/monet5/sql_rdf.c
@@ -771,6 +771,9 @@ SQLrdfreorganize(Client cntxt, MalBlkPtr
        sql_table       **viewcstables; 
        #endif
        sql_table       *psotbl;
+       #if TRIPLEBASED_TABLE   
+       sql_table       *respotbl;      /*reorganized spo table*/
+       #endif
        int     i, j, k, colId; 
        int     tmpNumMVCols = 0;
        int     nonullmvtables = 0;
@@ -822,7 +825,7 @@ SQLrdfreorganize(Client cntxt, MalBlkPtr
        printf ("Sql.mx: Reorganizing process process took %f seconds.\n", 
((float)(tmpendT - tmpbeginT))/CLOCKS_PER_SEC);
 
        //if (*mode == EXPLOREONLY){
-       if (*mode < 3){
+       if (*mode < BUILDTABLE){
                BBPunfix(sbat->batCacheid); 
                BBPunfix(pbat->batCacheid);
                BBPunfix(obat->batCacheid); 
@@ -855,7 +858,6 @@ SQLrdfreorganize(Client cntxt, MalBlkPtr
        mvc_create_column(m, psotbl, "s",  &tpe);
        mvc_create_column(m, psotbl, "o",  &tpe);
 
-
        store_funcs.append_col(m->session->tr,
                        mvc_bind_column(m, psotbl,"p" ), 
                        cstablestat->pbat, TYPE_bat);
@@ -866,6 +868,28 @@ SQLrdfreorganize(Client cntxt, MalBlkPtr
                        mvc_bind_column(m, psotbl,"o" ), 
                        cstablestat->obat, TYPE_bat);
        // Add regular triple to cstables and cstablesEx
+       
+       #if TRIPLEBASED_TABLE
+       printf("Create triple-based relational table ..."); 
+       respotbl = mvc_create_table(m, sch, "triples", tt_table, 0,
+                                                          SQL_PERSIST, 0, 3);
+       totalNoTablesCreated++;
+       mvc_create_column(m, respotbl, "s",  &tpe);
+       mvc_create_column(m, respotbl, "p",  &tpe);
+       mvc_create_column(m, respotbl, "o",  &tpe);
+
+       store_funcs.append_col(m->session->tr,
+                       mvc_bind_column(m, respotbl,"s" ), 
+                       cstablestat->resbat, TYPE_bat);
+       store_funcs.append_col(m->session->tr,
+                       mvc_bind_column(m, respotbl,"p" ), 
+                       cstablestat->repbat, TYPE_bat);
+       store_funcs.append_col(m->session->tr,
+                       mvc_bind_column(m, respotbl,"o" ), 
+                       cstablestat->reobat, TYPE_bat);
+       printf("Done\n");
+
+       #endif
 
        printf("Starting creating SQL Table -- \n");
        
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to