Changeset: f2dffa9077f6 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f2dffa9077f6
Modified Files:
        sql/backends/monet5/datacell/datacell.c
        sql/backends/monet5/datacell/opt_datacell.c
        sql/backends/monet5/datacell/opt_datacell.h
Branch: Feb2013
Log Message:

Fixing the datacell optimizer, step 1
The basic functionality works again. Scenario00.sql in
the test suite runs correctly.


diffs (128 lines):

diff --git a/sql/backends/monet5/datacell/datacell.c 
b/sql/backends/monet5/datacell/datacell.c
--- a/sql/backends/monet5/datacell/datacell.c
+++ b/sql/backends/monet5/datacell/datacell.c
@@ -351,7 +351,7 @@ DCquery(Client cntxt, MalBlkPtr mb, MalS
        /* optimize the code and register at scheduler */
        if (msg == MAL_SUCCEED) {
                OPTdatacellImplementation(cntxt, s->def, 0, 0);
-               addOptimizers(cntxt, s->def);
+               addOptimizers(cntxt, s->def,"default_pipe");
                if (msg == MAL_SUCCEED)
                        msg = optimizeMALBlock(cntxt, s->def);
                if (msg == MAL_SUCCEED)
diff --git a/sql/backends/monet5/datacell/opt_datacell.c 
b/sql/backends/monet5/datacell/opt_datacell.c
--- a/sql/backends/monet5/datacell/opt_datacell.c
+++ b/sql/backends/monet5/datacell/opt_datacell.c
@@ -47,8 +47,10 @@ OPTdatacellImplementation(Client cntxt, 
        char *tables[128] = { NULL };
        char *appends[128] = { NULL };
        InstrPtr q[128], qa[128] = { NULL };
-       lng clk /*,t*/;
+       lng clk = GDKusec();
        int *alias;
+       char *msg = MAL_SUCCEED;
+       char *tidlist;
        char buf[BUFSIZ];
 
        (void) pci;
@@ -67,9 +69,10 @@ OPTdatacellImplementation(Client cntxt, 
                return 0;
 
        alias = (int *) GDKzalloc(mb->vtop * 2 * sizeof(int));
+       tidlist = (char *) GDKzalloc(mb->vtop );
        if (alias == 0)
                return 0;
-       removeDataflow(old, limit);
+       removeDataflow(mb, old, limit);
 
        pushInstruction(mb, old[0]);
        newFcnCall(mb, sqlRef, putName("transaction", 11));
@@ -119,14 +122,25 @@ OPTdatacellImplementation(Client cntxt, 
                                (void) newFcnCall(mb, sqlRef, commitRef);
                                break;
                        }
+
+                       if (getModuleId(p) == sqlRef && getFunctionId(p) == 
mvcRef)
+                               mvc = getArg(p, 0);
+
+                       /* trim the number of sql instructions dealing with 
baskets */
                        if (getModuleId(p) == sqlRef && getFunctionId(p) == 
putName("affectedRows", 12)) {
                                freeInstruction(p);
                                continue;
                        }
 
-                       if (getModuleId(p) == sqlRef && getFunctionId(p) == 
mvcRef)
-                               mvc = getArg(p, 0);
-
+                       /* remove delta processing for baskets */
+                       if (getModuleId(p) == sqlRef && (getFunctionId(p) == 
deltaRef || getFunctionId(p) == projectdeltaRef || getFunctionId(p) == 
subdeltaRef) ) {
+                               clrFunction(p);
+                               getArg(p,1) = alias[getArg(p, 1)];
+                               p->argc =2;
+                               pushInstruction(mb, p);
+                               continue;
+                       }
+                       /* localize access to basket tables */
                        if (getModuleId(p) == sqlRef && (getFunctionId(p) == 
bindRef || getFunctionId(p) == binddbatRef)) {
                                snprintf(buf, BUFSIZ, "%s.%s", 
getVarConstant(mb, getArg(p, 2)).val.sval, getVarConstant(mb, getArg(p, 
3)).val.sval);
                                col = getVarConstant(mb, getArg(p, 4)).val.sval;
@@ -183,6 +197,18 @@ OPTdatacellImplementation(Client cntxt, 
                                        varSetProp(mb, p->argv[0], rowsProp, 
op_eq, VALset(&vr, TYPE_wrd, &rows));
                                }
                        }
+                       /* localize access to tid lists for basket tables */
+                       if (getModuleId(p) == sqlRef && getFunctionId(p) == 
tidRef ){
+                               snprintf(buf, BUFSIZ, "%s.%s", 
getVarConstant(mb, getArg(p, 2)).val.sval, getVarConstant(mb, getArg(p, 
3)).val.sval);
+                               bskt = BSKTlocate(buf);
+                               tidlist[getArg(p,0)] = bskt > 0;
+                       }
+                       /* remove consolidation of tid lists */
+                       if (getModuleId(p) == algebraRef && getFunctionId(p) == 
leftfetchjoinRef  && tidlist[getArg(p,1)]){
+                               alias[getArg(p, 0)] = getArg(p,2);
+                               freeInstruction(p);
+                               continue;
+                       }
 
                        for (j = 0; j < p->argc; j++)
                                if (alias[getArg(p, j)])
@@ -252,16 +278,26 @@ OPTdatacellImplementation(Client cntxt, 
        (void) stk;
        (void) pci;
 
+       OPTDEBUGdatacell {
+               mnstr_printf(cntxt->fdout, "#Datacell optimizer finished\n");
+               printFunction(cntxt->fdout, mb, stk, LIST_MAL_STMT);
+       } 
+       /* optimize this new continous query using the default pipe */
+       addOptimizers(cntxt, mb, "default_pipe");
+       msg = optimizeMALBlock(cntxt, mb);
+       if (msg == MAL_SUCCEED)
+               msg = optimizerCheck(cntxt, mb, "optimizer.datacell", actions, 
(GDKusec() - clk), OPT_CHECK_ALL);
+
        if (actions)
        {
                /* extend the plan with the new optimizer pipe required */
                clk = GDKusec();
-               optimizerCheck(cntxt, mb, "optimizer.datacell", 1, /*t =*/ 
(GDKusec() - clk), OPT_CHECK_ALL);
+               optimizerCheck(cntxt, mb, "optimizer.datacell", 1,  (GDKusec() 
- clk), OPT_CHECK_ALL);
                addtoMalBlkHistory(mb, "datacell");
        }
        GDKfree(alias);
+       GDKfree(tidlist);
        for (j = 0; j < m; j++)
                GDKfree(tables[j]);
        return actions;
 }
-
diff --git a/sql/backends/monet5/datacell/opt_datacell.h 
b/sql/backends/monet5/datacell/opt_datacell.h
--- a/sql/backends/monet5/datacell/opt_datacell.h
+++ b/sql/backends/monet5/datacell/opt_datacell.h
@@ -23,6 +23,7 @@
 #include "opt_support.h"
 #include "opt_pipes.h"
 
-#define OPTDEBUGdatacell  if (optDebug & (1 << DEBUG_OPT_DATACELL))
+#define OPTDEBUGdatacell   if (1)
+//#define OPTDEBUGdatacell  if (optDebug & (1 << DEBUG_OPT_DATACELL))
 opt_export int OPTdatacellImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr 
stk, InstrPtr pci);
 #endif
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to