Changeset: 82e80ecf2dde for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=82e80ecf2dde
Modified Files:
monetdb5/extras/rdf/rdfschema.c
monetdb5/extras/rdf/rdfschema.h
sql/backends/monet5/sql.mx
Branch: rdf
Log Message:
Add key column for mvtables
diffs (119 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
@@ -5656,8 +5656,6 @@ void initCStables(CStableStat* cstablest
cstablestat->lastInsertedS[i] = (oid*) malloc(sizeof(oid) *
tmpNumDefaultCol);
cstablestat->lstcstable[i].numCol = tmpNumDefaultCol;
cstablestat->lstcstable[i].colBats = (BAT**)malloc(sizeof(BAT*)
* tmpNumDefaultCol);
- //cstablestat->lstcstable[i].mvBats =
(BAT**)malloc(sizeof(BAT*) * tmpNumDefaultCol);
- //cstablestat->lstcstable[i].mvExBats =
(BAT**)malloc(sizeof(BAT*) * tmpNumDefaultCol);
cstablestat->lstcstable[i].lstMVTables = (CSMVtableEx *)
malloc(sizeof(CSMVtableEx) * tmpNumDefaultCol); // TODO: Only allocate memory
for multi-valued columns
cstablestat->lstcstable[i].lstProp = (oid*)malloc(sizeof(oid) *
tmpNumDefaultCol);
cstablestat->lstcstable[i].colTypes = (ObjectType
*)malloc(sizeof(ObjectType) * tmpNumDefaultCol);
@@ -5699,7 +5697,11 @@ void initCStables(CStableStat* cstablest
cstablestat->lstcstable[i].lstMVTables[j].mvBats[mvColIdx] = BATnew(TYPE_void,
mapObjBATtypes[k], smallbatsz);
}
}
+
+ //Add a bat for storing FK to the main
table
+
cstablestat->lstcstable[i].lstMVTables[j].keyBat = BATnew(TYPE_void, TYPE_oid,
smallbatsz);
}
+
//BATseqbase(cstablestat->lstcstable[i].mvExBats[j], 0);
}
}
@@ -5797,6 +5799,7 @@ void freeCStableStat(CStableStat* cstabl
}
free(cstablestat->lstcstable[i].lstMVTables[j].mvBats);
free(cstablestat->lstcstable[i].lstMVTables[j].colTypes);
+
BBPunfix(cstablestat->lstcstable[i].lstMVTables[j].keyBat->batCacheid);
}
}
@@ -6056,6 +6059,7 @@ str RDFdistTriplesToCSs(int *ret, bat *s
int tmplastInsertedS = -1;
int numMultiValues = 0;
oid tmpmvValue;
+ oid tmpmvKey = BUN_NONE;
char istmpMVProp = 0;
char* schema = "rdf";
void* realObjValue = NULL;
@@ -6215,6 +6219,10 @@ str RDFdistTriplesToCSs(int *ret, bat *s
//printf("Insert the refered oid " BUNFMT "for
MV prop \n", tmpmvValue);
BUNappend(tmpBat, &tmpmvValue, TRUE);
//BATprint(tmpBat);
+
+ //Insert this "key" to the key column of mv
table.
+ tmpmvKey = tmpmvValue;
+
BUNappend(cstablestat->lstcstable[tblIdx].lstMVTables[tmpColIdx].keyBat,
&tmpmvKey, TRUE);
tmplastInsertedS = (int)tmpSoid;
lastColIdx = tmpColIdx;
@@ -6222,6 +6230,10 @@ str RDFdistTriplesToCSs(int *ret, bat *s
numMultiValues++;
}
+ else{
+ //Repeat referred "key" in the key column of
mvtable
+
BUNappend(cstablestat->lstcstable[tblIdx].lstMVTables[tmpColIdx].keyBat,
&tmpmvKey, TRUE);
+ }
continue;
}
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
@@ -237,6 +237,7 @@ typedef struct LabelStat{ /*Store the li
} LabelStat;
typedef struct CSMVtableEx { /* For non-default-type columns*/
+ BAT* keyBat; /* Key bat refers to corresponding
column in the main table*/
BAT** mvBats; /* The first is the default col, other
is ex-type-specific cols*/
ObjectType* colTypes;
int numCol;
diff --git a/sql/backends/monet5/sql.mx b/sql/backends/monet5/sql.mx
--- a/sql/backends/monet5/sql.mx
+++ b/sql/backends/monet5/sql.mx
@@ -7821,11 +7821,18 @@ SQLrdfreorganize(Client cntxt, MalBlkPtr
csmvtables[i][j] = mvc_create_table(m, sch,
tmptbname, tt_table, 0, SQL_PERSIST, 0, 3);
totalNoTablesCreated++;
+ //One column for key
+ sprintf(tmpcolname, "mvCol%dt%dpKey",i,j);
+ tmpbat =
cstablestat->lstcstable[i].lstMVTables[j].keyBat;
+ mvc_create_column(m, csmvtables[i][j],
tmpcolname, &tpes[tmpbat->ttype]);
+
+ //Value columns
for (k = 0; k < tmpNumMVCols; k++){
sprintf(tmpcolname,
"mvCol%dt%dp%dc",i,j,k);
tmpbat =
cstablestat->lstcstable[i].lstMVTables[j].mvBats[k];
mvc_create_column(m, csmvtables[i][j],
tmpcolname, &tpes[tmpbat->ttype]);
}
+
}
else
nonullmvtables++;
@@ -7876,6 +7883,14 @@ SQLrdfreorganize(Client cntxt, MalBlkPtr
if (tmpNumMVCols != 0){
sprintf(tmptbname, "mvtable%dp%d",i,j);
+ //One column for key
+ sprintf(tmpcolname, "mvCol%dt%dpKey",i,j);
+ tmpbat =
cstablestat->lstcstable[i].lstMVTables[j].keyBat;
+ store_funcs.append_col(m->session->tr,
+ mvc_bind_column(m,
csmvtables[i][j],tmpcolname),
+ tmpbat, TYPE_bat);
+
+ //Value columns
for (k = 0; k < tmpNumMVCols; k++){
sprintf(tmpcolname,
"mvCol%dt%dp%dc",i,j,k);
@@ -7884,7 +7899,7 @@ SQLrdfreorganize(Client cntxt, MalBlkPtr
//printf("MVColumn %d: \n",k);
//BATprint(tmpbat);
store_funcs.append_col(m->session->tr,
- mvc_bind_column(m,
csmvtables[i][j],tmpcolname ),
+ mvc_bind_column(m,
csmvtables[i][j],tmpcolname),
tmpbat, TYPE_bat);
}
}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list