Changeset: 22d5756f69ca for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=22d5756f69ca
Modified Files:
monetdb5/extras/rdf/rdfdump.c
monetdb5/extras/rdf/rdfdump.h
monetdb5/extras/rdf/rdftypes.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_rdf.c
sql/backends/monet5/sql_rdf_jgraph.c
Branch: rdf
Log Message:
Fix some problem in handling exceptions with OPTIONAL
diffs (truncated from 579 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
@@ -569,19 +569,20 @@ PropStat* getPropStat_C_simpleCSset(Simp
* Note that p may be in the list of column of that table as
* it may be refined while removing infrequent p.
* */
-Postinglist get_p_postingList(PropStat *propStat, oid p){
+Postinglist* get_p_postingList(PropStat *propStat, oid p){
BUN ppos = BUN_NONE;
- Postinglist ptl;
+ Postinglist *ptl = NULL;
//Get number of BATs for this p
ppos = BUNfnd(propStat->pBat, &p);
if (ppos == BUN_NONE){
fprintf(stderr, "The prop "BUNFMT" must be in propStat bat\n",
p);
+ } else {
+ ptl = (Postinglist *) malloc(sizeof(Postinglist));
+ *ptl = propStat->plCSidx[ppos];
}
-
- ptl = propStat->plCSidx[ppos];
return ptl;
}
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
@@ -104,7 +104,7 @@ rdf_export
PropStat* getPropStat_C_simpleCSset(SimpleCSset* csset);
rdf_export
-Postinglist get_p_postingList(PropStat *propStat, oid p);
+Postinglist* get_p_postingList(PropStat *propStat, oid p);
rdf_export
int getColIdx_from_oid(int tblId, SimpleCSset *csset, oid coloid);
diff --git a/monetdb5/extras/rdf/rdftypes.c b/monetdb5/extras/rdf/rdftypes.c
--- a/monetdb5/extras/rdf/rdftypes.c
+++ b/monetdb5/extras/rdf/rdftypes.c
@@ -608,6 +608,12 @@ static ObjectType getObjType_fromValRec(
void get_encodedOid_from_atom(atom *at, oid *ret){
ValRecord vrec = at->data;
ObjectType objT = getObjType_fromValRec(vrec);
+ oid Min_String_Oid = RDF_MIN_LITERAL;
+ Min_String_Oid |= (BUN)STRING << (sizeof(BUN)*8 - 4);
+ if (objT == URI && (oid)(vrec.val.lval) >= Min_String_Oid){
+ *ret = (oid)(vrec.val.lval);
+ return;
+ }
encodeValueInOid(&vrec, objT, ret);
}
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
@@ -139,6 +139,7 @@ sql_symbol2relation(mvc *c, symbol *sym)
}
if (1){
+ rel_print(c,r,0);
r = rel_optimizer(c, r);
r = rel_distribute(c, r);
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
@@ -1527,17 +1527,23 @@ void get_full_outerjoin_p_slices(oid *ls
for (i = 0; i < np; i++){
start = clock();
+ printf("Slides of P = "BUNFMT " with o constraints from
"BUNFMT" to " BUNFMT"\n", lstprops[i], los[i], his[i]);
getSlides_per_P(pso_propstat, &(lstprops[i]), los[i], his[i],
full_obat, full_sbat, &(obats[i]), &(sbats[i]));
end = clock();
- printf("Slides of P = "BUNFMT " with o constraints from
"BUNFMT" to " BUNFMT" [Took %f seconds)\n", lstprops[i], los[i], his[i],
((float)(end - start))/CLOCKS_PER_SEC);
if (sbats[i]){
printf(" contains "BUNFMT " rows in sbat\n",
BATcount(sbats[i]));
//BATprint(sbats[i]);
+ if (BATcount(sbats[i]) < 100){
+ BATprint(sbats[i]);
+ }
}
if (obats[i]){
printf(" contains "BUNFMT " rows in obat\n",
BATcount(obats[i]));
- //BATprint(obats[i]);
+ if (BATcount(obats[i]) < 100){
+ BATprint(obats[i]);
+ }
}
+ printf(" [Took %f seconds)\n",((float)(end -
start))/CLOCKS_PER_SEC);
}
start = clock();
@@ -1555,13 +1561,15 @@ void get_full_outerjoin_p_slices(oid *ls
static
-void fetch_result(BAT **r_obats, oid **obatCursors, int pos, oid
**regular_obat_cursors, oid **regular_obat_mv_cursors, BAT **regular_obats, BAT
**regular_obat_mv, oid sbt, oid tmpS, int cur_p, int np, oid *tmpres){
+void fetch_result(BAT **r_obats, oid **obatCursors, int pos, oid
**regular_obat_cursors, oid **regular_obat_mv_cursors, BAT **regular_obats, BAT
**regular_obat_mv, oid sbt, oid tmpS, int cur_p, int nrp, int np, oid *tmpres){
int j;
if (obatCursors[cur_p][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
- assert(regular_obat_cursors[cur_p][tmpS] != oid_nil);
+
+ assert(cur_p >= nrp || regular_obat_cursors[cur_p][tmpS] !=
oid_nil);
+
if (regular_obat_mv_cursors[cur_p] != NULL){ //mv col
//Get the values from mvBat
oid offset = regular_obat_cursors[cur_p][tmpS];
@@ -1579,7 +1587,7 @@ void fetch_result(BAT **r_obats, oid **o
tmpres[cur_p] =
regular_obat_mv_cursors[cur_p][offset + i];
if (cur_p < (np -1))
- fetch_result(r_obats, obatCursors, pos,
regular_obat_cursors, regular_obat_mv_cursors, regular_obats, regular_obat_mv,
sbt, tmpS, cur_p + 1, np, tmpres);
+ fetch_result(r_obats, obatCursors, pos,
regular_obat_cursors, regular_obat_mv_cursors, regular_obats, regular_obat_mv,
sbt, tmpS, cur_p + 1, nrp, np, tmpres);
else if (cur_p == (np - 1)){
//Output result
@@ -1591,10 +1599,11 @@ void fetch_result(BAT **r_obats, oid **o
}
else{
- tmpres[cur_p] = regular_obat_cursors[cur_p][tmpS];
+ if (regular_obat_cursors[cur_p] != NULL) tmpres[cur_p]
= regular_obat_cursors[cur_p][tmpS];
+ else tmpres[cur_p] = oid_nil;
if (cur_p < (np -1))
- fetch_result(r_obats, obatCursors, pos,
regular_obat_cursors, regular_obat_mv_cursors, regular_obats, regular_obat_mv,
sbt, tmpS, cur_p + 1, np, tmpres);
+ fetch_result(r_obats, obatCursors, pos,
regular_obat_cursors, regular_obat_mv_cursors, regular_obats, regular_obat_mv,
sbt, tmpS, cur_p + 1, nrp, np, tmpres);
else if (cur_p == (np - 1)){
//Output result
@@ -1609,7 +1618,7 @@ void fetch_result(BAT **r_obats, oid **o
tmpres[cur_p] = obatCursors[cur_p][pos];
if (cur_p < (np -1))
- fetch_result(r_obats, obatCursors, pos,
regular_obat_cursors, regular_obat_mv_cursors, regular_obats, regular_obat_mv,
sbt, tmpS, cur_p + 1, np, tmpres);
+ fetch_result(r_obats, obatCursors, pos,
regular_obat_cursors, regular_obat_mv_cursors, regular_obats, regular_obat_mv,
sbt, tmpS, cur_p + 1, nrp, np, tmpres);
else if (cur_p == (np - 1)){
//Output result
@@ -1710,7 +1719,7 @@ void combine_exception_and_regular_table
regular_obat_cursors[j] = NULL;
regular_obat_mv_cursors[j] = NULL;
#if
RDF_HANDLING_EXCEPTION_MISSINGPROP_OPT
- lst_missing_props[num_mp] = j;
+ if (j < nRP) lst_missing_props[num_mp]
= j;
num_mp++;
#endif
continue;
@@ -1755,7 +1764,7 @@ void combine_exception_and_regular_table
}
if (accept == 0) continue;
#endif
- for (j = 0; j < nP; j++){
+ for (j = 0; j < nRP; j++){
if (obatCursors[j][pos] == oid_nil){
if (regular_obat_cursors[j] == NULL){ //No
corresponding regular column
accept = 0;
@@ -1779,7 +1788,7 @@ void combine_exception_and_regular_table
for (j = 0; j < nP; j++){
tmpres[j] = oid_nil;
}
- fetch_result(*r_obats, obatCursors, pos,
regular_obat_cursors, regular_obat_mv_cursors, regular_obats, regular_obat_mv,
sbt, tmpS, 0, nP, tmpres);
+ fetch_result(*r_obats, obatCursors, pos,
regular_obat_cursors, regular_obat_mv_cursors, regular_obats, regular_obat_mv,
sbt, tmpS, 0, nRP, nP, tmpres);
r_obat_newsize = BATcount((*r_obats)[0]);
for (j = 0; j < (int)(r_obat_newsize - r_obat_oldsize);
j++){
BUNappend(*r_sbat, &sbt, TRUE);
@@ -2119,6 +2128,7 @@ void getOffsets(PsoPropStat *pso_pstat,
* */
void getSlides_per_P(PsoPropStat *pso_pstat, oid *p, oid lo_cst, oid hi_cst,
BAT *obat, BAT *sbat, BAT **ret_oBat, BAT **ret_sBat){
BUN l, h;
+ BAT *tmpB = NULL;
getOffsets(pso_pstat, p, &l, &h);
if (l != BUN_NONE){
@@ -2145,8 +2155,10 @@ void getSlides_per_P(PsoPropStat *pso_ps
hi = hi_cst;
}
//BATsubselect(inputbat, <dont know yet>,
lowValue, Highvalue, isIncludeLowValue, isIncludeHigh, <anti>
- *ret_oBat = BATsubselect(tmp_o, NULL, &lo, &hi,
1, 1, 0);
- *ret_sBat = BATproject(*ret_oBat, tmp_s);
+ tmpB = BATsubselect(tmp_o, NULL, &lo, &hi, 1,
1, 0);
+ *ret_oBat = BATproject(tmpB, tmp_o);
+ *ret_sBat = BATproject(tmpB, tmp_s);
+ BBPunfix(tmpB->batCacheid);
}
#else
*ret_oBat = tmp_o;
diff --git a/sql/backends/monet5/sql_rdf_jgraph.c
b/sql/backends/monet5/sql_rdf_jgraph.c
--- a/sql/backends/monet5/sql_rdf_jgraph.c
+++ b/sql/backends/monet5/sql_rdf_jgraph.c
@@ -205,7 +205,7 @@ sql_column* get_rdf_column(mvc *c, char
#if HANDLING_EXCEPTION
static
-sql_table *create_dummy_table(mvc *c, str tblname, list *proj_exps){
+sql_table *create_dummy_table(mvc *c, str tblname, list *proj_exps, int nump){
sql_table *tbl = NULL;
str schema = "rdf";
@@ -228,20 +228,36 @@ sql_table *create_dummy_table(mvc *c, st
}
//create columns
- for (en = proj_exps->h; en; en = en->next){
- sql_exp *tmpexp = (sql_exp *) en->data;
- sql_subtype *tpe;
- char colname[100];
-
- assert(tmpexp->type == e_column);
- tpe = exp_subtype(tmpexp);
- sprintf(colname, "dummy_%s_%s", tmpexp->rname, tmpexp->name);
- if (mvc_bind_column(c, tbl, colname) == NULL){
- mvc_create_column(c, tbl, colname, tpe);
+ if (proj_exps != NULL){ //Create the column based on the an existing
expression
+ for (en = proj_exps->h; en; en = en->next){
+ sql_exp *tmpexp = (sql_exp *) en->data;
+ sql_subtype *tpe;
+ char colname[100];
+
+ assert(tmpexp->type == e_column);
+ tpe = exp_subtype(tmpexp);
+ sprintf(colname, "dummy_%s_%s", tmpexp->rname,
tmpexp->name);
+ if (mvc_bind_column(c, tbl, colname) == NULL){
+ mvc_create_column(c, tbl, colname, tpe);
+ }
+ }
+ } else { //No existing expression
+ int i;
+ for (i = 0; i < nump; i++){
+ char colname_s[50], colname_o[50];
+ sql_subtype tpe;
+ sql_find_subtype(&tpe, "oid", 31, 0);
+ sprintf(colname_s, "dummy_col_s_%d", i);
+ sprintf(colname_o, "dummy_col_o_%d", i);
+ if (mvc_bind_column(c, tbl, colname_s) == NULL){
+ mvc_create_column(c, tbl, colname_s, &tpe);
+ }
+ if (mvc_bind_column(c, tbl, colname_o) == NULL){
+ mvc_create_column(c, tbl, colname_o, &tpe);
+ }
}
}
-
return tbl;
}
@@ -1305,6 +1321,7 @@ void get_o_constraint_value(mvc *c, sql_
//first: Convert the compared value into oid
newoid = BUN_NONE;
+
if (re->type == e_atom){
atom *at = re->l;
assert(at != NULL);
@@ -1817,13 +1834,20 @@ void get_matching_tbl_from_spprops(int *
printf("Table Id for set of props [");
for (i = 0; i < num; i++){
//Postinglist pl = get_p_postingList(global_p_propstat,
lstprop[i]);
- Postinglist pl = get_p_postingList(global_c_propstat,
lstprop[i]);
- tmptblId[i] = pl.lstIdx;
- count[i] = pl.numAdded;
- printf(" " BUNFMT, lstprop[i]);
+ Postinglist *pl = get_p_postingList(global_c_propstat,
lstprop[i]);
+ if (pl != NULL){
+ tmptblId[i] = pl->lstIdx;
+ count[i] = pl->numAdded;
+ printf(" " BUNFMT, lstprop[i]);
+ } else {
+ printf(" NO TABLE");
+ break;
+ }
+
}
- intersect_intsets(tmptblId, count, num, &tblId, &numtbl);
+ if (i == num) //All props have matching tabe
+ intersect_intsets(tmptblId, count, num, &tblId,
&numtbl);
printf(" ] --> ");
@@ -2291,8 +2315,9 @@ void get_removed_tid_exps(mvc *c, list *
* select from a table and mv_table if there is mv prop.
* - sp_prj_exps stores all the columns should be selected in the "original
order"
* */
+
static
-sql_rel* build_rdfexception_old (mvc *c, int tId, jgraph *jg, list
*union_rdfscan_exps, int nijgroup, int **ijgroup, int *nnodes_per_ijgroup){
+sql_rel* build_rdfexception (mvc *c, int tId, jgraph *jg, list
*union_rdfscan_exps, int nijgroup, int **ijgroup, int *nnodes_per_ijgroup,
spProps *spprops){
sql_rel *rel_rdfscan = NULL;
str tblname;
@@ -2305,23 +2330,33 @@ sql_rel* build_rdfexception_old (mvc *c,
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list