Changeset: 742d825e789e for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=742d825e789e Added Files: sql/backends/monet5/timetrails/50_timetrails.mal sql/backends/monet5/timetrails/50_timetrails.sql sql/backends/monet5/timetrails/Makefile.ag sql/backends/monet5/timetrails/Tests/.gdk_lock sql/backends/monet5/timetrails/Tests/All sql/backends/monet5/timetrails/Tests/TestingRecipe sql/backends/monet5/timetrails/Tests/ais/Tests/All sql/backends/monet5/timetrails/Tests/ais/Tests/ais01.sql sql/backends/monet5/timetrails/Tests/ais/Tests/ais02.sql sql/backends/monet5/timetrails/Tests/ais/Tests/ais03.sql sql/backends/monet5/timetrails/Tests/ais/Tests/ais04.sql sql/backends/monet5/timetrails/Tests/ais/Tests/ais05.sql sql/backends/monet5/timetrails/Tests/ais/Tests/ais06.sql sql/backends/monet5/timetrails/Tests/ais/Tests/ais07.sql sql/backends/monet5/timetrails/Tests/ais/Tests/ais08.sql sql/backends/monet5/timetrails/Tests/ais/Tests/ais09.sql sql/backends/monet5/timetrails/Tests/ais/Tests/ais10.sql sql/backends/monet5/timetrails/Tests/ais/Tests/ais11.sql sql/backends/monet5/timetrails/Tests/bug01.sql sql/backends/monet5/timetrails/Tests/bug02.sql sql/backends/monet5/timetrails/Tests/bug03.sql sql/backends/monet5/timetrails/Tests/bug04.sql sql/backends/monet5/timetrails/Tests/bug05.sql sql/backends/monet5/timetrails/Tests/bug06.sql sql/backends/monet5/timetrails/Tests/export00.sql sql/backends/monet5/timetrails/Tests/genbasket.c sql/backends/monet5/timetrails/Tests/inputoutput.sql sql/backends/monet5/timetrails/Tests/iot00.sql sql/backends/monet5/timetrails/Tests/iot01.sql sql/backends/monet5/timetrails/Tests/iot02.sql sql/backends/monet5/timetrails/Tests/iot03.sql sql/backends/monet5/timetrails/Tests/iot04.sql sql/backends/monet5/timetrails/Tests/iot06.sql sql/backends/monet5/timetrails/Tests/iot10.sql sql/backends/monet5/timetrails/Tests/iot11.sql sql/backends/monet5/timetrails/Tests/iot12.sql sql/backends/monet5/timetrails/Tests/iot13.sql sql/backends/monet5/timetrails/Tests/iot14.sql sql/backends/monet5/timetrails/Tests/iot15.sql sql/backends/monet5/timetrails/Tests/iot16.sql sql/backends/monet5/timetrails/Tests/logger.sql sql/backends/monet5/timetrails/Tests/petrinet00.mal sql/backends/monet5/timetrails/Tests/receptor00.sql sql/backends/monet5/timetrails/Tests/receptor01.sql sql/backends/monet5/timetrails/Tests/webtest.sql sql/backends/monet5/timetrails/Tests/x.ql sql/backends/monet5/timetrails/basket.c sql/backends/monet5/timetrails/basket.h sql/backends/monet5/timetrails/basket.mal sql/backends/monet5/timetrails/petrinet.c sql/backends/monet5/timetrails/petrinet.h sql/backends/monet5/timetrails/petrinet.mal sql/backends/monet5/timetrails/timetrails.c sql/backends/monet5/timetrails/timetrails.h sql/backends/monet5/timetrails/timetrails.mal Removed Files: monetdb5/optimizer/opt_iot.c monetdb5/optimizer/opt_iot.h sql/backends/monet5/iot/50_iot.mal sql/backends/monet5/iot/50_iot.sql sql/backends/monet5/iot/Makefile.ag sql/backends/monet5/iot/Tests/.gdk_lock sql/backends/monet5/iot/Tests/All sql/backends/monet5/iot/Tests/TestingRecipe sql/backends/monet5/iot/Tests/ais/Tests/All sql/backends/monet5/iot/Tests/ais/Tests/ais01.sql sql/backends/monet5/iot/Tests/ais/Tests/ais01.stable.err sql/backends/monet5/iot/Tests/ais/Tests/ais01.stable.out sql/backends/monet5/iot/Tests/ais/Tests/ais02.sql sql/backends/monet5/iot/Tests/ais/Tests/ais02.stable.err sql/backends/monet5/iot/Tests/ais/Tests/ais02.stable.out sql/backends/monet5/iot/Tests/ais/Tests/ais03.sql sql/backends/monet5/iot/Tests/ais/Tests/ais03.stable.err sql/backends/monet5/iot/Tests/ais/Tests/ais03.stable.out sql/backends/monet5/iot/Tests/ais/Tests/ais04.sql sql/backends/monet5/iot/Tests/ais/Tests/ais04.stable.err sql/backends/monet5/iot/Tests/ais/Tests/ais04.stable.out sql/backends/monet5/iot/Tests/ais/Tests/ais05.sql sql/backends/monet5/iot/Tests/ais/Tests/ais05.stable.err sql/backends/monet5/iot/Tests/ais/Tests/ais05.stable.out sql/backends/monet5/iot/Tests/ais/Tests/ais06.sql sql/backends/monet5/iot/Tests/ais/Tests/ais06.stable.err sql/backends/monet5/iot/Tests/ais/Tests/ais06.stable.out sql/backends/monet5/iot/Tests/ais/Tests/ais07.sql sql/backends/monet5/iot/Tests/ais/Tests/ais07.stable.err sql/backends/monet5/iot/Tests/ais/Tests/ais07.stable.out sql/backends/monet5/iot/Tests/ais/Tests/ais08.sql sql/backends/monet5/iot/Tests/ais/Tests/ais08.stable.err sql/backends/monet5/iot/Tests/ais/Tests/ais08.stable.out sql/backends/monet5/iot/Tests/ais/Tests/ais09.sql sql/backends/monet5/iot/Tests/ais/Tests/ais09.stable.err sql/backends/monet5/iot/Tests/ais/Tests/ais09.stable.out sql/backends/monet5/iot/Tests/ais/Tests/ais10.sql sql/backends/monet5/iot/Tests/ais/Tests/ais10.stable.err sql/backends/monet5/iot/Tests/ais/Tests/ais10.stable.out sql/backends/monet5/iot/Tests/ais/Tests/ais11.sql sql/backends/monet5/iot/Tests/ais/Tests/ais11.stable.err sql/backends/monet5/iot/Tests/ais/Tests/ais11.stable.out sql/backends/monet5/iot/Tests/bug01.sql sql/backends/monet5/iot/Tests/bug01.stable.err sql/backends/monet5/iot/Tests/bug01.stable.out sql/backends/monet5/iot/Tests/bug02.sql sql/backends/monet5/iot/Tests/bug02.stable.err sql/backends/monet5/iot/Tests/bug02.stable.out sql/backends/monet5/iot/Tests/bug03.sql sql/backends/monet5/iot/Tests/bug03.stable.err sql/backends/monet5/iot/Tests/bug03.stable.out sql/backends/monet5/iot/Tests/bug04.sql sql/backends/monet5/iot/Tests/bug04.stable.err sql/backends/monet5/iot/Tests/bug04.stable.out sql/backends/monet5/iot/Tests/bug05.sql sql/backends/monet5/iot/Tests/bug05.stable.err sql/backends/monet5/iot/Tests/bug05.stable.out sql/backends/monet5/iot/Tests/bug06.sql sql/backends/monet5/iot/Tests/export00.sql sql/backends/monet5/iot/Tests/export00.stable.err sql/backends/monet5/iot/Tests/export00.stable.out sql/backends/monet5/iot/Tests/genbasket.c sql/backends/monet5/iot/Tests/inputoutput.sql sql/backends/monet5/iot/Tests/inputoutput.stable.err sql/backends/monet5/iot/Tests/inputoutput.stable.out sql/backends/monet5/iot/Tests/iot00.sql sql/backends/monet5/iot/Tests/iot00.stable.err sql/backends/monet5/iot/Tests/iot00.stable.out sql/backends/monet5/iot/Tests/iot01.sql sql/backends/monet5/iot/Tests/iot01.stable.err sql/backends/monet5/iot/Tests/iot01.stable.out sql/backends/monet5/iot/Tests/iot02.sql sql/backends/monet5/iot/Tests/iot02.stable.err sql/backends/monet5/iot/Tests/iot02.stable.out sql/backends/monet5/iot/Tests/iot03.sql sql/backends/monet5/iot/Tests/iot03.stable.err sql/backends/monet5/iot/Tests/iot03.stable.out sql/backends/monet5/iot/Tests/iot04.sql sql/backends/monet5/iot/Tests/iot04.stable.err sql/backends/monet5/iot/Tests/iot04.stable.out sql/backends/monet5/iot/Tests/iot06.sql sql/backends/monet5/iot/Tests/iot06.stable.err sql/backends/monet5/iot/Tests/iot06.stable.out sql/backends/monet5/iot/Tests/iot10.sql sql/backends/monet5/iot/Tests/iot10.stable.err sql/backends/monet5/iot/Tests/iot10.stable.out sql/backends/monet5/iot/Tests/iot11.sql sql/backends/monet5/iot/Tests/iot11.stable.err sql/backends/monet5/iot/Tests/iot11.stable.out sql/backends/monet5/iot/Tests/iot12.sql sql/backends/monet5/iot/Tests/iot12.stable.err sql/backends/monet5/iot/Tests/iot12.stable.out sql/backends/monet5/iot/Tests/iot13.sql sql/backends/monet5/iot/Tests/iot13.stable.err sql/backends/monet5/iot/Tests/iot13.stable.out sql/backends/monet5/iot/Tests/iot14.sql sql/backends/monet5/iot/Tests/iot14.stable.err sql/backends/monet5/iot/Tests/iot14.stable.out sql/backends/monet5/iot/Tests/iot15.sql sql/backends/monet5/iot/Tests/iot16.sql sql/backends/monet5/iot/Tests/iot16.stable.err sql/backends/monet5/iot/Tests/iot16.stable.out sql/backends/monet5/iot/Tests/logger.sql sql/backends/monet5/iot/Tests/petrinet00.mal sql/backends/monet5/iot/Tests/receptor00.sql sql/backends/monet5/iot/Tests/receptor00.stable.err sql/backends/monet5/iot/Tests/receptor00.stable.out sql/backends/monet5/iot/Tests/receptor01.sql sql/backends/monet5/iot/Tests/receptor01.stable.err sql/backends/monet5/iot/Tests/receptor01.stable.out sql/backends/monet5/iot/Tests/webtest.sql sql/backends/monet5/iot/Tests/webtest.stable.err sql/backends/monet5/iot/Tests/webtest.stable.out sql/backends/monet5/iot/Tests/x.ql sql/backends/monet5/iot/basket.c sql/backends/monet5/iot/basket.h sql/backends/monet5/iot/basket.mal sql/backends/monet5/iot/iot.c sql/backends/monet5/iot/iot.h sql/backends/monet5/iot/iot.mal sql/backends/monet5/iot/petrinet.c sql/backends/monet5/iot/petrinet.h sql/backends/monet5/iot/petrinet.mal Branch: timetrails Log Message:
Transform the iot branch diffs (truncated from 14234 to 300 lines): diff --git a/monetdb5/optimizer/opt_iot.c b/monetdb5/optimizer/opt_iot.c deleted file mode 100644 --- a/monetdb5/optimizer/opt_iot.c +++ /dev/null @@ -1,323 +0,0 @@ -/* - * 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://www.monetdb.org/Legal/MonetDBLicense - * - * 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-2015 MonetDB B.V. - * All Rights Reserved. - */ - -/* - * (author) M. Kersten - * Assume simple queries . Clear out all non-iot schema related sql statements, except for the bare minimum. - */ -/* - * We keep a flow dependency table to detect. - */ -#include "monetdb_config.h" -#include "opt_iot.h" -#include "opt_deadcode.h" -#include "mal_interpreter.h" /* for showErrors() */ -#include "mal_builder.h" -#include "opt_dataflow.h" - -#define MAXBSKT 64 -#define getStreamTableInfo(S,T) \ - for(fnd=0, k= 0; k< btop; k++) \ - if( strcmp(schemas[k], S)== 0 && strcmp(tables[k], T)== 0 ){ \ - fnd= 1; break;\ - } - -str -OPTiotImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) -{ - int i, j, k, fnd, limit, slimit; - InstrPtr r, p, *old; - int *alias; - str schemas[MAXBSKT]; - str tables[MAXBSKT]; - int input[MAXBSKT]= {0}; - int output[MAXBSKT]= {0}; - int btop=0, lastmvc=0; - int noerror=0; - int mvcseen = 0; - int cq= strncmp(getFunctionId(getInstrPtr(mb,0)),"cq",2) == 0; - char buf[256]; - lng usec = GDKusec(); - - (void) pci; - // Check applicability of optimizer by looking for streams - for(i =0; i< mb->stop; i++){ - p= getInstrPtr(mb,i); - if( getModuleId(p) == basketRef|| - getModuleId(p) == iotRef) - break; - } - if( i == mb->stop) - return MAL_SUCCEED; - -#ifdef DEBUG_OPT_IOT - mnstr_printf(cntxt->fdout, "#iot optimizer start\n"); - printFunction(cntxt->fdout, mb, stk, LIST_MAL_DEBUG); -#endif - old = mb->stmt; - limit = mb->stop; - slimit = mb->ssize; - - /* first analyse the query for streaming tables */ - for (i = 1; i < limit && btop <MAXBSKT; i++){ - p = old[i]; - if( getModuleId(p)== basketRef && (getFunctionId(p)== registerRef || getFunctionId(p)== bindRef ) ){ -#ifdef DEBUG_OPT_IOT - mnstr_printf(cntxt->fdout, "#iot stream table %s.%s\n", getModuleId(p), getFunctionId(p)); -#endif - schemas[btop]= getVarConstant(mb, getArg(p,2)).val.sval; - tables[btop]= getVarConstant(mb, getArg(p,3)).val.sval; - for( j =0; j< btop ; j++) - if( strcmp(schemas[j], schemas[btop])==0 && strcmp(tables[j],tables[btop]) ==0) - break; - input[j]= 1; - if( j == btop) - btop++; - } - if( getModuleId(p)== basketRef && getFunctionId(p) == appendRef ){ -#ifdef DEBUG_OPT_IOT - mnstr_printf(cntxt->fdout, "#iot stream table %s.%s\n", getModuleId(p), getFunctionId(p)); -#endif - schemas[btop]= getVarConstant(mb, getArg(p,2)).val.sval; - tables[btop]= getVarConstant(mb, getArg(p,3)).val.sval; - for( j =0; j< btop ; j++) - if( strcmp(schemas[j], schemas[btop])==0 && strcmp(tables[j],tables[btop]) ==0) - break; - - output[j]= 1; - if( j == btop) - btop++; - } - if( getModuleId(p)== basketRef && getFunctionId(p) == updateRef ){ -#ifdef DEBUG_OPT_IOT - mnstr_printf(cntxt->fdout, "#iot stream table %s.%s\n", getModuleId(p), getFunctionId(p)); -#endif - schemas[btop]= getVarConstant(mb, getArg(p,2)).val.sval; - tables[btop]= getVarConstant(mb, getArg(p,3)).val.sval; - for( j =0; j< btop ; j++) - if( strcmp(schemas[j], schemas[btop])==0 && strcmp(tables[j],tables[btop]) ==0) - break; - - output[j]= 1; - if( j == btop) - btop++; - } - if( getModuleId(p)== iotRef && getFunctionId(p) == basketRef){ -#ifdef DEBUG_OPT_IOT - mnstr_printf(cntxt->fdout, "#iot stream table %s.%s\n", getModuleId(p), getFunctionId(p)); -#endif - schemas[btop]= getVarConstant(mb, getArg(p,1)).val.sval; - tables[btop]= getVarConstant(mb, getArg(p,2)).val.sval; - for( j =0; j< btop ; j++) - if( strcmp(schemas[j], schemas[btop])==0 && strcmp(tables[j],tables[btop]) ==0) - break; - if( j == btop) - btop++; - } - if( getModuleId(p)== sqlRef && getFunctionId(p) == appendRef ) - lastmvc = getArg(p,0); - if (!cq && getModuleId(p) == sqlRef && getFunctionId(p) == affectedRowsRef ) - lastmvc = getArg(p,0); - if( getModuleId(p)== iotRef && getFunctionId(p) == tumbleRef){ - lastmvc = getArg(p,1); - } - } - if( btop == MAXBSKT || btop == 0) - return MAL_SUCCEED; - -#ifdef DEBUG_OPT_IOT - mnstr_printf(cntxt->fdout, "#iot optimizer started with %d streams, mvc %d\n", btop,lastmvc); - printFunction(cntxt->fdout, mb, stk, LIST_MAL_DEBUG); -#endif - (void) stk; - - alias = (int *) GDKzalloc(mb->vtop * 2 * sizeof(int)); - if (alias == 0) - return MAL_SUCCEED; - - if (newMalBlkStmt(mb, slimit) < 0) - return MAL_SUCCEED; - - pushInstruction(mb, old[0]); - for (i = 1; i < limit; i++) - if (old[i]) { - p = old[i]; - - if(getModuleId(p) == sqlRef && getFunctionId(p)== transactionRef){ - freeInstruction(p); - continue; - } - if(getModuleId(p) == sqlRef && getFunctionId(p)== mvcRef){ - pushInstruction(mb,p); - lastmvc = getArg(p,0); - // watch out for second transaction in same block - if( mvcseen){ - // unlock the tables - for( j=btop-1; j>= 0; j--){ - r= newStmt(mb,basketRef,unlockRef); - r= pushArgument(mb,r,lastmvc); - r= pushStr(mb,r, schemas[j]); - r= pushStr(mb,r, tables[j]); - lastmvc= getArg(r,0); - } - } - // register and lock all baskets used - for( j=0; j<btop; j++){ - p= newStmt(mb,basketRef,registerRef); - p= pushArgument(mb,p,lastmvc); - p= pushStr(mb,p, schemas[j]); - p= pushStr(mb,p, tables[j]); - p= pushInt(mb,p, output[j]); - alias[lastmvc] = getArg(p,0); - lastmvc = getArg(p,0); - - p= newStmt(mb,basketRef,lockRef); - p= pushArgument(mb,p,lastmvc); - p= pushStr(mb,p, schemas[j]); - p= pushStr(mb,p, tables[j]); - lastmvc = getArg(p,0); - } - mvcseen=1; - continue; - } - // register all baskets used after the mvc had been determined - if (getModuleId(p) == sqlRef && getFunctionId(p) == tidRef ){ - getStreamTableInfo(getVarConstant(mb,getArg(p,2)).val.sval, getVarConstant(mb,getArg(p,3)).val.sval ); -#ifdef DEBUG_OPT_IOT - mnstr_printf(cntxt->fdout, "#iot optimizer found stream %d\n",fnd); -#endif - if( fnd){ - getModuleId(p) = basketRef; - pushInstruction(mb,p); - alias[getArg(p,0)] = -1; - //freeInstruction(p); - continue; - } - } - - if (getModuleId(p) == algebraRef && getFunctionId(p) == projectionRef && alias[getArg(p,1)] < 0){ - alias[getArg(p,0)] = getArg(p,2); - freeInstruction(p); - continue; - } - - if (getModuleId(p) == sqlRef && getFunctionId(p) == affectedRowsRef ){ - if(cq) - freeInstruction(p); - else - pushInstruction(mb,p); - continue; - } - - if( getModuleId(p)== iotRef && getFunctionId(p)==errorRef) - noerror++; - if (p->token == ENDsymbol && btop > 0 && noerror==0) { - // empty all baskets used only when we are optimizing a cq - for(j = 0; j < btop; j++) - if( input[j] && !output[j] ){ - r = newStmt(mb, basketRef, tumbleRef); - r = pushArgument(mb,r, lastmvc); - r = pushStr(mb,r, schemas[j]); - r = pushStr(mb,r, tables[j]); - lastmvc = getArg(r,0); - } - - /* catch any exception left behind */ - r = newAssignment(mb); - j = getArg(r, 0) = newVariable(mb, "SQLexception", 12, TYPE_str); - setVarUDFtype(mb, j); - r->barrier = CATCHsymbol; - - r = newStmt(mb,iotRef, errorRef); - r = pushStr(mb, r, getModuleId(old[0])); - r = pushStr(mb, r, getFunctionId(old[0])); - r = pushArgument(mb, r, j); - - r = newAssignment(mb); - getArg(r, 0) = j; - r->barrier = EXITsymbol; - r = newAssignment(mb); - j = getArg(r, 0) = newVariable(mb, "MALexception",12, TYPE_str); - setVarUDFtype(mb, j); - r->barrier = CATCHsymbol; - - r = newStmt(mb,iotRef, errorRef); - r = pushStr(mb, r, getModuleId(old[0])); - r = pushStr(mb, r, getFunctionId(old[0])); - r = pushArgument(mb, r, j); - - r = newAssignment(mb); - getArg(r, 0) = j; - r->barrier = EXITsymbol; - - /* non-contiguous queries call for releasing the lock on the basket */ - for( j=btop-1; j>= 0; j--){ - r= newStmt(mb,basketRef,unlockRef); - r= pushArgument(mb,r,lastmvc); - r= pushStr(mb,r, schemas[j]); - r= pushStr(mb,r, tables[j]); - lastmvc= getArg(r,0); - } - //p= newStmt(mb,basketRef,commitRef); - //p= pushArgument(mb,p, lastmvc); - //p= pushStr(mb,p, schemas[j]); - //p= pushStr(mb,p, tables[j]); - //lastmvc = getArg(p,0); - break; - } - - for (j = 0; j < p->argc; j++) - if (alias[getArg(p, j)] > 0) - getArg(p, j) = alias[getArg(p, j)]; - - if ( (getModuleId(p) == sqlRef ||getModuleId(p)== basketRef) && getFunctionId(p) == appendRef ){ - getArg(p,1) = lastmvc; - lastmvc = getArg(p,0); - } - if ( (getModuleId(p) == sqlRef ||getModuleId(p)== basketRef) && getFunctionId(p) == updateRef ){ - getArg(p,1) = lastmvc; - lastmvc = getArg(p,0); _______________________________________________ checkin-list mailing list [email protected] https://www.monetdb.org/mailman/listinfo/checkin-list
