Changeset: e7fc748145f2 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e7fc748145f2
Modified Files:
        gdk/gdk_search.c
        monetdb5/modules/kernel/algebra.c
        monetdb5/modules/mal/mat.c
        monetdb5/modules/mal/pcre.c
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql_rdf_jgraph.c
        sql/benchmarks/tpch/alter.sql
Branch: rdf
Log Message:

Fix the problems causing by the changes in relational plan (after merging with 
default branch).


diffs (truncated from 336 to 300 lines):

diff --git a/gdk/gdk_search.c b/gdk/gdk_search.c
--- a/gdk/gdk_search.c
+++ b/gdk/gdk_search.c
@@ -404,7 +404,7 @@ BAThash(BAT *b, BUN masksize)
                                h = NULL;
                        }
                        /* create the hash structures */
-                       if ((h = HASHnew(hp, ATOMtype(b->ttype), 
BATcapacity(b), mask, BATcount(b))) == NULL) {
+                       if ((h = HASHnew(hp, ATOMtype(b->ttype), 
(b->S->restricted==BAT_READ)?BATcount(b):BATcapacity(b), mask, BATcount(b))) == 
NULL) {
 
                                MT_lock_unset(&GDKhashLock(abs(b->batCacheid)), 
"BAThash");
                                GDKfree(hp->filename);
diff --git a/monetdb5/modules/kernel/algebra.c 
b/monetdb5/modules/kernel/algebra.c
--- a/monetdb5/modules/kernel/algebra.c
+++ b/monetdb5/modules/kernel/algebra.c
@@ -344,6 +344,7 @@ ALGsubselect2(bat *result, const bat *bi
                BBPunfix(s->batCacheid);
        if (bn == NULL)
                throw(MAL, "algebra.subselect", GDK_EXCEPTION);
+       if (!(bn->batDirty&2)) BATsetaccess(bn, BAT_READ);
        *result = bn->batCacheid;
        BBPkeepref(bn->batCacheid);
        return MAL_SUCCEED;
@@ -374,6 +375,7 @@ ALGthetasubselect2(bat *result, const ba
                BBPunfix(s->batCacheid);
        if (bn == NULL)
                throw(MAL, "algebra.subselect", GDK_EXCEPTION);
+       if (!(bn->batDirty&2)) BATsetaccess(bn, BAT_READ);
        *result = bn->batCacheid;
        BBPkeepref(bn->batCacheid);
        return MAL_SUCCEED;
@@ -641,6 +643,10 @@ do_join(bat *r1, bat *r2, const bat *lid
        }
        *r1 = result1->batCacheid;
        *r2 = result2->batCacheid;
+       if (!(result1->batDirty&2))
+               BATsetaccess(result1, BAT_READ);
+       if (!(result2->batDirty&2))
+               BATsetaccess(result2, BAT_READ);
        BBPkeepref(*r1);
        BBPkeepref(*r2);
        BBPunfix(left->batCacheid);
@@ -939,6 +945,10 @@ ALGantijoin2( bat *l, bat *r, const bat 
        BBPunfix(R->batCacheid);
        if (ret == GDK_FAIL)
                throw(MAL, "algebra.antijoin", GDK_EXCEPTION);
+       if (!(j1->batDirty&2))
+               BATsetaccess(j1, BAT_READ);
+       if (!(j2->batDirty&2))
+               BATsetaccess(j2, BAT_READ);
        BBPkeepref(*l = j1->batCacheid);
        BBPkeepref(*r = j2->batCacheid);
        return MAL_SUCCEED;
@@ -993,6 +1003,10 @@ ALGjoin2( bat *l, bat *r, const bat *lef
                j2 = R;
                rmap = NULL;
        }
+       if (!(j1->batDirty&2))
+               BATsetaccess(j1, BAT_READ);
+       if (!(j2->batDirty&2))
+               BATsetaccess(j2, BAT_READ);
        BBPkeepref(*l = j1->batCacheid);
        BBPkeepref(*r = j2->batCacheid);
        return MAL_SUCCEED;
@@ -1018,6 +1032,10 @@ ALGthetajoin2( bat *l, bat *r, const bat
        BBPunfix(R->batCacheid);
        if (ret == GDK_FAIL)
                throw(MAL, "algebra.thetajoin", GDK_EXCEPTION);
+       if (!(j1->batDirty&2))
+               BATsetaccess(j1, BAT_READ);
+       if (!(j2->batDirty&2))
+               BATsetaccess(j2, BAT_READ);
        BBPkeepref(*l = j1->batCacheid);
        BBPkeepref(*r = j2->batCacheid);
        return MAL_SUCCEED;
@@ -1064,6 +1082,10 @@ ALGbandjoin2(bat *l, bat *r, const bat *
        BBPunfix(R->batCacheid);
        if (ret == GDK_FAIL)
                throw(MAL, "algebra.bandjoin", GDK_EXCEPTION);
+       if (!(bn1->batDirty&2))
+               BATsetaccess(bn1, BAT_READ);
+       if (!(bn2->batDirty&2))
+               BATsetaccess(bn2, BAT_READ);
        BBPkeepref(*l = bn1->batCacheid);
        BBPkeepref(*r = bn2->batCacheid);
        return MAL_SUCCEED;
@@ -1094,6 +1116,10 @@ ALGrangejoin2(bat *l, bat *r, const bat 
        BBPunfix(RH->batCacheid);
        if (ret == GDK_FAIL)
                throw(MAL, "algebra.rangejoin", GDK_EXCEPTION);
+       if (!(bn1->batDirty&2))
+               BATsetaccess(bn1, BAT_READ);
+       if (!(bn2->batDirty&2))
+               BATsetaccess(bn2, BAT_READ);
        BBPkeepref(*l = bn1->batCacheid);
        BBPkeepref(*r = bn2->batCacheid);
        return MAL_SUCCEED;
diff --git a/monetdb5/modules/mal/mat.c b/monetdb5/modules/mal/mat.c
--- a/monetdb5/modules/mal/mat.c
+++ b/monetdb5/modules/mal/mat.c
@@ -159,6 +159,7 @@ MATpackIncrement(Client cntxt, MalBlkPtr
                BATappend(bn,b,FALSE);
                assert(!bn->H->nil || !bn->H->nonil);
                assert(!bn->T->nil || !bn->T->nonil);
+               bn->H->align = (pieces-1);
                BBPkeepref(*ret = bn->batCacheid);
                BBPunfix(b->batCacheid);
        } else {
@@ -171,6 +172,9 @@ MATpackIncrement(Client cntxt, MalBlkPtr
                                BATseqbase(BATmirror(b), bb->T->seq);
                        BATappend(b,bb,FALSE);
                }
+               b->H->align--;
+               if(b->H->align == 0)
+                       BATsetaccess(b, BAT_READ);
                assert(!b->H->nil || !b->H->nonil);
                assert(!b->T->nil || !b->T->nonil);
                BBPkeepref(*ret = b->batCacheid);
diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c
--- a/monetdb5/modules/mal/pcre.c
+++ b/monetdb5/modules/mal/pcre.c
@@ -1336,6 +1336,7 @@ PCRElikesubselect2(bat *ret, const bat *
                return res;
        assert(bn);
        *ret = bn->batCacheid;
+       if (!(bn->batDirty&2)) BATsetaccess(bn, BAT_READ);
        BBPkeepref(bn->batCacheid);
        return MAL_SUCCEED;
 }
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
@@ -2095,6 +2095,7 @@ DELTAbat(bat *result, const bat *col, co
                BBPunfix(i->batCacheid);
        }
 
+       if (!(res->batDirty&2)) BATsetaccess(res, BAT_READ);
        BBPkeepref(*result = res->batCacheid);
        return MAL_SUCCEED;
 }
@@ -2214,6 +2215,7 @@ DELTAsub(bat *result, const bat *col, co
                res = u;
        }
        BATkey(BATmirror(res), TRUE);
+       if (!(res->batDirty&2)) BATsetaccess(res, BAT_READ);
        BBPkeepref(*result = res->batCacheid);
        return MAL_SUCCEED;
 }
@@ -2302,6 +2304,7 @@ DELTAproject(bat *result, const bat *sub
        BBPunfix(u_id->batCacheid);
        BBPunfix(u_val->batCacheid);
 
+       if (!(res->batDirty&2)) BATsetaccess(res, BAT_READ);
        BBPkeepref(*result = res->batCacheid);
        return MAL_SUCCEED;
 }
@@ -2378,6 +2381,7 @@ SQLtid(Client cntxt, MalBlkPtr mb, MalSt
                BBPunfix(diff->batCacheid);
                BBPunfix(d->batCacheid);
        }
+       if (!(tids->batDirty&2)) BATsetaccess(tids, BAT_READ);
        BBPkeepref(*res = tids->batCacheid);
        return MAL_SUCCEED;
 }
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
@@ -1004,12 +1004,16 @@ void get_col_name_from_p (char **col, ch
  *
  * E.g., s12_t0.o = oid[sys.rdf_strtoid(char(85) "<http://www/Product9>"]
  * will be convert to tbl1.p = oid[sys.rdf_strtoid(char(85) 
"<http://www/Product9>"]
+ * UPDATE: oid[s12_t0.o] = sys.rdf_strtoid(char(85) "<http://www/Product9>"
+ * will be convert to tbl1.p = type_of_column_p[sys.rdf_strtoid(char(85) 
"<http://www/Product9>"]
+ *
  * */
+
 static
 void modify_exp_col(mvc *c, sql_exp *m_exp,  char *_rname, char *_name, char 
*_arname, char *_aname, int update_e_convert){
-       sql_exp *e = NULL;
+       sql_exp *tmpe = NULL;
        sql_exp *ne = NULL;
-       sql_exp *re = NULL; //right expression, should be e_convert
+       sql_exp *le = NULL; //right expression, should be e_convert
        
        str rname = GDKstrdup(_rname); 
        str name = GDKstrdup(_name);
@@ -1020,57 +1024,55 @@ void modify_exp_col(mvc *c, sql_exp *m_e
        //exp_setname(sa, e, rname, name); 
        assert(m_exp->type == e_cmp); 
 
-       e = (sql_exp *)m_exp->l; 
-       assert(e->type == e_column); 
+       le = (sql_exp *)m_exp->l; 
+       assert(le->type == e_convert); 
 
-       ne = exp_column(c->sa, arname, aname, exp_subtype(e), exp_card(e), 
has_nil(e), 0);
+       tmpe = le->l; 
+
+       assert(tmpe->type == e_column); 
+
+       ne = exp_column(c->sa, arname, aname, exp_subtype(tmpe), 
exp_card(tmpe), has_nil(tmpe), 0);
 
        m_exp->l = ne; 
-       
+
        if (update_e_convert){
                //TODO: Convert subtype to the type of new col
                //sql_subtype *t;
-               sql_exp *l = NULL;
-               sql_exp *newre = NULL;
+               sql_exp *newle = NULL;
                sql_column *col = get_rdf_column(c, rname, name);
                sql_subtype totype = col->type;
-               re = (sql_exp *)m_exp->r;
 
-               l = exp_copy(c->sa,re->l);
-       
-               assert(re->type == e_convert && l); 
+               assert(le->type == e_convert && ne); 
                
-               newre = exp_convert(c->sa, l, exp_fromtype(re), &totype);
+               newle = exp_convert(c->sa, m_exp->r, exp_fromtype(le), &totype);
 
-               m_exp->r = newre; 
+               m_exp->r = newle; 
        }
-       
+
 }
 
 /*
  * oid[sys.rdf_strtoid(char(67) "<http://www/product>")] 
+ * UPDATE: sys.rdf_strtoid(char(67) "<http://www/product>")
  * returns <http://www/product>
  * */
 static 
 void extractURI_from_exp(mvc *c, char **uri, sql_exp *exp){
 
-       sql_exp *tmpexp, *tmpexp2;
+       sql_exp *tmpexp;
        node *tmpen; 
        str s;
        list *lst = NULL; 
 
-       assert(exp->type == e_convert);
+       assert(exp->type == e_func); 
 
-       tmpexp = (sql_exp *) exp->l;
-       assert(tmpexp->type == e_func); 
-
-       lst = tmpexp->l;
+       lst = exp->l;
        
        //There should be only one parameter for the function which is the 
property name
        tmpen = lst->h; 
-       tmpexp2 = (sql_exp *) tmpen->data;
+       tmpexp = (sql_exp *) tmpen->data;
                                
-       s = atom2string(c->sa, (atom *) tmpexp2->l); 
+       s = atom2string(c->sa, (atom *) tmpexp->l); 
        *uri = GDKstrdup(s); 
 
        //get_col_name_from_p (&col, s);
@@ -1080,6 +1082,8 @@ void extractURI_from_exp(mvc *c, char **
 
 /*
  * //Example: [s12_t0.p = oid[sys.rdf_strtoid(char(67) 
"<http://www/product>")], s12_t0.o = oid[sys.rdf_strtoid(char(85) 
"<http://www/Product9>"]
+ * // UPDATED: Example: [oid[s12_t0.p] = sys.rdf_strtoid(char(67) 
"<http://www/product>"), oid[s12_t0.o] = sys.rdf_strtoid(char(85) 
"<http://www/Product9>" 
+ *
  * */
 static 
 void get_predicate_from_exps(mvc *c, list *tmpexps, char **prop, char **subj){
@@ -1091,22 +1095,26 @@ void get_predicate_from_exps(mvc *c, lis
        assert (tmpexps != NULL);
        for (en = tmpexps->h; en; en = en->next){
                sql_exp *tmpexp = (sql_exp *) en->data; 
+               sql_exp *colexp = NULL;
 
                assert(tmpexp->type == e_cmp); //TODO: Handle other exps for 
op_select
                
                //Example: [s12_t0.p = oid[sys.rdf_strtoid(char(67) 
"<http://www/product>")], s12_t0.o = oid[sys.rdf_strtoid(char(85) 
"<http://www/Product9>"]
-               assert(((sql_exp *)tmpexp->l)->type == e_column); 
+               assert(((sql_exp *)tmpexp->l)->type == e_convert); 
 
+               colexp = ((sql_exp *)tmpexp->l)->l; 
+
+               assert(colexp->type == e_column); 
                //Check if the column name is p, then
                //extract the input property name
-               if (strcmp(((sql_exp *)tmpexp->l)->name, "p") == 0){
+               if (strcmp(colexp->name, "p") == 0){
 
                        num_p_cond++; 
                        extractURI_from_exp(c, prop, (sql_exp *)tmpexp->r);     
                        //In case the column name is not in the abstract table, 
add it
                        if (0) add_abstract_column(c, *prop);
 
-               } else if (strcmp(((sql_exp *)tmpexp->l)->name, "s") == 0) {
+               } else if (strcmp(colexp->name, "s") == 0) {
                        extractURI_from_exp(c, subj, (sql_exp *)tmpexp->r);     
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to