Changeset: 95fb5fe047c0 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=95fb5fe047c0
Modified Files:
sql/backends/monet5/rel_bin.c
sql/backends/monet5/sql_rdf.c
sql/backends/monet5/sql_rdf_jgraph.c
sql/server/rel_rdfscan.c
sql/server/rel_rdfscan.h
Branch: rdf
Log Message:
Fix the wrong order of column.
This wrong order is caused by a problem in rel2_bin when matching the alias and
real column names.
diffs (222 lines):
diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -1244,10 +1244,10 @@ rel2bin_table( mvc *sql, sql_rel *rel, l
for(i=0, en = rel->exps->h, n = f->res->h; en; en =
en->next, n = n->next, i++ ) {
sql_exp *exp = en->data;
sql_subtype *st = n->data;
- char *rnme = exp->rname?exp->rname:exp->l;
+ //char *rnme = exp->l?exp->l:exp->rname;
stmt *s = stmt_rs_column(sql->sa, psub, i, st);
- s = stmt_alias(sql->sa, s, rnme, exp->name);
+ s = stmt_alias(sql->sa, s, NULL, exp->r);
list_append(l, s);
}
} else {
@@ -1309,7 +1309,7 @@ rel2bin_table( mvc *sql, sql_rel *rel, l
stmt *s;
/* no relation names */
- if (exp->l)
+ if (exp->l) //DUC: CHECK exp->l==NULL
exp->l = NULL;
s = exp_bin(sql, exp, sub, NULL, NULL, NULL, NULL, NULL);
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
@@ -1650,10 +1650,30 @@ void get_full_outerjoin_p_slices(oid *ls
*/
}
-
+static void appendResult(BAT **r_obats, oid *tmpres, int np, oid sbt){
+ int j = 0;
+ (void) sbt;
+ for (j = 0; j < np; j++){
+ //Output result
+
+ if (sbt == (oid)3835096557682764 ){
+ printf(BUNFMT " | ", tmpres[j]);
+ }
+ /*
+ if (j == 1 && tmpres[j] == 62700365){
+ printf("[Debug]Append one more person \n");
+ }
+ */
+
+ BUNappend(r_obats[j], &(tmpres[j]), TRUE);
+ }
+
+ if (sbt == (oid)3835096557682764 ){
+ printf("\n");
+ }
+}
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 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
@@ -1681,10 +1701,7 @@ void fetch_result(BAT **r_obats, oid **o
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
- for (j = 0; j < np; j++){
- BUNappend(r_obats[j],
&(tmpres[j]), TRUE);
- }
+ appendResult(r_obats, tmpres, np, sbt);
}
}
@@ -1698,9 +1715,7 @@ void fetch_result(BAT **r_obats, oid **o
else if (cur_p == (np - 1)){
//Output result
- for (j = 0; j < np; j++){
- BUNappend(r_obats[j], &(tmpres[j]),
TRUE);
- }
+ appendResult(r_obats, tmpres, np, sbt);
}
}
@@ -1713,9 +1728,7 @@ void fetch_result(BAT **r_obats, oid **o
else if (cur_p == (np - 1)){
//Output result
- for (j = 0; j < np; j++){
- BUNappend(r_obats[j], &(tmpres[j]), TRUE);
- }
+ appendResult(r_obats, tmpres, np, sbt);
}
}
@@ -1845,10 +1858,7 @@ void combine_exception_and_regular_table
}
}
- //printf("At row "BUNFMT" of table %d for sbt "BUNFMT"...",
tmpS, tid, sbt);
- if (sbt == (oid)3835096557682764){
- printf("[DEBUG2] FOUND THAT SUBJECT HERE\n");
- }
+
accept = 1;
#if RDF_HANDLING_EXCEPTION_MISSINGPROP_OPT
for (j = 0; j < num_mp; j++){
@@ -1875,6 +1885,11 @@ void combine_exception_and_regular_table
}
+ //printf("At row "BUNFMT" of table %d for sbt "BUNFMT"...",
tmpS, tid, sbt);
+ if (sbt == (oid)3835096557682764 && accept == 1){
+ printf("[DEBUG2] THAT SUBJECT IS ACCEPTED\n");
+ }
+
if (accept == 1){ //Accept, can insert to the output bat
oid *tmpres = (oid *) malloc(sizeof(oid) * nP);
oid r_obat_oldsize = BATcount((*r_obats)[0]);
@@ -2029,6 +2044,23 @@ SQLrdfScan(Client cntxt, MalBlkPtr mb, M
BATprint_topn(m_obats[i], 5);
}
//BATprint(m_sbat);
+ if ((*nP) > 2){
+
+ oid *s_curs = (oid *) Tloc(m_sbat, BUNfirst(m_sbat));
+ oid *o_curs = (oid *) Tloc(m_obats[1],
BUNfirst(m_obats[1]));
+ int j = 0;
+ int count = 0;
+ for (j = 0; (oid)j < m_sbat->batCount; j++){
+ if (s_curs[j] == 3835096557682764 && o_curs[j]
== 62700365){
+ printf("[Debug] Having matching
results\n");
+ }
+ if (o_curs[j] == 62700365){
+ count++;
+ }
+ }
+ printf("The total number of matching results is %d\n",
count);
+
+ }
for (i = 0; i < (*nP); i++){
//BATprint(m_obats[i]);
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
@@ -2481,7 +2481,7 @@ sql_rel* build_rdfexception (mvc *c, int
his[i] = spprops->lst_o_constraints[i].hi;
}
- rel_rdfscan = rel_rdfscan_func(c, tbl, spprops->num,
nnodes_per_ijgroup[0], spprops->lstPropIds, los, his, spprops->exps);
+ rel_rdfscan = rel_rdfscan_func(c, tbl, spprops->num,
nnodes_per_ijgroup[0], spprops->lstPropIds, los, his, spprops->exps,
spprops->lstAlias);
//rel_rdfscan = rel_rdfscan_func(c, tbl, spprops->num,
nnodes_per_ijgroup[0], spprops->lstPropIds, los, his, NULL);
printf("\nRDFSCAN \n");
diff --git a/sql/server/rel_rdfscan.c b/sql/server/rel_rdfscan.c
--- a/sql/server/rel_rdfscan.c
+++ b/sql/server/rel_rdfscan.c
@@ -91,7 +91,7 @@ table_column_types(sql_allocator *sa, sq
}
sql_rel *
-rel_rdfscan_func(mvc *sql, sql_table *t, int numprop, int nRP, oid *lstprop,
oid *los, oid *his, list *sel_exps)
+rel_rdfscan_func(mvc *sql, sql_table *t, int numprop, int nRP, oid *lstprop,
oid *los, oid *his, list *sel_exps, char **lstAlias)
{
sql_rel *resbase;
sql_rel *res;
@@ -101,7 +101,8 @@ rel_rdfscan_func(mvc *sql, sql_table *t,
int i;
sql_schema *sys = mvc_bind_schema(sql, "sys");
sql_subfunc *f = sql_find_func(sql->sa, sys, "rdfscan", -1, F_UNION,
NULL);
-
+
+ (void) lstAlias;
if (!f) /* we do expect copyfrom to be there */
return NULL;
@@ -129,18 +130,22 @@ rel_rdfscan_func(mvc *sql, sql_table *t,
for (n = t->columns.set->h; n; n = n->next) {
sql_column *c = n->data;
if (c->base.name[0] != '%'){
- append(exps, exp_column(sql->sa, t->base.name,
c->base.name, &c->type, CARD_MULTI, c->null, 0));
- //str s_or_o = NULL;
- //int idx = i % 2;
- //s_or_o = strlen((str)objStr);
- //append(exps, exp_alias(sql->sa, lstAlias[idx],
s_or_o, t->base.name, c->base.name, &c->type, CARD_MULTI, c->null, 0));
+ char *s = "s";
+ char *o = "o";
+ int idx = (int) i / 2;
+ str alias = GDKstrdup(lstAlias[idx]);
+ sql_exp* e = exp_column(sql->sa, NULL, c->base.name,
&c->type, CARD_MULTI, c->null, 0);
+
+ exp_setname(sql->sa, e, alias, ((i%2)==0)?s:o);
+ append(exps, e);
}
- //i++;
+ i++;
}
resbase = rel_table_func(sql->sa, NULL, import, exps, 1);
- if (0) res = rel_select_copy(sql->sa, resbase, sel_exps);
- (void) res;
- //return res;
- return resbase;
+ if (1){ res = rel_select_copy(sql->sa, resbase, sel_exps);
+ return res;
+ } else {
+ return resbase;
+ }
}
diff --git a/sql/server/rel_rdfscan.h b/sql/server/rel_rdfscan.h
--- a/sql/server/rel_rdfscan.h
+++ b/sql/server/rel_rdfscan.h
@@ -18,7 +18,7 @@ extern void free_rdf_rel_prop(rdf_rel_pr
extern rdf_rel_prop *init_rdf_rel_prop(int ncol, int n_ijgroup, int
*nnodes_per_ijgroup);
-extern sql_rel *rel_rdfscan_func(mvc *sql, sql_table *t, int numprop, int
numRP, oid *lstprops, oid *los, oid *his, list *exps);
+extern sql_rel *rel_rdfscan_func(mvc *sql, sql_table *t, int numprop, int
numRP, oid *lstprops, oid *los, oid *his, list *exps, char **lstAlias);
#endif /*_REL_RDFSCAN_H_*/
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list