Changeset: bd5b0de9d3f2 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=bd5b0de9d3f2 Modified Files: sql/backends/monet5/sql.c sql/backends/monet5/sql_rdf.h sql/backends/monet5/sql_rdf_jgraph.c sql/server/rel_optimizer.c Branch: rdf Log Message:
More fix after merging with default branch. (Done with BSBM benchmark) - Fix the issue of pushing the projection up for simple renaming diffs (115 lines): 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 @@ -155,7 +155,7 @@ sql_symbol2relation(mvc *c, symbol *sym) if (1){ sT = clock(); - #if PRINT_FOR_DEBUG == 0 + #if PRINT_FOR_DEBUG //rel_print(c,r,0); printf("BEFORE running rel_optimizer\n"); _rel_print(c,r); @@ -167,7 +167,7 @@ sql_symbol2relation(mvc *c, symbol *sym) if (rel_is_point_query(r) || rel_need_distinct_query(r)) c->point_query = 1; - #if PRINT_FOR_DEBUG == 0 + #if PRINT_FOR_DEBUG printf("AFTER running rel_optimizer\n"); _rel_print(c,r); #endif diff --git a/sql/backends/monet5/sql_rdf.h b/sql/backends/monet5/sql_rdf.h --- a/sql/backends/monet5/sql_rdf.h +++ b/sql/backends/monet5/sql_rdf.h @@ -83,6 +83,6 @@ extern int need_handling_exception; #define RDF_HANDLING_EXCEPTION_POSSIBLE_TBL_OPT 1 /* Use the set of possible table for the set of required props to limit the number of matching subj Id */ -#define PRINT_FOR_DEBUG 0 +#define PRINT_FOR_DEBUG 1 #endif /*_SQL_RDF_H */ 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 @@ -743,6 +743,38 @@ const char *get_relname_from_basetable(s } +static +int in_nmap(nMap *nm, const char* rname){ + BUN bun; + bun = BUNfnd(nm->lmap,rname); + + if (bun == BUN_NONE){ + return 0; + } + else + return 1; +} + +/*This function is similar to the function + * rel_name in rel_select.c. But with the + * difference when get the name from column + * expression */ +static +const char *rel_name_rdf( sql_rel *r, nMap *nm) +{ + if (!is_project(r->op) && !is_base(r->op) && r->l) + return rel_name_rdf(r->l, nm); + if (r->exps && list_length(r->exps)) { + sql_exp *e = r->exps->h->data; + if (e->rname && in_nmap(nm, e->rname)) + return e->rname; + if (e->type == e_column && in_nmap(nm, (const char*) e->l)) + return e->l; + + + } + return NULL; +} /* * Get the name of the relation of each JG node @@ -1031,10 +1063,10 @@ void _add_join_edges(jgraph *jg, sql_rel //printf("Atom value %d \n",tmpCond); if (tmpCond == 1){ #if PRINT_FOR_DEBUG - printf("Join (condition 1) between %s and %s\n", rel_name((sql_rel*) rel->l), rel_name((sql_rel *)rel->r)); + printf("Join (condition 1) between %s and %s\n", rel_name_rdf((sql_rel*) rel->l, nm), rel_name_rdf((sql_rel *)rel->r,nm)); #endif - from = rname_to_nodeId(nm, rel_name((sql_rel*) rel->l)); - to = rname_to_nodeId(nm, rel_name((sql_rel*) rel->r)); + from = rname_to_nodeId(nm, rel_name_rdf((sql_rel*) rel->l,nm)); + to = rname_to_nodeId(nm, rel_name_rdf((sql_rel*) rel->r,nm)); if (have_same_subj(jg, from, to) == 1){ tmpjg = JP_S; } @@ -1064,8 +1096,8 @@ void _add_join_edges(jgraph *jg, sql_rel int from, to; JP tmpjp = JP_S; - relname1 = rel_name((sql_rel*) rel->l); - relname2 = rel_name((sql_rel*) rel->r); + relname1 = rel_name_rdf((sql_rel*) rel->l, nm); + relname2 = rel_name_rdf((sql_rel*) rel->r, nm); #if PRINT_FOR_DEBUG printf("CROSS PRODUCT HERE between %s and %s\n", relname1, relname2); diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c --- a/sql/server/rel_optimizer.c +++ b/sql/server/rel_optimizer.c @@ -4909,9 +4909,9 @@ rel_push_project_up(int *changes, mvc *s if (!l || rel_is_ref(l) || (is_join(rel->op) && (!r || rel_is_ref(r))) || (is_select(rel->op) && l->op != op_project) || - /* we cannot rewrite projection from outer joins */ - ((is_left(rel->op) || is_full(rel->op)) && r->op == op_project) || - ((is_right(rel->op) || is_full(rel->op)) && l->op == op_project) || + /* we cannot rewrite projection from outer joins - Disable for simple renaming */ + //((is_left(rel->op) || is_full(rel->op)) && r->op == op_project) || + //((is_right(rel->op) || is_full(rel->op)) && l->op == op_project) || (is_join(rel->op) && l->op != op_project && r->op != op_project) || ((l->op == op_project && (!l->l || l->r || project_unsafe(l))) || (is_join(rel->op) && (is_subquery(r) || _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list