Changeset: 4bab9a8dedfb for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4bab9a8dedfb
Added Files:
        monetdb5/optimizer/opt_emptycolumn.c
        monetdb5/optimizer/opt_emptycolumn.h
Removed Files:
        monetdb5/optimizer/opt_emptybind.h
Modified Files:
        monetdb5/optimizer/Makefile.ag
        monetdb5/optimizer/opt_candidates.c
        monetdb5/optimizer/opt_pipes.c
        monetdb5/optimizer/opt_prelude.c
        monetdb5/optimizer/opt_prelude.h
        monetdb5/optimizer/opt_support.c
        monetdb5/optimizer/opt_support.h
        monetdb5/optimizer/opt_wrapper.c
        monetdb5/optimizer/optimizer.mal
        sql/backends/monet5/sql.mal
        sql/backends/monet5/sql_optimizer.c
Branch: jit
Log Message:

rename and cleanup


diffs (truncated from 413 to 300 lines):

diff --git a/monetdb5/optimizer/Makefile.ag b/monetdb5/optimizer/Makefile.ag
--- a/monetdb5/optimizer/Makefile.ag
+++ b/monetdb5/optimizer/Makefile.ag
@@ -26,7 +26,7 @@ lib_optimizer = {
                opt_costModel.c opt_costModel.h \
                opt_dataflow.c opt_dataflow.h \
                opt_deadcode.c opt_deadcode.h \
-               opt_emptybind.c opt_emptybind.h \
+               opt_emptycolumn.c opt_emptycolumn.h \
                opt_evaluate.c opt_evaluate.h \
                opt_factorize.c opt_factorize.h \
                opt_garbageCollector.c opt_garbageCollector.h \
diff --git a/monetdb5/optimizer/opt_candidates.c 
b/monetdb5/optimizer/opt_candidates.c
--- a/monetdb5/optimizer/opt_candidates.c
+++ b/monetdb5/optimizer/opt_candidates.c
@@ -32,7 +32,7 @@ OPTcandidatesImplementation(Client cntxt
                                setVarCList(mb,getArg(p,0));
                        if(getFunctionId(p) == subdeltaRef) 
                                setVarCList(mb,getArg(p,0));
-                       if(getFunctionId(p) == emptybindRef && p->retc == 2) 
+                       if(getFunctionId(p) == emptycolumnRef && p->retc == 2) 
                                setVarCList(mb,getArg(p,0));
                        if(getFunctionId(p) == bindRef && p->retc == 2) 
                                setVarCList(mb,getArg(p,0));
diff --git a/monetdb5/optimizer/opt_emptybind.c 
b/monetdb5/optimizer/opt_emptycolumn.c
copy from monetdb5/optimizer/opt_emptybind.c
copy to monetdb5/optimizer/opt_emptycolumn.c
--- a/monetdb5/optimizer/opt_emptybind.c
+++ b/monetdb5/optimizer/opt_emptycolumn.c
@@ -22,7 +22,7 @@
  * and propagates them.
  */
 #include "monetdb_config.h"
-#include "opt_emptybind.h"
+#include "opt_emptycolumn.h"
 #include "opt_aliases.h"
 #include "opt_deadcode.h"
 #include "mal_builder.h"
@@ -35,34 +35,32 @@
                actions++;                                                      
                        \
        } while (0)
 
-#define emptyresult(TPE)                                                       
        \
+
+#define emptyresult(I)                                                         
\
        do {                                                                    
                        \
+               int tpe = getColumnType(getVarType(mb,getArg(p,I))); \
                clrFunction(p);                                                 
                \
-               setModuleId(p, batRef);                                         
        \
+               setModuleId(p,batRef);                                          
        \
                setFunctionId(p,newRef);                                        
        \
-               p->argc = 1;                                                    
                \
-               cst.vtype=TYPE_void;                                            
        \
-               cst.val.oval= oid_nil;                                          
        \
-               cst.len = 0;                                                    
                \
-               (void) convertConstant(TPE, &cst);                              
\
-               tmp = defConstant(mb,TPE,&cst);                                 
\
-               p= pushArgument(mb, p, tmp);                                    
        \
-               actions++;                                                      
                        \
+               p->argc = p->retc;                                              
                \
+               p = pushType(mb,p, TYPE_oid);                                   
\
+               p = pushType(mb,p,tpe);                                         
        \
        } while (0)
 
 
-//#undef       OPTDEBUGemptybind
-//#define      OPTDEBUGemptybind
+//#undef       OPTDEBUGemptycolumn
+//#define      OPTDEBUGemptycolumn
+
 int
-OPTemptybindImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci)
+OPTemptycolumnImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci)
 {
        int i, actions = 0;
        int *marked;
-       int limit = mb->stop, slimit= mb->ssize;
+       int limit = mb->stop;
        InstrPtr p, *old = mb->stmt;
 
        // use an instruction reference table to keep
-       // track of where 'emptybind' results are produced
+       // track of where 'emptycolumn' results are produced
        marked = (int *) GDKzalloc(mb->vsize * sizeof(int));
        if ( marked == NULL)
                return 0;
@@ -74,7 +72,7 @@ OPTemptybindImplementation(Client cntxt,
        (void) cntxt;
        (void) pci;
 
-       OPTDEBUGemptybind{
+       OPTDEBUGemptycolumn{
                mnstr_printf(GDKout, "Optimize Query Emptybind\n");
                printFunction(GDKout, mb, 0, LIST_MAL_DEBUG);
        }
@@ -100,28 +98,32 @@ OPTemptybindImplementation(Client cntxt,
                 * sequences to filter and replace results 
                 */
                if ( getModuleId(p) == batRef && getFunctionId(p) == newRef){
-                       OPTDEBUGemptybind
+                       OPTDEBUGemptycolumn
                                mnstr_printf(cntxt->fdout, "#empty bat  pc %d 
var %d\n",i , getArg(p,0) );
                        marked[getArg(p,0)] = i;
                        continue;
                } 
 
                /* restore the naming, dropping the runtime property 'marked' */
-               if (getFunctionId(p) == emptybindRef) {
-                       OPTDEBUGemptybind
+               if (getFunctionId(p) == emptycolumnRef) {
+                       OPTDEBUGemptycolumn
                                mnstr_printf(cntxt->fdout, "#empty bind  pc %d 
var %d\n",i , getArg(p,0) );
                        setFunctionId(p,bindRef);
                        marked[getArg(p,0)] = i;
                        if( p->retc == 2){
                                marked[getArg(p,1)] = i;
-                               OPTDEBUGemptybind
+                               OPTDEBUGemptycolumn
                                        mnstr_printf(cntxt->fdout, "#empty bind 
 pc %d var %d\n",i , getArg(p,1) );
                        }
+                       // replace the call into a empty bat creation
+                       if( p->retc == 1){
+                               emptyresult(0);
+                       }
                        continue;
                }
 
-               if (getFunctionId(p) == emptybindidxRef) {
-                       OPTDEBUGemptybind
+               if (getFunctionId(p) == emptycolumnidxRef) {
+                       OPTDEBUGemptycolumn
                                mnstr_printf(cntxt->fdout, "#empty bindidx  pc 
%d var %d\n",i , getArg(p,0) );
                        setFunctionId(p,bindidxRef);
                        marked[getArg(p,0)] = i;
@@ -130,10 +132,10 @@ OPTemptybindImplementation(Client cntxt,
 
                // delta operations without updates+ insert can be replaced by 
an assignment
                if (getModuleId(p)== sqlRef && getFunctionId(p) == deltaRef  && 
p->argc ==5){
-                       OPTDEBUGemptybind
+                       OPTDEBUGemptycolumn
                                mnstr_printf(cntxt->fdout, "#empty delta  pc %d 
var %d,%d,%d\n",i ,marked[getArg(p,2)], marked[getArg(p,3)], 
marked[getArg(p,4)] );
                        if( marked[getArg(p,2)] && marked[getArg(p,3)] && 
marked[getArg(p,4)] ){
-                               OPTDEBUGemptybind
+                               OPTDEBUGemptycolumn
                                        mnstr_printf(cntxt->fdout, "#empty 
delta  pc %d var %d\n",i , getArg(p,0) );
                                clrFunction(p);
                                p->argc = 2;
@@ -144,7 +146,7 @@ OPTemptybindImplementation(Client cntxt,
 
                if (getModuleId(p)== sqlRef && getFunctionId(p) == 
projectdeltaRef) {
                        if( marked[getArg(p,3)] && marked[getArg(p,4)] ){
-                               OPTDEBUGemptybind
+                               OPTDEBUGemptycolumn
                                        mnstr_printf(cntxt->fdout, "#empty 
projectdelta  pc %d var %d\n",i , getArg(p,0) );
                                        setModuleId(p,algebraRef);
                                        setFunctionId(p,projectionRef);
@@ -152,12 +154,19 @@ OPTemptybindImplementation(Client cntxt,
                        }
                        continue;
                }
+               if (getModuleId(p)== algebraRef){
+                       if( getFunctionId(p) == projectionRef) {
+                               if( marked[getArg(p,1)] || marked[getArg(p,2)] 
){
+                                       OPTDEBUGemptycolumn
+                                               mnstr_printf(cntxt->fdout, 
"#empty projection  pc %d var %d\n",i , getArg(p,0) );
+                                       emptyresult(0);
+                               }
+                       }
+               }
        }
-       for(; i<slimit; i++)
-               if (old[i])
-                       freeInstruction(old[i]);
 
-       OPTDEBUGemptybind{
+       chkTypes(cntxt->fdout, cntxt->nspace,mb,TRUE);
+       OPTDEBUGemptycolumn{
                mnstr_printf(GDKout, "Optimize Query Emptybind done\n");
                printFunction(GDKout, mb, 0, LIST_MAL_DEBUG);
        }
diff --git a/monetdb5/optimizer/opt_emptybind.h 
b/monetdb5/optimizer/opt_emptycolumn.h
rename from monetdb5/optimizer/opt_emptybind.h
rename to monetdb5/optimizer/opt_emptycolumn.h
--- a/monetdb5/optimizer/opt_emptybind.h
+++ b/monetdb5/optimizer/opt_emptycolumn.h
@@ -17,13 +17,13 @@
  * All Rights Reserved.
  */
 
-#ifndef _MAL_EMPTYBIND_
-#define _MAL_EMPTYBIND_
+#ifndef _MAL_EMPTYCOLUMN_
+#define _MAL_EMPTYCOLUMN_
 #include "opt_prelude.h"
 #include "opt_support.h"
 
-opt_export int OPTemptybindImplementation(Client cntxt, MalBlkPtr mb, 
MalStkPtr stk, InstrPtr p);
+opt_export int OPTemptycolumnImplementation(Client cntxt, MalBlkPtr mb, 
MalStkPtr stk, InstrPtr p);
 
-#define OPTDEBUGemptybind  if ( optDebug & ((lng) 1 <<DEBUG_OPT_EMPTYBIND) )
+#define OPTDEBUGemptycolumn  if ( optDebug & ((lng) 1 <<DEBUG_OPT_EMPTYCOLUMN) 
)
 
 #endif
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
@@ -67,7 +67,7 @@ static struct PIPELINES {
         "optimizer.costModel();"
         "optimizer.coercions();"
         "optimizer.evaluate();"
-        "optimizer.emptybind();"
+        "optimizer.emptycolumn();"
         "optimizer.pushselect();"
         "optimizer.aliases();"
         "optimizer.mitosis();"
@@ -98,7 +98,7 @@ static struct PIPELINES {
         "optimizer.costModel();"
         "optimizer.coercions();"
         "optimizer.evaluate();"
-        "optimizer.emptybind();"
+        "optimizer.emptycolumn();"
         "optimizer.pushselect();"
         "optimizer.aliases();"
         "optimizer.mitosis();"
@@ -137,7 +137,7 @@ static struct PIPELINES {
         "optimizer.costModel();"
         "optimizer.coercions();"
         "optimizer.evaluate();"
-        "optimizer.emptybind();"
+        "optimizer.emptycolumn();"
         "optimizer.pushselect();"
         "optimizer.aliases();"
         "optimizer.mergetable();"
@@ -174,7 +174,7 @@ static struct PIPELINES {
         "optimizer.costModel();"
         "optimizer.coercions();"
         "optimizer.evaluate();"
-        "optimizer.emptybind();"
+        "optimizer.emptycolumn();"
         "optimizer.pushselect();"
         "optimizer.aliases();"
         "optimizer.mergetable();"
@@ -203,7 +203,7 @@ static struct PIPELINES {
         "optimizer.costModel();"
         "optimizer.coercions();"
         "optimizer.evaluate();"
-        "optimizer.emptybind();"
+        "optimizer.emptycolumn();"
         "optimizer.pushselect();"
         "optimizer.aliases();"
         "optimizer.mitosis();"
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
@@ -48,8 +48,8 @@ str projectdeltaRef;
 str binddbatRef;
 str bindidxRef;
 str bindRef;
-str emptybindRef;
-str emptybindidxRef;
+str emptycolumnRef;
+str emptycolumnidxRef;
 str bpmRef;
 str bstreamRef;
 str calcRef;
@@ -278,8 +278,8 @@ void optimizerInit(void)
        binddbatRef = putName("bind_dbat");
        bindidxRef = putName("bind_idxbat");
        bindRef = putName("bind");
-       emptybindRef = putName("emptybind");
-       emptybindidxRef = putName("emptybindidx");
+       emptycolumnRef = putName("emptycolumn");
+       emptycolumnidxRef = putName("emptycolumnidx");
        bpmRef = putName("bpm");
        bstreamRef = putName("bstream");
        calcRef = putName("calc");
diff --git a/monetdb5/optimizer/opt_prelude.h b/monetdb5/optimizer/opt_prelude.h
--- a/monetdb5/optimizer/opt_prelude.h
+++ b/monetdb5/optimizer/opt_prelude.h
@@ -46,8 +46,8 @@ opt_export  str projectdeltaRef;
 opt_export  str binddbatRef;
 opt_export  str bindidxRef;
 opt_export  str bindRef;
-opt_export  str emptybindRef;
-opt_export     str emptybindidxRef;
+opt_export  str emptycolumnRef;
+opt_export     str emptycolumnidxRef;
 opt_export  str bpmRef;
 opt_export  str bstreamRef;
 opt_export  str calcRef;
diff --git a/monetdb5/optimizer/opt_support.c b/monetdb5/optimizer/opt_support.c
--- a/monetdb5/optimizer/opt_support.c
+++ b/monetdb5/optimizer/opt_support.c
@@ -138,7 +138,7 @@ struct OPTcatalog {
 {"datacyclotron",0,    0,      0,      DEBUG_OPT_DATACYCLOTRON},
 {"dataflow",   0,      0,      0,      DEBUG_OPT_DATAFLOW},
 {"deadcode",   0,      0,      0,      DEBUG_OPT_DEADCODE},
-{"emptybind",  0,      0,      0,      DEBUG_OPT_EMPTYBIND},
+{"emptycolumn",        0,      0,      0,      DEBUG_OPT_EMPTYCOLUMN},
 {"evaluate",   0,      0,      0,      DEBUG_OPT_EVALUATE},
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to