Changeset: 86a4dd0f9aea for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=86a4dd0f9aea
Modified Files:
        monetdb5/optimizer/Makefile.ag
        monetdb5/optimizer/opt_pipes.mx
        sql/backends/monet5/datacell/Makefile.ag
        sql/backends/monet5/datacell/Tests/poc.sql
        sql/backends/monet5/datacell/opt_dataflow.mx
Branch: default
Log Message:

Take care of boundary conditions


diffs (218 lines):

diff --git a/monetdb5/optimizer/Makefile.ag b/monetdb5/optimizer/Makefile.ag
--- a/monetdb5/optimizer/Makefile.ag
+++ b/monetdb5/optimizer/Makefile.ag
@@ -38,7 +38,6 @@
                opt_constants.mx \
                opt_costModel.mx \
                opt_crack.mx \
-               opt_datacell.mx \
                opt_datacyclotron.mx \
                opt_dataflow.mx \
                opt_deadcode.mx \
@@ -92,7 +91,7 @@
                opt_singleton.mx opt_costModel.mx opt_reduce.mx opt_macro.mx \
                opt_accumulators.mx opt_qep.mx opt_mergetable.mx \
                opt_remoteQueries.mx opt_joinselect.mx opt_partitions.mx \
-               opt_datacell.mx opt_reorder.mx opt_prejoin.mx 
opt_compression.mx \
+               opt_reorder.mx opt_prejoin.mx opt_compression.mx \
                opt_evaluate.mx opt_inline.mx opt_pushranges.mx 
opt_derivepath.mx \
                opt_accessmode.mx opt_joinpath.mx opt_heuristics.mx 
opt_remap.mx \
                opt_statistics.mx opt_trace.mx  opt_recycler.mx opt_dataflow.mx 
\
diff --git a/monetdb5/optimizer/opt_pipes.mx b/monetdb5/optimizer/opt_pipes.mx
--- a/monetdb5/optimizer/opt_pipes.mx
+++ b/monetdb5/optimizer/opt_pipes.mx
@@ -107,9 +107,8 @@
 {"dictionary_pipe",    
"inline,remap,dictionary,evaluate,costModel,coercions,emptySet,aliases,mergetable,deadcode,constants,commonTerms,joinPath,deadcode,reduce,dataflow,history,multiplex,garbageCollector"},
 
 /* The default + compression */
-{"compression_pipe",   
"inline,remap,evaluate,costModel,coercions,emptySet,aliases,mergetable,deadcode,constants,commonTerms,joinPath,deadcode,reduce,dataflow,compression,dataflow,history,multiplex,garbageCollector"},
+{"compression_pipe",   
"inline,remap,evaluate,costModel,coercions,emptySet,aliases,mergetable,deadcode,constants,commonTerms,joinPath,deadcode,reduce,dataflow,compression,dataflow,history,multiplex,garbageCollector"}
 
-{"",""}
 };
 @-
 Debugging the optimizer pipeline",
@@ -144,7 +143,7 @@
 {
        int i;
 
-       for( i=0; *pipes[i].name; i++)
+       for( i=0; i < MAXOPTPIPES && *pipes[i].name; i++)
                if ( strcmp(name, pipes[i].name) == 0)
                        return GDKstrdup(pipes[i].def);
        return NULL;
@@ -165,7 +164,7 @@
        }
        BATseqbase(b,0);
        BATseqbase(bn,0);
-       for( i=0; *pipes[i].name; i++){
+       for( i=0; i < MAXOPTPIPES && *pipes[i].name; i++){
                BUNappend(b,pipes[i].name, FALSE);
                BUNappend(bn,pipes[i].def, FALSE);
        }
diff --git a/sql/backends/monet5/datacell/Makefile.ag 
b/sql/backends/monet5/datacell/Makefile.ag
--- a/sql/backends/monet5/datacell/Makefile.ag
+++ b/sql/backends/monet5/datacell/Makefile.ag
@@ -40,6 +40,7 @@
                  receptor.mx \
                  petrinet.mx \
                  dcoperator.mx \
+                 opt_dataflow.mx \
                  emitter.mx 
 
     LIBS = ../../../../monetdb5/tools/libmonetdb5 \
@@ -71,6 +72,7 @@
                  receptor.mal \
                  emitter.mal \
                  petrinet.mal \
+                 opt_dataflow.mx \
                  dcoperator.mal
 }
 
diff --git a/sql/backends/monet5/datacell/Tests/poc.sql 
b/sql/backends/monet5/datacell/Tests/poc.sql
--- a/sql/backends/monet5/datacell/Tests/poc.sql
+++ b/sql/backends/monet5/datacell/Tests/poc.sql
@@ -12,6 +12,7 @@
 );
 
 -- to be used by continous queries
+-- could be generated from the table definition.
 create function datacell.basket_X()
 returns table (id integer, tag timestamp, payload integer)
 begin
diff --git a/sql/backends/monet5/datacell/opt_dataflow.mx 
b/sql/backends/monet5/datacell/opt_dataflow.mx
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/datacell/opt_dataflow.mx
@@ -0,0 +1,131 @@
+@/
+The contents of this file are subject to the MonetDB Public License
+Version 1.1 (the "License"); you may not use this file except in
+compliance with the License. You may obtain a copy of the License at
+http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
+
+Software distributed under the License is distributed on an "AS IS"
+basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+License for the specific language governing rights and limitations
+under the License.
+
+The Original Code is the MonetDB Database System.
+
+The Initial Developer of the Original Code is CWI.
+Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+Copyright August 2008-2011 MonetDB B.V.
+All Rights Reserved.
+@
+
+@f opt_datacell
+@a M. Kersten
+@- Datacell optimizer
+Assume simple queries 
+@{
+@mal
+pattern optimizer.datacell():str
+address OPTdatacell;
+pattern optimizer.datacell(mod:str, fcn:str):str
+address OPTdatacell
+comment "Datacell expression optimizer";
+
+@h
+#ifndef _OPT_DATACELL_
+#define _OPT_DATACELL_
+#include "opt_prelude.h"
+#include "opt_support.h"
+
+#define OPTDEBUGdatacell  if ( optDebug & (1 <<DEBUG_OPT_DATACELL) )
+
+@-
+We keep a flow dependency table to detect.
+@c
+#include "monetdb_config.h"
+#include "opt_datacell.h"
+#include "opt_deadcode.h"
+#include "mal_interpreter.h"   /* for showErrors() */
+#include "mal_builder.h"
+
+static int
+OPTdatacellImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci)
+{
+
+       addPipeDefinition("default_pipe",   
+                                       
"inline,remap,datacell,evaluate,costModel,coercions,emptySet,aliases,mitosis,"
+                                       
"mergetable,deadcode,commonTerms,joinPath,reorder,deadcode,reduce,dataflow,"
+                                       
"history,multiplex,accumulators,garbageCollector" );
+       OPTDEBUGdatacell {
+               mnstr_printf(cntxt->fdout, "#Datacell optimizer started\n");
+               printFunction(cntxt->fdout, mb, 0, LIST_MAL_STMT);
+       }
+       (void) stk;
+       (void) pci;
+       return 0;
+}
+@= exportOptimizer
+opt_export str OPT@1(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
+
+@= wrapOptimizer
+/* #define _DEBUG_OPTIMIZER_*/
+
+str OPT@1(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p){
+    str modnme;
+    str fcnnme;
+    str msg= MAL_SUCCEED;
+    Symbol s= NULL;
+    lng t,clk= GDKusec();
+    int actions = 0;
+
+    optimizerInit();
+    if( p )
+        removeInstruction(mb, p);
+    OPTDEBUG@1 mnstr_printf(cntxt->fdout,"=APPLY OPTIMIZER @1\n");
+    if( p && p->argc > 1 ){
+        if( getArgType(mb,p,1) != TYPE_str ||
+            getArgType(mb,p,2) != TYPE_str ||
+            !isVarConstant(mb,getArg(p,1)) ||
+            !isVarConstant(mb,getArg(p,2))
+        ) {
+            throw(MAL, "optimizer.@1", ILLARG_CONSTANTS);
+        }
+        if( stk != 0){
+            modnme= *(str*)getArgReference(stk,p,1);
+            fcnnme= *(str*)getArgReference(stk,p,2);
+        } else {
+            modnme= getArgDefault(mb,p,1);
+            fcnnme= getArgDefault(mb,p,2);
+        }
+        s= findSymbol(cntxt->nspace, 
putName(modnme,strlen(modnme)),putName(fcnnme,strlen(fcnnme)));
+
+        if( s == NULL) {
+            char buf[1024];
+            snprintf(buf,1024, "%s.%s",modnme,fcnnme);
+            throw(MAL, "optimizer.@1", RUNTIME_OBJECT_UNDEFINED ":%s", buf);
+        }
+        mb = s->def;
+        stk= 0;
+    }
+    if( mb->errors ){
+        /* when we have errors, we still want to see them */
+        addtoMalBlkHistory(mb,"@1");
+        return MAL_SUCCEED;
+    }
+    actions= OPT@1Implementation(cntxt, mb,stk,p);
+    msg= optimizerCheck(cntxt, mb, "optimizer.@1", actions, t=(GDKusec() - 
clk),@2);
+    OPTDEBUG@1 {
+        mnstr_printf(cntxt->fdout,"=FINISHED @1 %d\n",actions);
+        printFunction(cntxt->fdout,mb,0,LIST_MAL_STMT | LIST_MAPI);
+    }
+    DEBUGoptimizers
+        mnstr_printf(cntxt->fdout,"#opt_reduce: %d ms\n",t);
+    QOTupdateStatistics("@1",actions,t);
+    addtoMalBlkHistory(mb,"@1");
+    return msg;
+}
+@h
+@:exportOptimizer(datacell)@
+#endif
+@c
+#include "opt_statistics.h"
+@:wrapOptimizer(datacell,OPT_CHECK_ALL)@
+@}
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to