Changeset: 831629adcb15 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=831629adcb15
Modified Files:
        monetdb5/modules/mosaic/TODO_MOSAIC.txt
        monetdb5/modules/mosaic/mosaic_join.h
        monetdb5/optimizer/opt_mosaic.c
        monetdb5/optimizer/opt_pipes.c
        monetdb5/optimizer/opt_prelude.c
        monetdb5/optimizer/opt_wrapper.c
        monetdb5/optimizer/optimizer.mal
        sql/test/mosaic/Tests/All
Branch: mosaic
Log Message:

Make two versions of mosaic (nested loop) join available.


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,6 +1,4 @@
 ####technical depth####
-Create an 
uncompressed-bat-on-the-outer-side-and-compressed-bat-on-the-inner-side-nested-loop-join
 and mark it as default mosaic.join.
-Make the COUI-nested-loop-join available for comparison. i.e. separate 
optimizer.
 Split the MOSadvance-like functions to type specific variant and remove the 
MOSskip functions.
 See if decompress can be refactored similar to the algebraic operators.
 Factor out boilerplate code mosaic code: resulting mosaic boilerplate is for 
testing purposes.
diff --git a/monetdb5/modules/mosaic/mosaic_join.h 
b/monetdb5/modules/mosaic/mosaic_join.h
--- a/monetdb5/modules/mosaic/mosaic_join.h
+++ b/monetdb5/modules/mosaic/mosaic_join.h
@@ -110,35 +110,35 @@ static str MOSjoin_COUI_##TPE(MOStask ta
 \
                switch(MOSgetTag(task->blk)){\
                case MOSAIC_RLE:\
-                       ALGODEBUG mnstr_printf(GDKstdout, 
"MOSjoin_runlength\n");\
+                       ALGODEBUG mnstr_printf(GDKstdout, 
"MOSjoin_COUI_runlength\n");\
                        DO_OPERATION_IF_ALLOWED(join_COUI, runlength, TPE);\
                        break;\
                case MOSAIC_CAPPED:\
-                       ALGODEBUG mnstr_printf(GDKstdout, "MOSjoin_capped\n");\
+                       ALGODEBUG mnstr_printf(GDKstdout, 
"MOSjoin_COUI_capped\n");\
                        DO_OPERATION_IF_ALLOWED(join_COUI, capped, TPE);\
                        break;\
                case MOSAIC_VAR:\
-                       ALGODEBUG mnstr_printf(GDKstdout, "MOSjoin_var\n");\
+                       ALGODEBUG mnstr_printf(GDKstdout, 
"MOSjoin_COUI_var\n");\
                        DO_OPERATION_IF_ALLOWED(join_COUI, var, TPE);\
                        break;\
                case MOSAIC_FRAME:\
-                       ALGODEBUG mnstr_printf(GDKstdout, "MOSjoin_frame\n");\
+                       ALGODEBUG mnstr_printf(GDKstdout, 
"MOSjoin_COUI_frame\n");\
                        DO_OPERATION_IF_ALLOWED(join_COUI, frame, TPE);\
                        break;\
                case MOSAIC_DELTA:\
-                       ALGODEBUG mnstr_printf(GDKstdout, "MOSjoin_delta\n");\
+                       ALGODEBUG mnstr_printf(GDKstdout, 
"MOSjoin_COUI_delta\n");\
                        DO_OPERATION_IF_ALLOWED(join_COUI, delta, TPE);\
                        break;\
                case MOSAIC_PREFIX:\
-                       ALGODEBUG mnstr_printf(GDKstdout, "MOSjoin_prefix\n");\
+                       ALGODEBUG mnstr_printf(GDKstdout, 
"MOSjoin_COUI_prefix\n");\
                        DO_OPERATION_IF_ALLOWED(join_COUI, prefix, TPE);\
                        break;\
                case MOSAIC_LINEAR:\
-                       ALGODEBUG mnstr_printf(GDKstdout, "MOSjoin_linear\n");\
+                       ALGODEBUG mnstr_printf(GDKstdout, 
"MOSjoin_COUI_linear\n");\
                        DO_OPERATION_IF_ALLOWED(join_COUI, linear, TPE);\
                        break;\
                case MOSAIC_RAW:\
-                       ALGODEBUG mnstr_printf(GDKstdout, "MOSjoin_raw\n");\
+                       ALGODEBUG mnstr_printf(GDKstdout, 
"MOSjoin_COUI_raw\n");\
                        DO_OPERATION_IF_ALLOWED(join_COUI, raw, TPE);\
                        break;\
                }\
diff --git a/monetdb5/optimizer/opt_mosaic.c b/monetdb5/optimizer/opt_mosaic.c
--- a/monetdb5/optimizer/opt_mosaic.c
+++ b/monetdb5/optimizer/opt_mosaic.c
@@ -46,8 +46,8 @@ static int OPTmosaicType(MalBlkPtr mb, I
        return 0;
 }
 
-str 
-OPTmosaicImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci)
+static str
+OPTmosaicImplementationInternal(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci, bool coui)
 {
        InstrPtr p,q, *old;
     int limit, slimit,i,j, k, actions =0;
@@ -55,7 +55,7 @@ OPTmosaicImplementation(Client cntxt, Ma
        char buf[256];
     lng usec = GDKusec();
 
-       if( optimizerIsApplied(mb,"mosaic"))
+       if( optimizerIsApplied(mb,"mosaic") || 
optimizerIsApplied(mb,"mosaiccoui"))
                return MAL_SUCCEED;
        check = GDKzalloc(mb->vsize);
        if ( check == NULL)
@@ -74,8 +74,8 @@ OPTmosaicImplementation(Client cntxt, Ma
        }
 
        (void) cntxt;
+       (void) stk;
        (void) pci;
-       (void) stk;
 
        // pre-scan to identify all potentially compressed columns
     for( i=1; i < limit; i++){
@@ -117,6 +117,10 @@ OPTmosaicImplementation(Client cntxt, Ma
                } else
         if ( getModuleId(p) == algebraRef && getFunctionId(p) == joinRef && 
p->argc ==8){
                        setModuleId(p, mosaicRef);
+                       if (coui) {
+                               /*This will push and set the COUI flag true.*/
+                               pushBit(mb, p, 1);
+                       }
                        actions++;
                }
                if( p )
@@ -138,3 +142,9 @@ OPTmosaicImplementation(Client cntxt, Ma
 #endif
        return MAL_SUCCEED;
 }
+
+str
+OPTmosaicImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci) {
+       bool coui = strcmp("mosaiccoui", getFunctionId(pci)) == 0;
+       return OPTmosaicImplementationInternal(cntxt, mb, stk, pci, coui);
+}
diff --git a/monetdb5/optimizer/opt_pipes.c b/monetdb5/optimizer/opt_pipes.c
--- a/monetdb5/optimizer/opt_pipes.c
+++ b/monetdb5/optimizer/opt_pipes.c
@@ -96,8 +96,7 @@ static struct PIPELINES {
         "optimizer.garbageCollector();",
         "stable", NULL, NULL, 1},
 /*
- *     The mosaic pipeline is the only pipeline that uses the mosaic optimizer.
- *     It is based on the sequential pipeline.
+ *     The mosaic pipeline is based on the sequential pipeline.
 */
         {"mosaic_pipe",
         "optimizer.inline();"
@@ -133,6 +132,46 @@ static struct PIPELINES {
         "optimizer.garbageCollector();",
         "stable", NULL, NULL, 1},
 /*
+ * The mosaic pipeline with COUI is based on the normal mosaic pipeline.
+ * The main difference is that for nested loop joins, mosaic with COUI
+ * will iterate respectively
+ * over the (C)ompressed side in the (O)uter loop and
+ * over the (U)ncompressed side in the (I)nner loop.
+*/
+        {"mosaiccoui_pipe",
+        "optimizer.inline();"
+        "optimizer.remap();"
+        "optimizer.costModel();"
+        "optimizer.coercions();"
+        "optimizer.evaluate();"
+        "optimizer.emptybind();"
+        "optimizer.pushselect();"
+        "optimizer.aliases();"
+//      "optimizer.mitosis();" turned off for now
+        "optimizer.mergetable();"
+        "optimizer.deadcode();"
+        "optimizer.aliases();"
+        "optimizer.constants();"
+        "optimizer.commonTerms();"
+        "optimizer.projectionpath();"
+        "optimizer.deadcode();"
+        "optimizer.reorder();"
+//      "optimizer.reduce();" deprecated
+        "optimizer.matpack();"
+        "optimizer.querylog();"
+        "optimizer.multiplex();"
+        "optimizer.generator();"
+        "optimizer.mosaiccoui();"
+        "optimizer.profiler();"
+        "optimizer.candidates();"
+        "optimizer.postfix();"
+        "optimizer.deadcode();"
+//      "optimizer.jit();" awaiting the new batcalc api
+//      "optimizer.oltp();"awaiting the autocommit front-end changes
+        "optimizer.wlc();"
+        "optimizer.garbageCollector();",
+        "stable", NULL, NULL, 1},
+/*
  * Optimistic concurreny control in general leads to more transaction failures 
  * in an OLTP setting. The partial solution provided is to give out 
  * advisory locks and delay updates until they are released or timeout.
diff --git a/monetdb5/optimizer/opt_prelude.c b/monetdb5/optimizer/opt_prelude.c
--- a/monetdb5/optimizer/opt_prelude.c
+++ b/monetdb5/optimizer/opt_prelude.c
@@ -188,6 +188,7 @@ str minusRef;
 str mirrorRef;
 str mitosisRef;
 str mosaicRef;
+str mosaiccouiRef;
 str mkeyRef;
 str mmathRef;
 str mtimeRef;
@@ -490,6 +491,7 @@ void optimizerInit(void)
        mergepackRef= putName("mergepack");
        min_no_nilRef = putName("min_no_nil");
        mosaicRef = putName("mosaic");
+       mosaiccouiRef = putName("mosaiccoui");
        minRef = putName("min");
        minusRef = putName("-");
        mirrorRef = putName("mirror");
diff --git a/monetdb5/optimizer/opt_wrapper.c b/monetdb5/optimizer/opt_wrapper.c
--- a/monetdb5/optimizer/opt_wrapper.c
+++ b/monetdb5/optimizer/opt_wrapper.c
@@ -78,6 +78,7 @@ struct{
        {"mergetable", &OPTmergetableImplementation,0,0},
        {"mitosis", &OPTmitosisImplementation,0,0},
        {"mosaic", &OPTmosaicImplementation,0,0},
+       {"mosaiccoui", &OPTmosaicImplementation,0,0},
        {"multiplex", &OPTmultiplexImplementation,0,0},
        {"oltp", &OPToltpImplementation,0,0},
        {"postfix", &OPTpostfixImplementation,0,0},
@@ -142,7 +143,7 @@ str OPTwrapper (Client cntxt, MalBlkPtr 
        for (i=0; codes[i].nme; i++)
                if (strcmp(codes[i].nme, optimizer) == 0){
                        clk = GDKusec();
-                       msg = (str)(*(codes[i].fcn))(cntxt, mb, stk, 0);
+                       msg = (str)(*(codes[i].fcn))(cntxt, mb, stk, p);
                        codes[i].timing += GDKusec() - clk;
                        codes[i].calls++;
                        if (msg) 
diff --git a/monetdb5/optimizer/optimizer.mal b/monetdb5/optimizer/optimizer.mal
--- a/monetdb5/optimizer/optimizer.mal
+++ b/monetdb5/optimizer/optimizer.mal
@@ -196,6 +196,12 @@ pattern optimizer.mosaic(mod:str, fcn:st
 address OPTwrapper
 comment "Modify the plan to exploit compressed storage";
 
+pattern optimizer.mosaiccoui():str
+address OPTwrapper;
+pattern optimizer.mosaiccoui(mod:str, fcn:str):str
+address OPTwrapper
+comment "Modify the plan to exploit compressed storage";
+
 #opt_multiplex.mal
 pattern optimizer.multiplex():void
 address OPTwrapper
diff --git a/sql/test/mosaic/Tests/All b/sql/test/mosaic/Tests/All
--- a/sql/test/mosaic/Tests/All
+++ b/sql/test/mosaic/Tests/All
@@ -1,3 +1,4 @@
+join
 compression
 compressionRLE
 compressionRLE2
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to