Changeset: e91ac11694fd for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e91ac11694fd
Modified Files:
        monetdb5/modules/mosaic/TODO_MOSAIC.txt
        monetdb5/modules/mosaic/mosaic_delta.c
        monetdb5/modules/mosaic/mosaic_dictionary.h
        monetdb5/modules/mosaic/mosaic_frame.c
        monetdb5/modules/mosaic/mosaic_prefix.c
        monetdb5/modules/mosaic/mosaic_raw.c
Branch: mosaic
Log Message:

Improve join algorithms.


diffs (234 lines):

diff --git a/monetdb5/modules/mosaic/TODO_MOSAIC.txt 
b/monetdb5/modules/mosaic/TODO_MOSAIC.txt
--- a/monetdb5/modules/mosaic/TODO_MOSAIC.txt
+++ b/monetdb5/modules/mosaic/TODO_MOSAIC.txt
@@ -1,5 +1,4 @@
 ####technical depth####
-FIX HAS_NIL optimization in join algorithms
 Finish null semantics plus tests
 Add test for join nil_matches set for non-nill tests.
 make sure candidate lists are working properly for select, theta_select and 
join (2)
diff --git a/monetdb5/modules/mosaic/mosaic_delta.c 
b/monetdb5/modules/mosaic/mosaic_delta.c
--- a/monetdb5/modules/mosaic/mosaic_delta.c
+++ b/monetdb5/modules/mosaic/mosaic_delta.c
@@ -671,7 +671,7 @@ MOSprojection_delta( MOStask task)
                for(acc = parameters->init.val##TPE, i=0, oo= (oid) first; oo < 
(oid) last; oo++,i++){\
                        DeltaTpe(TPE) delta = (DeltaTpe(TPE)) 
getBitVector(base,i,bits);\
                        TPE value                       = ACCUMULATE(acc, 
delta, sign_mask, TPE);\
-                       if (!NIL_MATCHES) {\
+                       if (HAS_NIL && !NIL_MATCHES) {\
                                if (IS_NIL(TPE, value)) { continue;}\
                        }\
                        if (ARE_EQUAL(*w, value, HAS_NIL, TPE)){\
@@ -690,12 +690,11 @@ MOSprojection_delta( MOStask task)
        if( !nil && nil_matches){\
                join_delta_general(false, true, TPE);\
        }\
-       if( !nil_matches){\
-               /* We don't need to check nil because !nil_matches
-                * excludes a direct comparison with a nill value
-                  on the other side anyway.
-                */\
-       join_delta_general(false, false, TPE);\
+       if( nil && !nil_matches){\
+               join_delta_general(true, false, TPE);\
+       }\
+       if( !nil && !nil_matches){\
+               join_delta_general(false, false, TPE);\
        }\
 }
 
diff --git a/monetdb5/modules/mosaic/mosaic_dictionary.h 
b/monetdb5/modules/mosaic/mosaic_dictionary.h
--- a/monetdb5/modules/mosaic/mosaic_dictionary.h
+++ b/monetdb5/modules/mosaic/mosaic_dictionary.h
@@ -6,7 +6,7 @@
 #include "mal_exception.h"
 
  /*TODO: assuming (for now) that bats have nils during compression*/
-static const bool has_nil = true;
+static const bool nil = true;
 
 static unsigned char
 calculateBits(BUN count) {
@@ -75,11 +75,11 @@ extend_delta_##TPE(BUN* nr_compressed, B
        *delta_count    = 0;\
        for((*nr_compressed) = 0; (*nr_compressed)< limit; (*nr_compressed)++, 
val++) {\
                BUN pos = find_value_##TPE(dict, dict_count, *val);\
-               if (pos == dict_count || !ARE_EQUAL(delta[pos], *val, has_nil, 
TPE)) {\
+               if (pos == dict_count || !ARE_EQUAL(delta[pos], *val, nil, 
TPE)) {\
                        /*This value is not in the base dictionary. See if we 
can add it to the delta dictionary.*/;\
                        if (CONDITIONAL_INSERT(info, *val, TPE)) {\
                                BUN key = find_value_##TPE(delta, 
(*delta_count), *val);\
-                               if (key < *delta_count && ARE_EQUAL(delta[key], 
*val, has_nil, TPE)) {\
+                               if (key < *delta_count && ARE_EQUAL(delta[key], 
*val, nil, TPE)) {\
                                        /*This delta value is already in the 
dictionary hence we can skip it.*/\
                                        continue;\
                                }\
@@ -116,7 +116,7 @@ void merge_delta_Into_dictionary_##TPE(D
 \
        for (BUN i = 0; i < delta_count; i++) {\
                BUN key = find_value_##TPE(dict, *dict_count, delta[i]);\
-               if (key < *dict_count && ARE_EQUAL(dict[key], delta[i], 
has_nil, TPE)) {\
+               if (key < *dict_count && ARE_EQUAL(dict[key], delta[i], nil, 
TPE)) {\
                        /*This delta value is already in the dictionary hence 
we can skip it.*/\
                        continue;\
                }\
@@ -363,7 +363,7 @@ void thetaselect_dictionary_##TPE(\
        for(hr=0, n= rcnt; n-- > 0; hr++,tr++ ){\
                for(hl = (oid) hseqbase, i = 0; i < lcnt; i++,hl++){\
                        unsigned int j= getBitVector(base,i,bits);\
-                       if (!NIL_MATCHES) {\
+                       if (HAS_NIL && !NIL_MATCHES) {\
                                if (IS_NIL(TPE, dict[j])) { continue;}\
                        }\
                        if (ARE_EQUAL(*tr, dict[j], HAS_NIL, TPE)){\
@@ -380,19 +380,18 @@ static \
 str join_dictionary_##TPE(\
 BAT* lres, BAT* rres,\
 BUN hseqbase, BUN lcnt, TPE* dict, BitVector base, bte bits, TPE* tr, BUN 
rcnt,\
-bool has_nil, bool nil_matches)\
+bool nil, bool nil_matches)\
 {\
-if( has_nil && nil_matches){\
+if( nil && nil_matches){\
        join_dictionary_general(true, true, TPE);\
 }\
-if( !has_nil && nil_matches){\
+if( !nil && nil_matches){\
        join_dictionary_general(false, true, TPE);\
 }\
-if( !nil_matches){\
-       /* We don't need to check has_nil because !nil_matches
-               * excludes a direct comparison with a nill value
-               on the other side anyway.
-               */\
+if( nil && !nil_matches){\
+       join_dictionary_general(true, false, TPE);\
+}\
+if( !nil && !nil_matches){\
        join_dictionary_general(false, false, TPE);\
 }\
 return MAL_SUCCEED;\
@@ -483,13 +482,13 @@ return MAL_SUCCEED;\
        BAT* lres = task->lbat;\
        BAT* rres = task->rbat;\
        TPE* tr = (TPE*) task->src;/*right tail value, i.e. the non-mosaic 
side. */\
-       bool has_nil = !task->bsrc->tnonil;\
+       bool nil = !task->bsrc->tnonil;\
        BUN rcnt = task->stop;\
        str result = join_dictionary_##TPE(\
                lres, rres,\
                hseqbase, lcnt, dict, base, bits, /*left mosaic side*/\
                tr, rcnt, /*right (treated as) non-mosaic side*/\
-               has_nil, nil_matches);\
+               nil, nil_matches);\
        if (result != MAL_SUCCEED) return result;\
 }
 
diff --git a/monetdb5/modules/mosaic/mosaic_frame.c 
b/monetdb5/modules/mosaic/mosaic_frame.c
--- a/monetdb5/modules/mosaic/mosaic_frame.c
+++ b/monetdb5/modules/mosaic/mosaic_frame.c
@@ -733,7 +733,7 @@ MOSprojection_frame( MOStask task)
        for( o=0, n= task->stop; n-- > 0; o++,w++ ){\
                for(oo = task->start,i=0; i < limit; i++,oo++){\
                        TPE v = ADD_DELTA(TPE, min, getBitVector(base, i, 
parameters->bits));\
-                       if (!NIL_MATCHES) {\
+                       if (HAS_NIL && !NIL_MATCHES) {\
                                if ((IS_NIL(TPE, v))) {continue;};\
                        }\
                        if (ARE_EQUAL(*w, v, HAS_NIL, TPE)){\
@@ -749,23 +749,16 @@ MOSprojection_frame( MOStask task)
 {\
     MosaicBlkHeader_frame_t* parameters = (MosaicBlkHeader_frame_t*) 
((task))->blk;\
        TPE min =  parameters->min.min##TPE;\
-       TPE max =       parameters->max.max##TPE;\
-       bool nil = false;\
-       if (nil_matches && !task->bsrc->tnonil && (min == TPE##_nil || max == 
TPE##_nil)) {\
-               /*TODO: this is a strong assumption that nil values are always 
the highest or the lowest value in a GDK type domain.*/\
-               nil = (min == TPE##_nil) || (max == TPE##_nil);\
-       }\
        if( nil && nil_matches){\
                join_frame_general(true, true, TPE);\
        }\
        if( !nil && nil_matches){\
                join_frame_general(false, true, TPE);\
        }\
-       if( !nil_matches){\
-               /* We don't need to check nil because !nil_matches
-                * excludes a direct comparison with a nill value
-                  on the other side anyway.
-                */\
+       if( nil && !nil_matches){\
+               join_frame_general(true, false, TPE);\
+       }\
+       if( !nil && !nil_matches){\
                join_frame_general(false, false, TPE);\
        }\
 }
@@ -775,6 +768,7 @@ MOSjoin_frame( MOStask task, bit nil_mat
 {
        BUN i,n,limit;
        oid o, oo;
+       bool nil = !task->bsrc->tnonil;
 
        // set the oid range covered and advance scan range
        switch(ATOMbasetype(task->type)){
diff --git a/monetdb5/modules/mosaic/mosaic_prefix.c 
b/monetdb5/modules/mosaic/mosaic_prefix.c
--- a/monetdb5/modules/mosaic/mosaic_prefix.c
+++ b/monetdb5/modules/mosaic/mosaic_prefix.c
@@ -720,7 +720,7 @@ MOSprojection_prefix( MOStask task)
                for(i=0, oo= (oid) first; oo < (oid) last; oo++,i++){\
                        PrefixTpe(TPE) pvalue = prefix | 
getBitVector(base,i,suffix_bits);\
                        TPE* value =  (TPE*) &pvalue;\
-                       if (!NIL_MATCHES) {\
+                       if (HAS_NIL && !NIL_MATCHES) {\
                                if (IS_NIL(TPE, *value)) { continue;}\
                        }\
                        if (ARE_EQUAL(*w, *value, HAS_NIL, TPE)){\
@@ -739,12 +739,11 @@ MOSprojection_prefix( MOStask task)
        if( !nil && nil_matches){\
                join_prefix_general(false, true, TPE);\
        }\
-       if( !nil_matches){\
-               /* We don't need to check nil because !nil_matches
-                * excludes a direct comparison with a nill value
-                  on the other side anyway.
-                */\
-       join_prefix_general(false, false, TPE);\
+       if( nil && !nil_matches){\
+               join_prefix_general(true, false, TPE);\
+       }\
+       if( !nil && !nil_matches){\
+               join_prefix_general(false, false, TPE);\
        }\
 }
 
diff --git a/monetdb5/modules/mosaic/mosaic_raw.c 
b/monetdb5/modules/mosaic/mosaic_raw.c
--- a/monetdb5/modules/mosaic/mosaic_raw.c
+++ b/monetdb5/modules/mosaic/mosaic_raw.c
@@ -543,7 +543,7 @@ MOSprojection_raw( MOStask task)
 {      TPE *v, *w;\
        v = (TPE*) (((char*) task->blk) + MosaicBlkSize);\
        for(oo= (oid) first; first < last; first++, v++, oo++){\
-               if (!NIL_MATCHES) {\
+               if (HAS_NIL && !NIL_MATCHES) {\
                        if ((IS_NIL(TPE, *v))) {continue;};\
                }\
                w = (TPE*) task->src;\
@@ -564,12 +564,11 @@ MOSprojection_raw( MOStask task)
        if( !nil && nil_matches){\
                join_raw_general(false, true, TPE);\
        }\
-       if( !nil_matches){\
-               /* We don't need to check nil because !nil_matches
-                * excludes a direct comparison with a nill value
-                  on the other side anyway.
-                */\
-       join_raw_general(false, false, TPE);\
+       if( nil && !nil_matches){\
+               join_raw_general(true, false, TPE);\
+       }\
+       if( !nil && !nil_matches){\
+               join_raw_general(false, false, TPE);\
        }\
 }
 
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to