Changeset: 652cc2793b91 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/652cc2793b91
Modified Files:
        sql/backends/monet5/rel_physical.c
        sql/backends/monet5/rel_pphash.c
Branch: manti
Log Message:

one more condition for manti: the join involves more than one column
put back the generation of sys.not() for single column anti.


diffs (90 lines):

diff --git a/sql/backends/monet5/rel_physical.c 
b/sql/backends/monet5/rel_physical.c
--- a/sql/backends/monet5/rel_physical.c
+++ b/sql/backends/monet5/rel_physical.c
@@ -1010,7 +1010,8 @@ rel_pipeline(visitor *v, sql_rel *rel, b
                if (do_oahash_join(v, rel, &side)) {
                        list *eq_exps = sa_list(v->sql->sa);
                        list *other = sa_list(v->sql->sa);
-                       bool is_manti_with_null = list_length(rel->attr) == 1 
&& exp_is_atom(rel->attr->h->data) && !exp_is_true(rel->attr->h->data);
+                       /* manti: multi-column not-exist */
+                       bool manti = list_length(rel->attr) == 1 && 
list_length(rel->exps) > 1 && exp_is_atom(rel->attr->h->data) && 
!exp_is_true(rel->attr->h->data);
                        if (!list_empty(rel->attr))
                                rel->exps = get_simple_equi_joins_first(v->sql, 
rel, rel->exps);
                        split_join_exps(rel, eq_exps, other, true /* anti */, 
true /* eqonly */, false /* firstonly */);
@@ -1038,7 +1039,7 @@ rel_pipeline(visitor *v, sql_rel *rel, b
                                        rel->op == op_left ||
                                        rel->op == op_right ||
                                    rel_getcount(v->sql, r) < 
rel_getcount(v->sql, l) ||
-                                       is_manti_with_null)
+                                       manti)
                                        rel->oahash = 2;
                                else
                                        rel->oahash = 1;
@@ -1084,7 +1085,7 @@ rel_pipeline(visitor *v, sql_rel *rel, b
                                        rel_hsh->attr = cross?NULL:exps_cmp_hsh;
                                }
                                rel_prb->attr = cross?NULL:exps_cmp_prb;
-                               if (is_manti_with_null) {
+                               if (manti) {
                                        /* only hash the first join column, put 
the subsequent column(s) in the payload */
                                        // TODO (move no_nil join columns to 
the front?) hash the leading no_nil join columns
                                        assert(exps_cmp_hsh->cnt == 
exps_cmp_prb->cnt);
diff --git a/sql/backends/monet5/rel_pphash.c b/sql/backends/monet5/rel_pphash.c
--- a/sql/backends/monet5/rel_pphash.c
+++ b/sql/backends/monet5/rel_pphash.c
@@ -391,7 +391,7 @@ rel2bin_oahash_equi_join(backend *be, sq
        list *exps_prj_prb = rel_prb->exps;
        list *exps_prj_hsh = rel_hsh->exps;
 
-       bool groupedjoin = false, mark = false, marked_anti = false;
+       bool groupedjoin = false, mark = false, manti = false;
        if (!list_empty(rel->attr)) {
                groupedjoin = true;
                (void) groupedjoin;
@@ -399,21 +399,19 @@ rel2bin_oahash_equi_join(backend *be, sq
                sql_exp *e = rel->attr->h->data;
                if (exp_is_atom(e)) {
                mark = true;
-                               if (!exp_is_true(rel->attr->h->data)) {
-                                       marked_anti = true;
-                               }
+                               manti = !exp_is_true(rel->attr->h->data) && 
list_length(rel->exps) > 1;
                        }
                }
        }
-       assert((list_length(jexps) == list_length(exps_cmp_prb)) || 
(marked_anti && list_length(jexps) == 1 && list_length(jexps) <= 
list_length(exps_cmp_prb)));
+       assert((list_length(jexps) == list_length(exps_cmp_prb)) || (manti && 
list_length(jexps) == 1 && list_length(jexps) <= list_length(exps_cmp_prb)));
 
-       stmt *prb_res = oahash_probe(be, rel, jexps, exps_cmp_prb, stmts_ht, 
sub, marked_anti, mark /* groupjoin */, has_outerselect, nulls, prb_mrk);
+       stmt *prb_res = oahash_probe(be, rel, jexps, exps_cmp_prb, stmts_ht, 
sub, manti, mark /* groupjoin */, has_outerselect, nulls, prb_mrk);
        if (prb_res == NULL) return NULL;
 
        /*** PROJECT RESULT PHASE ***/
        stmt *hp_pos = stmts_ht->op2, *freq = stmts_ht->op3;
        stmt *prb_oid = NULL, *hsh_gid = NULL;
-       if (marked_anti) {
+       if (manti) {
                sql_subtype *tpe_oid = sql_fetch_localtype(TYPE_bit);
                sql_subtype *tpe_bit = sql_fetch_localtype(TYPE_bit);
                stmt *mrk = NULL;
@@ -801,7 +799,7 @@ rel2bin_oahash_groupjoin(backend *be, sq
                        mark = true;
                        if (exp_is_false(e)) {
                                exist = false;
-                               manti = true;
+                               manti = list_length(rel->exps) > 1;
                        }
                }
        }
@@ -860,6 +858,11 @@ rel2bin_oahash_groupjoin(backend *be, sq
                                assert(prb_mrk);
                                if (exp_is_atom(e) && need_no_nil(e)) /* 
exclude nulls */
                                        prb_mrk = sql_Nop_(be, "ifthenelse", 
sql_unop_(be, "isnull", prb_mrk), stmt_bool(be, false), prb_mrk, NULL);
+                               if (!exist && !manti) {
+                                               sql_subtype *bt = 
sql_fetch_localtype(TYPE_bit);
+                                               sql_subfunc *not = 
sql_bind_func(be->mvc, "sys", "not", bt, NULL, F_FUNC, true, true);
+                                               prb_mrk = stmt_unop(be, 
prb_mrk, NULL, not);
+                               }
                        }
                        stmt *s = stmt_alias(be, prb_mrk, e->alias.label, rnme, 
nme);
                        append(sub->op4.lval, s);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to