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

added a 'firstonly' flag to split_join_exps() to get only the first joinable
exp (needed for marked-antijoin)


diffs (150 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
@@ -3409,7 +3409,7 @@ rel2bin_join(backend *be, sql_rel *rel, 
                list *jexps = sa_list(sql->sa);
                sexps = sa_list(sql->sa);
 
-               split_join_exps(rel, jexps, sexps, false /* anti */, false /* 
eqonly */);
+               split_join_exps(rel, jexps, sexps, false /* anti */, false /* 
eqonly */, false /* firstonly */);
                if (list_empty(jexps)) { /* cross product and continue after 
project */
                        stmt *l = bin_find_smallest_column(be, left);
                        stmt *r = bin_find_smallest_column(be, right);
@@ -3656,7 +3656,7 @@ rel2bin_antijoin(backend *be, sql_rel *r
        jexps = sa_list(sql->sa);
        sexps = sa_list(sql->sa);
 
-       split_join_exps(rel, jexps, sexps, true /* anti */, false /* eqonly */);
+       split_join_exps(rel, jexps, sexps, true /* anti */, false /* eqonly */, 
false /* firstonly */);
        if (list_empty(jexps)) {
                stmt *l = bin_find_smallest_column(be, left);
                stmt *r = bin_find_smallest_column(be, right);
@@ -3882,7 +3882,7 @@ rel2bin_semijoin(backend *be, sql_rel *r
                list *jexps = sa_list(sql->sa);
                sexps = sa_list(sql->sa);
 
-               split_join_exps(rel, jexps, sexps, false /* anti */, false /* 
eqonly */);
+               split_join_exps(rel, jexps, sexps, false /* anti */, false /* 
eqonly */, false /* firstonly */);
                if (list_empty(jexps)) { /* cross product and continue after 
project */
                        right = subrel_project(be, right, refs, rel->r);
                        stmt *l = bin_find_smallest_column(be, left);
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
@@ -889,7 +889,7 @@ rel_pipeline(visitor *v, sql_rel *rel, b
        } else if (is_semi(rel->op)) {
                list *eq_exps = sa_list(v->sql->sa);
                list *other = sa_list(v->sql->sa);
-               split_join_exps(rel, eq_exps, other, true /* anti */, true /* 
eqonly */);
+               split_join_exps(rel, eq_exps, other, true /* anti */, true /* 
eqonly */, false /* firstonly */);
                bool needs_payload = (!list_empty(other));
                bool need_all = false;
                bool cross = list_empty(eq_exps);
@@ -1013,7 +1013,7 @@ rel_pipeline(visitor *v, sql_rel *rel, b
                        bool is_manti_with_null = list_length(rel->attr) == 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 */);
+                       split_join_exps(rel, eq_exps, other, true /* anti */, 
true /* eqonly */, false /* firstonly */);
 
                        sql_rel *l = rel->l, *r = rel->r;
                        sql_rel *rel_hsh = NULL, *rel_prb = NULL, *iprj = NULL, 
*pprj = NULL;
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
@@ -855,7 +855,7 @@ rel2bin_oahash_groupjoin(backend *be, sq
        assert(!list_empty(rel->attr));
        stmt *sub = NULL, *probe_sub = NULL;
        list *jexps = sa_list(be->mvc->sa), *sexps = sa_list(be->mvc->sa), 
*probe_side = NULL, *hash_side = NULL;
-       split_join_exps(rel, jexps, sexps, false /* anti */, true /* eqonly */);
+       split_join_exps(rel, jexps, sexps, false /* anti */, true /* eqonly */, 
false /* firstonly */);
        stmt *probed_ids = NULL, *hash_ids = NULL;
        stmt *prb_mrk = NULL;
        bool mark = false, exist = true;
@@ -942,7 +942,7 @@ rel2bin_oahash_innerjoin(backend *be, sq
        bool hf = false;
        stmt *sub = NULL, *probed_ids = NULL;
        list *jexps = sa_list(be->mvc->sa), *sexps = sa_list(be->mvc->sa), 
*probe_side = NULL, *hash_side = NULL;
-       split_join_exps(rel, jexps, sexps, false /* anti */, true /* eqonly */);
+       split_join_exps(rel, jexps, sexps, false /* anti */, true /* eqonly */, 
false /* firstonly */);
        bool single = rel->single && !list_empty(sexps);
 
        /* start new parallel block after join. NB get_need_pipeline has side 
effect! */
@@ -973,7 +973,7 @@ rel2bin_oahash_leftouterjoin(backend *be
 {
        stmt *sub = NULL, *probe_sub = NULL;
        list *jexps = sa_list(be->mvc->sa), *sexps = sa_list(be->mvc->sa), 
*probe_side = NULL, *hash_side = NULL;
-       split_join_exps(rel, jexps, sexps, false /* anti */, true /* eqonly */);
+       split_join_exps(rel, jexps, sexps, false /* anti */, true /* eqonly */, 
false /* firstonly */);
        stmt *probed_ids = NULL, *hash_ids = NULL;
        stmt *prb_mrk = NULL;
 
@@ -1069,7 +1069,7 @@ rel2bin_oahash_rightouterjoin(backend *b
        bool hf = false;
        stmt *sub = NULL, *probed_ids = NULL;
        list *jexps = sa_list(be->mvc->sa), *sexps = sa_list(be->mvc->sa), 
*probe_side = NULL, *hash_side = NULL;
-       split_join_exps(rel, jexps, sexps, false /* anti */, true /* eqonly */);
+       split_join_exps(rel, jexps, sexps, false /* anti */, true /* eqonly */, 
false /* firstonly */);
        bool single = rel->single && !list_empty(sexps);
 
        stmt *hsh_mrk = NULL;
@@ -1256,7 +1256,7 @@ rel2bin_oahash_fullouterjoin(backend *be
        // existing leftjoin code, extended to mark the matched payloads
        stmt *sub = NULL, *probe_sub = NULL;
        list *jexps = sa_list(sql->sa), *sexps = sa_list(sql->sa), *probe_side 
= NULL, *hash_side = NULL;
-       split_join_exps(rel, jexps, sexps, false /* anti */, true /* eqonly */);
+       split_join_exps(rel, jexps, sexps, false /* anti */, true /* eqonly */, 
false /* firstonly */);
        stmt *probed_ids = NULL, *hash_ids = NULL;
        stmt *m = NULL, *hsh_mrk = NULL;
 
@@ -1417,7 +1417,7 @@ rel2bin_oahash_semi(backend *be, sql_rel
        list *probe_side = NULL, *hash_side = NULL;
 
        list *jexps = sa_list(be->mvc->sa), *sexps = sa_list(be->mvc->sa);
-       split_join_exps(rel, jexps, sexps, false /* anti */, true /* eqonly */);
+       split_join_exps(rel, jexps, sexps, false /* anti */, true /* eqonly */, 
false /* firstonly */);
 
        bool anti = (list_length(jexps) == 1 && rel->op == op_anti);
        bool hf = false;
diff --git a/sql/backends/monet5/rel_util.c b/sql/backends/monet5/rel_util.c
--- a/sql/backends/monet5/rel_util.c
+++ b/sql/backends/monet5/rel_util.c
@@ -86,17 +86,23 @@ can_join_exp(sql_rel *rel, sql_exp *e, b
 }
 
 void
-split_join_exps(sql_rel *rel, list *joinable, list *not_joinable, bool anti, 
bool eqonly)
+split_join_exps(sql_rel *rel, list *joinable, list *not_joinable, bool anti, 
bool eqonly, bool firstonly)
 {
+       bool found = 0;
        if (!list_empty(rel->exps)) {
                for (node *n = rel->exps->h; n; n = n->next) {
                        sql_exp *e = n->data;
 
                        /* eqonly -
                         *   TRUE: only handle equi-join expressions, e.g. in 
case of pipeline hash join
-                        *   FALSE: we can (also) handle thetajoins, rangejoins 
and filter joins (like) */
-                       if (can_join_exp(rel, e, anti) && (!eqonly || 
(is_equi_exp_(e) && !exp_is_atom(e->r) && !exp_is_atom(e->l)))) {
+                        *   FALSE: we can (also) handle thetajoins, rangejoins 
and filter joins (like) 
+                        * firstonly - 
+                        *   TRUE: add only the first joinable `e` to 
`joinable` (used by marked-manti-join)
+                        *   FALSE: add all joinable `e` to `joinable`
+                        */
+                       if (!found && can_join_exp(rel, e, anti) && (!eqonly || 
(is_equi_exp_(e) && !exp_is_atom(e->r) && !exp_is_atom(e->l)))) {
                                append(joinable, e);
+                               found = firstonly;
                        } else {
                                append(not_joinable, e);
                        }
diff --git a/sql/backends/monet5/rel_util.h b/sql/backends/monet5/rel_util.h
--- a/sql/backends/monet5/rel_util.h
+++ b/sql/backends/monet5/rel_util.h
@@ -17,7 +17,7 @@
 #define is_equi_exp_(e) ((e)->flag == cmp_equal)
 
 extern bool can_join_exp(sql_rel *rel, sql_exp *e, bool anti);
-extern void split_join_exps(sql_rel *rel, list *joinable, list *not_joinable, 
bool anti, bool eqonly);
+extern void split_join_exps(sql_rel *rel, list *joinable, list *not_joinable, 
bool anti, bool eqonly, bool firstonly);
 
 extern list *get_simple_equi_joins_first(mvc *sql, sql_rel *rel, list *exps);
 
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to