Changeset: 061ee11850cb for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=061ee11850cb
Modified Files:
monetdb5/extras/rdf/rdfdump.c
monetdb5/extras/rdf/rdfdump.h
sql/backends/monet5/sql_rdf.c
Branch: rdf
Log Message:
generate mv col name for future use in handling exception
diffs (truncated from 359 to 300 lines):
diff --git a/monetdb5/extras/rdf/rdfdump.c b/monetdb5/extras/rdf/rdfdump.c
--- a/monetdb5/extras/rdf/rdfdump.c
+++ b/monetdb5/extras/rdf/rdfdump.c
@@ -46,6 +46,8 @@ static csdumBATdef csdumBatdefs[N_CSDUM_
{csd_fullC_name, "fullC_name_dump", TYPE_void, TYPE_str}, //Name
of each column
{csd_isMV, "isMVBat_dump", TYPE_void, TYPE_int}, // 0 indicating
single-valued column, otherwise > 0
// the value is
the number of column in MVtable
+ {csd_mv_tbl_name, "mvtblname_dump", TYPE_void, TYPE_str}, //
Table name of a mv col
+ {csd_mv_defaultcol_name, "mvdefaultcolname_dump", TYPE_void, TYPE_str},
//Name of default type col in the mv table
{csd_cname, "cIdxBat_dump", TYPE_void, TYPE_int} //Index of the
col in the table
};
@@ -152,10 +154,19 @@ void dumpCS(CSDump *csdump, int _freqId,
for (i = 0; i < cstbl.numCol; i++){
str tmpColName = (char *) malloc(sizeof(char) * 100);
+ str tmptblMVName = (char *) malloc(sizeof(char) * 100);
+ str tmpmvdefaultcolname = (char *) malloc(sizeof(char) * 100);
+
lstIsMV[i] = cstbl.lstMVTables[i].numCol;
lstColbat[i] = cstbl.colBats[i]->batCacheid;
getColSQLname(tmpColName, i, -1, cstbl.lstProp[i], mapi, mbat);
+ getMvTblSQLname(tmptblMVName, tblId, i, tblname,
cstbl.lstProp[i], mapi, mbat);
+ getColSQLname(tmpmvdefaultcolname, i, 0, cstbl.lstProp[i],
mapi, mbat); //only get default-type mv col
+
BUNappend(csdump->dumpBats[csd_fullC_name], tmpColName, TRUE);
+ BUNappend(csdump->dumpBats[csd_mv_tbl_name], tmptblMVName,
TRUE);
+ BUNappend(csdump->dumpBats[csd_mv_defaultcol_name],
tmpmvdefaultcolname, TRUE);
+
}
appendIntArrayToBat(csdump->dumpBats[csd_isMV], lstIsMV, cstbl.numCol);
@@ -232,7 +243,7 @@ void freeCSDump(CSDump *csdump){
static
-SimpleCS *create_simpleCS(int tblId, oid tblname, str tblsname, int freqId,
int numP, oid* lstProp, int numC, oid* lstCol, bat *lstColbat, str *lstColname,
int* lstIsMV, int sup, int cov){
+SimpleCS *create_simpleCS(int tblId, oid tblname, str tblsname, int freqId,
int numP, oid* lstProp, int numC, oid* lstCol, bat *lstColbat, str *lstColname,
int* lstIsMV, str *lstMVtblname, str *lstMVdefaultcolname, int sup, int cov){
SimpleCS *cs;
cs = (SimpleCS *) malloc(sizeof(SimpleCS));
cs->tblId = tblId;
@@ -257,6 +268,9 @@ SimpleCS *create_simpleCS(int tblId, oid
cs->lstIsMV = (int *) malloc(sizeof(int) * numC);
copyIntSet(cs->lstIsMV, lstIsMV, numC);
+ cs->lstmvtblname = lstMVtblname;
+ cs->lstmvdefaultcolname = lstMVdefaultcolname;
+
cs->sup = sup;
cs->cov = cov;
@@ -274,6 +288,20 @@ void free_simpleCS(SimpleCS *cs){
}
GDKfree(cs->lstColname);
}
+ if (cs->lstmvtblname){
+ int i;
+ for (i = 0; i < cs->numC; i++){
+ GDKfree(cs->lstmvtblname[i]);
+ }
+ GDKfree(cs->lstmvtblname);
+ }
+ if (cs->lstmvdefaultcolname){
+ int i;
+ for (i = 0; i < cs->numC; i++){
+ GDKfree(cs->lstmvdefaultcolname[i]);
+ }
+ GDKfree(cs->lstmvdefaultcolname);
+ }
GDKfree(cs->tblsname);
free(cs);
}
@@ -290,7 +318,9 @@ SimpleCS* read_a_cs_from_csdump(int pos,
bat *lstColbat = NULL;
int *lstIsMV = NULL;
str *lstColname = NULL;
- BATiter cname_mapi, tblsname_mapi;
+ str *lstMVtblname = NULL;
+ str *lstMVdefaultcolname = NULL;
+ BATiter cname_mapi, tblsname_mapi, mvnamei, mvcolnamei;
int i;
SimpleCS *cs;
@@ -343,16 +373,28 @@ SimpleCS* read_a_cs_from_csdump(int pos,
lstColname = (str *)malloc(sizeof(str) * numC);
+ lstMVtblname = (str *)malloc(sizeof(str) * numC);
+
+ lstMVdefaultcolname = (str *)malloc(sizeof(str) * numC);
+
cname_mapi = bat_iterator(csdump->dumpBats[csd_fullC_name]);
+ mvnamei = bat_iterator(csdump->dumpBats[csd_mv_tbl_name]);
+
+ mvcolnamei = bat_iterator(csdump->dumpBats[csd_mv_defaultcol_name]);
+
for (i = 0; i < numC; i++){
str tmpStr = (str) BUNtail(cname_mapi,
BUNfirst(csdump->dumpBats[csd_fullC_name]) + (BUN) (*offsetC + i));
+ str tmpMVname = (str) BUNtail(mvnamei,
BUNfirst(csdump->dumpBats[csd_mv_tbl_name]) + (BUN) (*offsetC + i));
+ str tmpMVcolname = (str) BUNtail(mvcolnamei,
BUNfirst(csdump->dumpBats[csd_mv_defaultcol_name]) + (BUN) (*offsetC + i));
lstColname[i] = GDKstrdup(tmpStr);
+ lstMVtblname[i] = GDKstrdup(tmpMVname);
+ lstMVdefaultcolname[i] = GDKstrdup(tmpMVcolname);
}
- cs = create_simpleCS(*tblId, *tblname, tblsname, *freqId, numP,
lstProp, numC, lstCol, lstColbat, lstColname, lstIsMV, *freq, *coverage);
+ cs = create_simpleCS(*tblId, *tblname, tblsname, *freqId, numP,
lstProp, numC, lstCol, lstColbat, lstColname, lstIsMV, lstMVtblname,
lstMVdefaultcolname, *freq, *coverage);
return cs;
}
diff --git a/monetdb5/extras/rdf/rdfdump.h b/monetdb5/extras/rdf/rdfdump.h
--- a/monetdb5/extras/rdf/rdfdump.h
+++ b/monetdb5/extras/rdf/rdfdump.h
@@ -38,6 +38,8 @@ typedef enum {
csd_fullC_batIds,
csd_fullC_name,
csd_isMV,
+ csd_mv_tbl_name,
+ csd_mv_defaultcol_name,
csd_cname
} csdumBatType;
@@ -70,6 +72,8 @@ typedef struct SimpleDumpCS {
bat *lstColbat;
str *lstColname;
int *lstIsMV; //Whether the column is multi-valued column or not
+ str *lstmvtblname;
+ str *lstmvdefaultcolname;
int sup;
int cov;
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
@@ -1528,6 +1528,27 @@ void get_full_outerjoin_p_slices(oid *ls
}
}
+
+static
+void next(BAT *r_sbat, BAT **r_obats, oid **obatCursors, oid
**regular_obat_cursors, oid **regular_obat_mv_cursors, int cur_p, int np){
+
+ if (obatCursors[j][pos] == oid_nil){
+ Look for the result from regular bat.
+ Check if the regular bat is pointing to a MVBat
+ Then, get all teh value from MVBATs
+ }
+ else{
+
+ }
+
+ for (int i = 0; i < numofresult; i++){
+ if (cur_p < (np -1)){
+ next (r_sbat, r_obats, sbat, obats, cur_p + 1, np);
+ }
+
+ //Output
+ }
+}
/*
* Combine exceptioins and regular tables
* */
@@ -1536,49 +1557,127 @@ static
void combine_exception_and_regular_tables(mvc *c, BAT **r_sbat, BAT
***r_obats, BAT *sbat, BAT **obats, oid *lstProps, int nP, int nRP){
oid *sbatCursor;
oid **obatCursors;
- int i, j;
+ int i, j, pos;
int numS;
char *schema = "rdf";
+ int curtid = -1;
+ BAT **regular_obats = NULL;
+ BAT **regular_obat_mv = NULL;
+ oid **regular_obat_cursors = NULL;
+ oid **regular_obat_mv_cursors = NULL; //If this column is MV col,
then store the point to its MV BAT
+ int accept = 0;
+ int nAdded = 0; //Number of tuples added to the output
+ oid *r_set = NULL; //Set of output values
(void) r_sbat;
(void) r_obats;
(void) nRP;
+ //Init return BATs
+ *r_sbat = BATnew(TYPE_void, TYPE_oid, BATcount(sbat), TRANSIENT);
+ *r_obats = (BAT **) malloc(sizeof(BAT*) * nP);
+ for (i = 0; i < nP; i++){
+ (*r_obats)[i] = BATnew(TYPE_void, TYPE_oid, BATcount(sbat),
TRANSIENT);
+ }
+
+
sbatCursor = (oid *) Tloc(sbat, BUNfirst(sbat));
obatCursors = (oid **) malloc(sizeof(oid*) * nP);
+ regular_obat_cursors = (oid **) malloc(sizeof(oid*) * nP);
for (i = 0; i < nP; i++){
obatCursors[i] = (oid *) Tloc(obats[i], BUNfirst(obats[i]));
assert (BATcount(obats[i]) == BATcount(sbat));
+ regular_obat_cursors[i] = NULL;
}
+
+ regular_obats = (BAT **) malloc(sizeof(BAT *) * nP);
+ regular_obat_mv = (BAT **) malloc(sizeof(BAT *) * nP);
numS = BATcount(sbat);
- for (i = 0; i < numS; i++){
- oid sbt = sbatCursor[i];
+ for (pos = 0; pos < numS; pos++){
+ oid sbt = sbatCursor[pos];
int tid = -1;
oid tmpS = BUN_NONE;
getTblIdxFromS(sbt, &tid, &tmpS);
+ if (tid != curtid){
+ //reload BATs for that table
+ for (j = 0; j < nP; j++){
+ str tmpColname, tmptblname;
+ int colIdx = getColIdx_from_oid(tid,
global_csset, lstProps[j]);
+ if (colIdx == -1) {
+ regular_obats[j] = NULL;
+ regular_obat_mv[j] = NULL;
+ regular_obat_cursors[j] = NULL;
+ regular_obat_mv_cursors[j] = NULL;
+ continue;
+ }
+
+ tmpColname = getColumnName(global_csset, tid,
colIdx);
+ tmptblname =
(global_csset->items[tid])->tblsname;
+ tmpmvtblname =
(global_csset->items[tid])->lstmvtblname[colIdx];
+ tmpmvdefcolname =
(global_csset->items[tid])->lstmvdefaultcolname[colIdx];
+
+ //Unfix old one
+ if (regular_obats[j]) {
+ BBPunfix(regular_obats[j]->batCacheid);
+ regular_obats[j] = NULL;
+ }
+
+ if (regular_obat_mv[j]){
+
BBPunfix(regular_obat_mv[j]->batCacheid);
+ regular_obat_mv[j] = NULL;
+ }
+
+ regular_obats[j] = mvc_bind(c, schema,
tmptblname, tmpColname, 0);
+ assert(regular_obats[j] != NULL);
+ regular_obat_cursors[j] = (oid *)
Tloc(regular_obats[j], BUNfirst(regular_obats[j]));
+
+ regular_obat_mv[j] = mvc_bind(c, schema,
tmpmvtblname, tmpmvdefcolname, 0);
+ regular_obat_mv_cursors[j] = (oid *)
Tloc(regular_obat_mv[j], BUNfirst(regular_obat_mv[j]));
+
+ }
+ }
+
printf("At row "BUNFMT" of table %d\n", tmpS, tid);
+ accept = 1;
for (j = 0; j < nP; j++){
- if (obatCursors[i][j] == oid_nil){
+ if (obatCursors[j][pos] == oid_nil){
+ if (regular_obat_cursors[j] == NULL){ //No
corresponding regular column
+ accept = 0;
+ break;
+ }
//Look for the value from main table
- int colIdx = getColIdx_from_oid(tid,
global_csset, lstProps[j]);
- str tmpColname = getColumnName(global_csset,
tid, colIdx);
- str tmptblname =
(global_csset->items[tid])->tblsname;
- BAT *regular_obat = NULL;
+ if (regular_obat_cursors[j][tmpS] == oid_nil) {
+ //TODO: Continue if this [j] is
optional prop
+ accept = 0;
+ break;
+ }
+ }
+ }
- assert(colIdx != -1);
- regular_obat = mvc_bind(c, schema, tmptblname,
tmpColname, 0);
- if (regular_obat == NULL) printf("There is no
BAT binding for table %s and column %s \n", tmptblname, tmpColname);
- }
+ if (accept == 1){ //Accept, can insert to the output bat
+ for (j = 0; j < np; j++){
+
+ }
+
+ nAdded++;
}
+
}
-
+
+ //free
+ for (i = 0; i < nP; i++){
+ if (regular_obats[i]) BBPunfix(regular_obats[j]->batCacheid);
+ }
+ free(regular_obats);
+ free(regular_obat_cursors);
}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list