Changeset: d9a4d62b1e47 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d9a4d62b1e47
Modified Files:
        monetdb5/modules/mal/pp_hash.c
        monetdb5/modules/mal/pp_hash.h
        sql/backends/monet5/rel_physical.c
        sql/backends/monet5/rel_pphash.c
        sql/backends/monet5/sql_pp_statement.c
        sql/backends/monet5/sql_pp_statement.h
        sql/server/rel_optimize_sel.c
        sql/server/rel_unnest.c
Branch: manti
Log Message:

check in WiP on marked-anti-join


diffs (truncated from 934 to 300 lines):

diff --git a/monetdb5/modules/mal/pp_hash.c b/monetdb5/modules/mal/pp_hash.c
--- a/monetdb5/modules/mal/pp_hash.c
+++ b/monetdb5/modules/mal/pp_hash.c
@@ -109,6 +109,7 @@ _ht_create( int type, size_t size, hash_
        h->last = 0;
        h->empty = true;
        h->has_nil = 0;
+       h->gid_NULL = oid_nil;
        h->p = p;
        h->pinned = NULL;
        h->pinned_nr = 0; /* no more than 1024 */
@@ -708,8 +709,6 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
                Type *vals = h->vals; \
                \
                TIMEOUT_LOOP_IDX_DECL(i, cnt, qry_ctx) { \
-                       if (need_has_nil) \
-                               (void)ATOMIC_OR(&h->has_nil, 
is_##Type##_nil(bp[i])); \
                        bool fnd = 0; \
                        gid g = 0; \
                        while (!fnd) { \
@@ -743,6 +742,14 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
                                fnd = 1; \
                        } \
                        gp[i] = g-1; \
+                       bit is_nil = is_##Type##_nil(bp[i]); \
+                       if (need_has_nil && !h->has_nil && is_nil) {\
+                               bit old_has_nil = (bit) ATOMIC_OR(&h->has_nil, 
is_nil); \
+                               if (old_has_nil != (bit) h->has_nil) {\
+                                       assert(!old_has_nil && h->has_nil && 
is_oid_nil(h->gid_NULL)); \
+                                       ATOMIC_SET(&h->gid_NULL, gp[i]); \
+                               } \
+                       } \
                } \
        } while (0)
 
@@ -797,8 +804,6 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
                Type *vals = h->vals; \
                \
                TIMEOUT_LOOP_IDX_DECL(i, cnt, qry_ctx) { \
-                       if (need_has_nil) \
-                               (void)ATOMIC_OR(&h->has_nil, 
is_##Type##_nil(bp[i])); \
                        bool fnd = 0; \
                        gid g = 0; \
                        while (!fnd) { \
@@ -832,6 +837,14 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
                                fnd = 1; \
                        } \
                        gp[i] = g-1; \
+                       bit is_nil = is_##Type##_nil(bp[i]); \
+                       if (need_has_nil && !h->has_nil && is_nil) {\
+                               bit old_has_nil = (bit) ATOMIC_OR(&h->has_nil, 
is_nil); \
+                               if (old_has_nil != (bit) h->has_nil) {\
+                                       assert(!old_has_nil && h->has_nil && 
is_oid_nil(h->gid_NULL)); \
+                                       ATOMIC_SET(&h->gid_NULL, gp[i]); \
+                               } \
+                       } \
                } \
        } while (0)
 
@@ -844,8 +857,6 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
                        bool fnd = 0; \
                        var_t voff = VarHeapVal(bi.base,i,bi.width);            
                \
                        void *bpi = voff == 0 ? (void*) ATOMnilptr((bi).type) : 
(void *) ((bi).vh->base+voff); \
-                       if (need_has_nil) \
-                               (void)ATOMIC_OR(&h->has_nil, (voff == 0)); \
                        gid g = 0; \
                        while (!fnd) { \
                                gid k = (gid)h->hsh(bpi)&h->mask; \
@@ -877,6 +888,14 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
                                fnd = 1; \
                        } \
                        gp[i] = g-1; \
+                       bit is_nil = (voff == 0); \
+                       if (need_has_nil && !h->has_nil && is_nil) {\
+                               bit old_has_nil = (bit) ATOMIC_OR(&h->has_nil, 
is_nil); \
+                               if (old_has_nil != (bit) h->has_nil) {\
+                                       assert(!old_has_nil && h->has_nil && 
is_oid_nil(h->gid_NULL)); \
+                                       ATOMIC_SET(&h->gid_NULL, gp[i]); \
+                               } \
+                       } \
                } \
                bat_iterator_end(&bi); \
        } while (0)
@@ -892,8 +911,6 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
                                bool fnd = 0; \
                                var_t voff = VarHeapVal(bi.base,i,bi.width);    
                        \
                                void *bpi = voff == 0 ? (void*) 
ATOMnilptr((bi).type) : (void *) ((bi).vh->base+voff); \
-                               if (need_has_nil) \
-                                       (void)ATOMIC_OR(&h->has_nil, (voff == 
0)); \
                                gid g = 0; \
                                while (!fnd) { \
                                        gid k = (gid)str_hsh(bpi)&h->mask; \
@@ -925,6 +942,14 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
                                        fnd = 1; \
                                } \
                                gp[i] = g-1; \
+                               bit is_nil = (voff == 0); \
+                               if (need_has_nil && !h->has_nil && is_nil) {\
+                                       bit old_has_nil = (bit) 
ATOMIC_OR(&h->has_nil, is_nil); \
+                                       if (old_has_nil != (bit) h->has_nil) {\
+                                               assert(!old_has_nil && 
h->has_nil && is_oid_nil(h->gid_NULL)); \
+                                               ATOMIC_SET(&h->gid_NULL, 
gp[i]); \
+                                       } \
+                               } \
                        } \
                } else { /* other ATOMvarsized, e.g. BLOB */ \
                        int (*atomcmp)(const void *, const void *) = 
ATOMcompare(tt); \
@@ -932,8 +957,6 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
                                bool fnd = 0; \
                                var_t voff = VarHeapVal(bi.base,i,bi.width);    
                        \
                                void *bpi = voff == 0 ? (void*) 
ATOMnilptr((bi).type) : (void *) ((bi).vh->base+voff); \
-                               if (need_has_nil) \
-                                       (void)ATOMIC_OR(&h->has_nil, (voff == 
0)); \
                                gid g = 0; \
                                while (!fnd) { \
                                        gid k = (gid)h->hsh(bpi)&h->mask; \
@@ -965,6 +988,14 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
                                        fnd = 1; \
                                } \
                                gp[i] = g-1; \
+                               bit is_nil = (voff == 0); \
+                               if (need_has_nil && !h->has_nil && is_nil) {\
+                                       bit old_has_nil = (bit) 
ATOMIC_OR(&h->has_nil, is_nil); \
+                                       if (old_has_nil != (bit) h->has_nil) {\
+                                               assert(!old_has_nil && 
h->has_nil && is_oid_nil(h->gid_NULL)); \
+                                               ATOMIC_SET(&h->gid_NULL, 
gp[i]); \
+                                       } \
+                               } \
                        } \
                } \
                bat_iterator_end(&bi); \
@@ -976,8 +1007,6 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
                Type *vals = h->vals; \
                \
                TIMEOUT_LOOP_IDX_DECL(i, cnt, qry_ctx) { \
-                       if (need_has_nil) \
-                               (void)ATOMIC_OR(&h->has_nil, 
is_##Type##_nil(bp[i])); \
                        bool fnd = 0; \
                        gid g = 0; \
                        while (!fnd) { \
@@ -1013,6 +1042,9 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
                                fnd = 1; \
                        } \
                        gp[i] = g-1; \
+                       bit is_nil = is_##Type##_nil(bp[i]); \
+                       if (need_has_nil && !h->has_nil && is_nil) \
+                               (void)ATOMIC_OR(&h->has_nil, is_nil); \
                } \
        } while (0)
 
@@ -1070,8 +1102,6 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
                Type *vals = h->vals; \
                \
                TIMEOUT_LOOP_IDX_DECL(i, cnt, qry_ctx) { \
-                       if (need_has_nil) \
-                               (void)ATOMIC_OR(&h->has_nil, 
is_##Type##_nil(bp[i])); \
                        bool fnd = 0; \
                        gid g = 0; \
                        while (!fnd) { \
@@ -1107,6 +1137,9 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
                                fnd = 1; \
                        } \
                        gp[i] = g-1; \
+                       bit is_nil = is_##Type##_nil(bp[i]); \
+                       if (need_has_nil && !h->has_nil && is_nil) \
+                               (void)ATOMIC_OR(&h->has_nil, is_nil); \
                } \
        } while (0)
 
@@ -1119,8 +1152,6 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
                        bool fnd = 0; \
                        var_t voff = VarHeapVal(bi.base,i,bi.width);            
                \
                        void *bpi = voff == 0 ? (void*) ATOMnilptr((bi).type) : 
(void *) ((bi).vh->base+voff); \
-                       if (need_has_nil) \
-                               (void)ATOMIC_OR(&h->has_nil, (voff == 0)); \
                        gid g = 0; \
                        while (!fnd) { \
                                gid k = (gid)combine(gi[i], h->hsh(bpi), 
prime)&h->mask; \
@@ -1155,6 +1186,9 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
                                fnd = 1; \
                        } \
                        gp[i] = g-1; \
+                       bit is_nil = (voff == 0); \
+                       if (need_has_nil && !h->has_nil && is_nil) \
+                               (void)ATOMIC_OR(&h->has_nil, is_nil); \
                } \
                bat_iterator_end(&bi); \
        } while (0)
@@ -1170,8 +1204,6 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
                                bool fnd = 0; \
                                var_t voff = VarHeapVal(bi.base,i,bi.width);    
                        \
                                void *bpi = voff == 0 ? (void*) 
ATOMnilptr((bi).type) : (void *) ((bi).vh->base+voff); \
-                               if (need_has_nil) \
-                                       (void)ATOMIC_OR(&h->has_nil, (voff == 
0)); \
                                gid g = 0; \
                                while (!fnd) { \
                                        gid k = (gid)combine(gi[i], 
str_hsh(bpi), prime)&h->mask; \
@@ -1206,6 +1238,9 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
                                        fnd = 1; \
                                } \
                                gp[i] = g-1; \
+                               bit is_nil = (voff == 0); \
+                               if (need_has_nil && !h->has_nil && is_nil) \
+                                       (void)ATOMIC_OR(&h->has_nil, is_nil); \
                        } \
                        bat_iterator_end(&bi); \
                } else { /* other ATOMvarsized, e.g. BLOB */ \
@@ -1214,8 +1249,6 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
                                bool fnd = 0; \
                                var_t voff = VarHeapVal(bi.base,i,bi.width);    
                        \
                                void *bpi = voff == 0 ? (void*) 
ATOMnilptr((bi).type) : (void *) ((bi).vh->base+voff); \
-                               if (need_has_nil) \
-                                       (void)ATOMIC_OR(&h->has_nil, (voff == 
0)); \
                                gid g = 0; \
                                while (!fnd) { \
                                        gid k = (gid)combine(gi[i], 
h->hsh(bpi), prime)&h->mask; \
@@ -1249,6 +1282,9 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
                                        fnd = 1; \
                                } \
                                gp[i] = g-1; \
+                               bit is_nil = (voff == 0); \
+                               if (need_has_nil && !h->has_nil && is_nil) \
+                                       (void)ATOMIC_OR(&h->has_nil, is_nil); \
                        } \
                        bat_iterator_end(&bi); \
                } \
@@ -1908,14 +1944,22 @@ OAHASHnprobe(Client ctx, bat *PRB_oid, b
                        oid_mtd[mtdcnt] = off+i; \
                        if (slot) { \
                                slt[mtdcnt] = (oid)(slot - 1); \
-                               mark[i] = true; \
+                               mark[mtdcnt] = true; \
                                if (*single && freq[slot - 1] > 1) { \
                                        err = createException(SQL, 
"oahash.probe", "more than one match"); \
                                        goto error; \
                                } \
+                               \
+                               if (match_nulls && ht->has_nil) { \
+                                       assert(ht->gid_NULL != oid_nil); \
+                                       mtdcnt++; \
+                                       oid_mtd[mtdcnt] = off+i; \
+                                       slt[mtdcnt] = ht->gid_NULL; \
+                                       mark[mtdcnt] = bit_nil; \
+                               }\
                        } else { \
-                               slt[mtdcnt] = oid_nil; \
-                               mark[i] = (any && ht->has_nil)?bit_nil:false; \
+                               slt[mtdcnt] = 
(match_nulls)?ht->gid_NULL:oid_nil; \
+                               mark[mtdcnt] = (any && 
ht->has_nil)?bit_nil:false; \
                        } \
                        mtdcnt++; \
                } \
@@ -1930,7 +1974,7 @@ OAHASHnprobe(Client ctx, bat *PRB_oid, b
                        if (!(*semantics) && is_##Type##_nil(ky[i])) { \
                                oid_mtd[mtdcnt] = off+i; \
                                slt[mtdcnt] = oid_nil; \
-                               mark[i] = any?empty:false; \
+                               mark[mtdcnt] = any?empty:false; \
                                mtdcnt++; \
                                continue; \
                        } \
@@ -1944,14 +1988,22 @@ OAHASHnprobe(Client ctx, bat *PRB_oid, b
                        oid_mtd[mtdcnt] = off+i; \
                        if (slot) { \
                                slt[mtdcnt] = (oid)(slot - 1); \
-                               mark[i] = true; \
+                               mark[mtdcnt] = true; \
                                if (*single && freq[slot - 1] > 1) { \
                                        err = createException(SQL, 
"oahash.probe", "more than one match"); \
                                        goto error; \
                                } \
+                               \
+                               if (match_nulls && ht->has_nil) { \
+                                       assert(ht->gid_NULL != oid_nil); \
+                                       mtdcnt++; \
+                                       oid_mtd[mtdcnt] = off+i; \
+                                       slt[mtdcnt] = ht->gid_NULL; \
+                                       mark[mtdcnt] = bit_nil; \
+                               }\
                        } else { \
-                               slt[mtdcnt] = oid_nil; \
-                               mark[i] = (any && ht->has_nil)?bit_nil:false; \
+                               slt[mtdcnt] = 
(match_nulls)?ht->gid_NULL:oid_nil; \
+                               mark[mtdcnt] = (any && 
ht->has_nil)?bit_nil:false; \
                        } \
                        mtdcnt++; \
                } \
@@ -1972,7 +2024,7 @@ OAHASHnprobe(Client ctx, bat *PRB_oid, b
                        if (!(*semantics) && is_##Type##_nil(ky[i])) { \
                                oid_mtd[mtdcnt] = off+i; \
                                slt[mtdcnt] = oid_nil; \
-                               mark[i] = any?empty:false; \
+                               mark[mtdcnt] = any?empty:false; \
                                mtdcnt++; \
                                continue; \
                        } \
@@ -1986,14 +2038,22 @@ OAHASHnprobe(Client ctx, bat *PRB_oid, b
                        oid_mtd[mtdcnt] = off+i; \
                        if (slot) { \
                                slt[mtdcnt] = (oid)(slot - 1); \
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to