Changeset: ad615a17fa1e for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ad615a17fa1e Modified Files: monetdb5/extras/crackers/crackers_pq.c monetdb5/extras/rdf/rdf.c monetdb5/mal/mal.c monetdb5/mal/mal_atom.c monetdb5/mal/mal_authorize.c monetdb5/mal/mal_box.c monetdb5/mal/mal_builder.c monetdb5/mal/mal_client.c monetdb5/mal/mal_debugger.c monetdb5/mal/mal_exception.c monetdb5/mal/mal_factory.c monetdb5/mal/mal_function.c monetdb5/mal/mal_import.c monetdb5/mal/mal_instruction.c monetdb5/mal/mal_interpreter.c monetdb5/mal/mal_linker.c monetdb5/mal/mal_module.c monetdb5/mal/mal_namespace.c monetdb5/mal/mal_parser.c monetdb5/mal/mal_profiler.c monetdb5/mal/mal_properties.c monetdb5/mal/mal_readline.c monetdb5/mal/mal_recycle.c monetdb5/mal/mal_resolve.c monetdb5/mal/mal_sabaoth.c monetdb5/mal/mal_scenario.c monetdb5/mal/mal_session.c monetdb5/mal/mal_stack.c monetdb5/mal/mal_type.c monetdb5/mal/mal_utils.c monetdb5/mal/mal_xml.c monetdb5/modules/atoms/blob.c monetdb5/modules/atoms/color.c monetdb5/modules/atoms/colxml.c monetdb5/modules/atoms/identifier.c monetdb5/modules/atoms/inet.c monetdb5/modules/atoms/mtime.c monetdb5/modules/atoms/str.c monetdb5/modules/atoms/streams.c monetdb5/modules/atoms/url.c monetdb5/modules/atoms/xml.c monetdb5/modules/kernel/lock.c monetdb5/modules/kernel/sema.c monetdb5/modules/kernel/unix.c monetdb5/modules/mal/attach.c monetdb5/modules/mal/cbp.c monetdb5/modules/mal/clients.c monetdb5/modules/mal/extensions.c monetdb5/modules/mal/factories.c monetdb5/modules/mal/groupby.c monetdb5/modules/mal/histogram.c monetdb5/modules/mal/inspect.c monetdb5/modules/mal/language.c monetdb5/modules/mal/mal_io.c monetdb5/modules/mal/manual.c monetdb5/modules/mal/mat.c monetdb5/modules/mal/mdb.c monetdb5/modules/mal/mkey.c monetdb5/modules/mal/pcrelib.c monetdb5/modules/mal/profiler.c monetdb5/modules/mal/recycle.c monetdb5/modules/mal/remote.c monetdb5/modules/mal/replication.c monetdb5/modules/mal/sabaoth.c monetdb5/modules/mal/table_sql.c monetdb5/modules/mal/tablet.c monetdb5/modules/mal/tokenizer.c monetdb5/modules/mal/trader.c monetdb5/modules/mal/zorder.c monetdb5/optimizer/opt_accumulators.c monetdb5/optimizer/opt_aliases.c monetdb5/optimizer/opt_cluster.c monetdb5/optimizer/opt_coercion.c monetdb5/optimizer/opt_commonTerms.c monetdb5/optimizer/opt_compression.c monetdb5/optimizer/opt_costModel.c monetdb5/optimizer/opt_crackers.c monetdb5/optimizer/opt_datacell.c monetdb5/optimizer/opt_datacyclotron.c monetdb5/optimizer/opt_dataflow.c monetdb5/optimizer/opt_deadcode.c monetdb5/optimizer/opt_derivepath.c monetdb5/optimizer/opt_dictionary.c monetdb5/optimizer/opt_emptySet.c monetdb5/optimizer/opt_evaluate.c monetdb5/optimizer/opt_factorize.c monetdb5/optimizer/opt_garbagecollector.c monetdb5/optimizer/opt_history.c monetdb5/optimizer/opt_inline.c monetdb5/optimizer/opt_joinpath.c monetdb5/optimizer/opt_macro.c monetdb5/optimizer/opt_mapreduce.c monetdb5/optimizer/opt_mergetable.c monetdb5/optimizer/opt_mitosis.c monetdb5/optimizer/opt_multiplex.c monetdb5/optimizer/opt_octopus.c monetdb5/optimizer/opt_partitions.c monetdb5/optimizer/opt_prejoin.c monetdb5/optimizer/opt_prelude.c monetdb5/optimizer/opt_pushranges.c monetdb5/optimizer/opt_qep.c monetdb5/optimizer/opt_recycler.c monetdb5/optimizer/opt_reduce.c monetdb5/optimizer/opt_remap.c monetdb5/optimizer/opt_remoteQueries.c monetdb5/optimizer/opt_remoteQueries.mx monetdb5/optimizer/opt_reorder.c monetdb5/optimizer/opt_replication.c monetdb5/optimizer/opt_selcrack.c monetdb5/optimizer/opt_singleton.c monetdb5/optimizer/opt_statistics.c monetdb5/optimizer/opt_strengthReduction.c monetdb5/optimizer/opt_support.c monetdb5/optimizer/opt_tarantula.c monetdb5/optimizer/opt_trace.c monetdb5/optimizer/opt_wrapper.c monetdb5/optimizer/optimizer.c monetdb5/optimizer/optimizerWrapper.mx monetdb5/scheduler/run_adder.c monetdb5/scheduler/run_isolate.c monetdb5/scheduler/run_tarantula.c Branch: headless Log Message:
Merge in rename fixes. diffs (truncated from 578 to 300 lines): diff --git a/monetdb5/optimizer/opt_remoteQueries.mx b/monetdb5/optimizer/opt_remoteQueries.mx deleted file mode 100644 --- a/monetdb5/optimizer/opt_remoteQueries.mx +++ /dev/null @@ -1,478 +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://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_remoteQueries -/* Author(s) M.L. Kersten - * Remote Queries - * MAL variables may live at a different site from where they are used. - * In particular, the SQL front-end uses portions of remote - * BATs as replication views. Each time such a view is needed, - * the corresponding BAT is fetched and added to the local cache. - * - * Consider the following snippet produced by a query compiler, - * @verbatim - * mid:= mapi.reconnect("s0_0","localhost",50000,"monetdb","monetdb","mal"); - * b:col[:int] := mapi.bind(mid,"rvar"); - * c:=algebra.select(b,0,12); - * io.print(c); - * d:=algebra.select(b,5,10); - * low:= 5+1; - * e:=algebra.select(d,low,7); - * i:=aggr.count(e); - * io.printf(" count %d\n",i); - * io.print(d); - * @end verbatim - * which uses a BAT @sc{rvar} stored at the remote site @sc{db1}. - * - * There are several options to execute this query. - * The remote BAT can be fetched as soon as the bind operation is executed, - * or a portion can be fetched after a remote select, - * or the output for the user could be retrieved. - * An optimal solution depends on the actual resources - * available at both ends and the time to ship the BAT. - * - * The remote query optimizer - * assumes that the remote site has sufficient - * resources to handle the instructions. - * For each remote query it creates a private connection. - * It is re-used in subsequent calls . - * - * The remote environment is used to execute - * the statements. The objects are retrieved - * just before they are locally needed. - * - * @verbatim - * mid:= mapi.reconnect("s0_0","localhost",50000,"monetdb","monetdb","mal"); - * mapi.rpc(mid,"b:col[:int] :=bbp.bind(\"rvar\");"); - * mapi.rpc(mid,"c:=algebra.select(b,0,12);"); - * c:col[:int]:= mapi.rpc(mid, "io.print(c);"); - * io.print(c); - * mapi.rpc(mid,"d:=algebra.select(b,5,10);"); - * low:= 5+1; - * mapi.put(mid,"low",low); - * mapi.rpc(mid,"e:=algebra.select(d,low,7);"); - * mapi.rpc(mid,"i:=aggr.count(d);"); - * i:= mapi.rpc(mid,"io.print(i);"); - * io.printf(" count %d\n",i); - * io.print(d); - * @end verbatim - * - * To reduce the number of interprocess communications - * this code can be further improved by glueing - * the instructions together when until the first - * result is needed. - * @{ - * Glueing together statements should respect the flow. - * It seems that we can savely concatenate subsequence - * requests. - * @verbatim - * mid:= mapi.reconnect("s0_0","localhost",50000,"monetdb","monetdb","mal"); - * mapi.rpc(mid,"b:col[:int] :=bbp.bind(\"rvar\");"); - * mapi.rpc(mid,"c:=algebra.select(b,0,12);"); - * c:col[:int]:= mapi.rpc(mid, "io.print(c);"); - * io.print(c); - * mapi.rpc(mid,"d:=algebra.select(b,5,10);"); - * low:= 5+1; - * mapi.put(mid,"low",low); - * i:= mapi.rpc(mid,"e:=algebra.select(d,low,7); i:=aggr.count(d); io.print(i);"); - * io.printf(" count %d\n",i); - * io.print(d); - * @end verbatim -*/ - -@mal -pattern optimizer.remoteQueries():str -address OPTwrapper; -pattern optimizer.remoteQueries(mod:str, fcn:str):str -address OPTwrapper -comment "Resolve the multi-table definitions"; -@h -#ifndef _OPT_REMOTE_ -#define _OPT_REMOTE_ -#include "opt_prelude.h" -#include "opt_support.h" - -#define DEBUG_OPT_REMOTEQUERIES DEBUG_OPT_REMOTE - -opt_export int OPTremoteQueriesImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p); - -#define OPTDEBUGremoteQueries if ( optDebug & ((lng)1 <<DEBUG_OPT_REMOTEQUERIES) ) -#endif -@c -#include "monetdb_config.h" -#include "opt_remoteQueries.h" -#include "mal_interpreter.h" /* for showErrors() */ -#include "mal_builder.h" -#include "opt_statistics.h" - -/* The instruction sent is produced with a variation of call2str from the debugger.*/ - -static str -RQcall2str(MalBlkPtr mb, InstrPtr p) -{ - int k,len=1; - str msg; - str s,cv= NULL; - - msg = (str) GDKmalloc(BUFSIZ); - if (msg == NULL) - return NULL; - msg[0]='#'; - msg[1]=0; - if( p->barrier) - strcat(msg, getSymbolName(p->barrier)); - - if( p->retc > 1) strcat(msg,"("); - len= (int) strlen(msg); - for (k = 0; k < p->retc; k++) { - VarPtr v = getVar(mb, getArg(p, k)); - if( isVarFixed(mb, getArg(p,k)) ){ - str tpe = getTypeName(getVarType(mb, getArg(p, k))); - sprintf(msg+len, "%s%s ", v->name, tpe); - GDKfree(tpe); - } else - if (isTmpVar(mb, getArg(p,k))) - sprintf(msg+len, "%c%d", REFMARKER, v->tmpindex); - else - sprintf(msg+len, "%s", v->name); - if (k < p->retc - 1) - strcat(msg,","); - len= (int) strlen(msg); - } - if( p->retc > 1) strcat(msg,")"); - sprintf(msg+len,":= %s.%s(",getModuleId(p),getFunctionId(p)); - s = strchr(msg, '('); - if (s) { - s++; - *s = 0; - len = (int) strlen(msg); - for (k = p->retc; k < p->argc; k++) { - VarPtr v = getVar(mb, getArg(p, k)); - if( isVarConstant(mb, getArg(p,k)) ){ - if( v->type == TYPE_void) { - sprintf(msg+len, "nil"); - } else { - VALformat(&cv, &v->value); - sprintf(msg+len,"%s:%s",cv, ATOMname(v->type)); - GDKfree(cv); - } - - } else if (isTmpVar(mb, getArg(p,k))) - sprintf(msg+len, "%c%d", REFMARKER, v->tmpindex); - else - sprintf(msg+len, "%s", v->name); - if (k < p->argc - 1) - strcat(msg,","); - len= (int) strlen(msg); - } - strcat(msg,");"); - } -/* printf("#RQcall:%s\n",msg);*/ - return msg; -} -/* - * The algorithm follows the common scheme used so far. - * Instructions are taken out one-by-one and copied - * to the new block. - * - * A local cache of connections is established, because - * the statements related to a single remote database - * should be executed in the same stack context. - * A pitfall is to create multiple connections with - * their isolated runtime environment. -*/ -#define lookupServer(A1) \ - /* lookup the server connection */ \ - if( location[getArg(p,0)] == 0){ \ - db = 0; \ - if( isVarConstant(mb,getArg(p,A1)) ) \ - db= getVarConstant(mb, getArg(p,A1))->val.sval; \ - for(k=0; k<dbtop; k++) \ - if( strcmp(db, dbalias[k].dbname)== 0) \ - break; \ - \ - if( k== dbtop){ \ - r= newInstruction(mb,ASSIGNsymbol); \ - getModuleId(r)= mapiRef; \ - getFunctionId(r)= lookupRef; \ - j= getArg(r,0)= newTmpVariable(mb, TYPE_int); \ - r= pushArgument(mb,r, getArg(p,A1)); \ - pushInstruction(mb,r); \ - dbalias[dbtop].dbhdl= j; \ - dbalias[dbtop++].dbname= db; \ - if( dbtop== 127) dbtop--; \ - } else j= dbalias[k].dbhdl; \ - location[getArg(p,0)]= j; \ - } else j= location[getArg(p,0)]; - -#define prepareRemote(A1) \ - r= newInstruction(mb,ASSIGNsymbol); \ - getModuleId(r)= mapiRef; \ - getFunctionId(r)= rpcRef; \ - getArg(r,0)= newTmpVariable(mb, A1); \ - r= pushArgument(mb,r,j); - -#define putRemoteVariables() \ - for(j=p->retc; j<p->argc; j++) \ - if( location[getArg(p,j)] == 0 && !isVarConstant(mb,getArg(p,j)) ){ \ - q= newStmt(mb,mapiRef,putRef); \ - getArg(q,0)= newTmpVariable(mb, TYPE_void); \ - q= pushArgument(mb,q,location[getArg(p,j)]); \ - q= pushStr(mb,q, getRefName(mb,getArg(p,j))); \ - (void) pushArgument(mb,q,getArg(p,j)); \ - } -#define remoteAction \ - s= RQcall2str(mb,p); \ - r= pushStr(mb,r,s+1); \ - GDKfree(s); \ - pushInstruction(mb,r); \ - freeInstruction(p); \ - doit++; - -typedef struct{ - str dbname; - int dbhdl; -} DBalias; - -int -OPTremoteQueriesImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) -{ - InstrPtr p, q, r, *old; - int i, j, cnt, limit, slimit, doit=0; - int remoteSite,collectFirst; - int *location; - DBalias *dbalias; - int dbtop,k; - char buf[BUFSIZ],*s, *db; - ValRecord cst; - cst.vtype= TYPE_int; - cst.val.ival= 0; - - - OPTDEBUGremoteQueries - mnstr_printf(cntxt->fdout, "RemoteQueries optimizer started\n"); - (void) cntxt; - (void) stk; - (void) pci; - - limit = mb->stop; - slimit = mb->ssize; - old = mb->stmt; - - location= (int*) GDKzalloc(mb->vsize * sizeof(int)); - if ( location == NULL) - return 0; - dbalias= (DBalias*) GDKzalloc(128 * sizeof(DBalias)); - if (dbalias == NULL){ - GDKfree(location); - return 0; - } - dbtop= 0; - - if ( newMalBlkStmt(mb, mb->ssize) < 0){ - GDKfree(dbalias); - GDKfree(location); - return 0; - } - - for (i = 0; i < limit; i++) { - p = old[i]; _______________________________________________ Checkin-list mailing list [email protected] http://mail.monetdb.org/mailman/listinfo/checkin-list
