Changeset: 8083da7233d7 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8083da7233d7 Modified Files: MonetDB.spec debian/monetdb-client-testing.install gdk/gdk_select.c monetdb5/modules/mal/language.c monetdb5/modules/mal/language.h monetdb5/modules/mal/language.mal monetdb5/optimizer/opt_dataflow.c monetdb5/optimizer/opt_prelude.c monetdb5/optimizer/opt_prelude.h monetdb5/optimizer/opt_wrapper.c Branch: default Log Message:
Merge with Feb2013 branch. diffs (truncated from 431 to 300 lines): diff --git a/MonetDB.spec b/MonetDB.spec --- a/MonetDB.spec +++ b/MonetDB.spec @@ -334,7 +334,6 @@ developer. %{_bindir}/malsample.pl %{_bindir}/sqlsample.php %{_bindir}/sqlsample.pl -%{_bindir}/sqlsample.py %if %{?centos:0}%{!?centos:1} %package geom-MonetDB5 diff --git a/debian/monetdb-client-testing.install b/debian/monetdb-client-testing.install --- a/debian/monetdb-client-testing.install +++ b/debian/monetdb-client-testing.install @@ -11,4 +11,3 @@ debian/tmp/usr/bin/testgetinfo usr/bin debian/tmp/usr/bin/malsample.pl usr/bin debian/tmp/usr/bin/sqlsample.php usr/bin debian/tmp/usr/bin/sqlsample.pl usr/bin -debian/tmp/usr/bin/sqlsample.py usr/bin diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c --- a/gdk/gdk_select.c +++ b/gdk/gdk_select.c @@ -537,6 +537,44 @@ BAT_scanselect(BAT *b, BAT *s, BAT *bn, * - if tl==nil and th!=NULL, no lower bound; * - if th==NULL or tl==th, point (equi) select; * - if th==nil, no upper bound + * + * A complete breakdown of the various arguments follows. Here, v, v1 + * and v2 are values from the appropriate domain, and + * v != nil, v1 != nil, v2 != nil, v1 < v2. + * tl th li hi anti result list of OIDs for values + * ----------------------------------------------------------------- + * nil NULL ignored ignored false x = nil (only way to get nil) + * nil NULL ignored ignored true x != nil + * nil nil ignored ignored false x != nil + * nil v ignored false false x < v + * nil v ignored true false x <= v + * nil v ignored false true x >= v + * nil v ignored true true x > v + * v nil false ignored false x > v + * v nil true ignored false x >= v + * v nil false ignored true x <= v + * v nil true ignored true x < v + * v NULL false ignored false NOTHING + * v NULL true ignored false x == v + * v NULL false ignored true x != nil + * v NULL true ignored true x != v + * v v false false false NOTHING + * v v true false false NOTHING + * v v false true false NOTHING + * v v true true false x == v + * v v false false true x != nil + * v v true false true x != nil + * v v false true true x != nil + * v v true true true x != v + * v1 v2 false false false v1 < x < v2 + * v1 v2 true false false v1 <= x < v2 + * v1 v2 false 1 false v1 < x <= v2 + * v1 v2 true true false v1 <= x <= v2 + * v1 v2 false false true x <= v1 or x >= v2 + * v1 v2 true false true x < v1 or x >= v2 + * v1 v2 false true true x <= v1 or x > v2 + * v1 v2 true true true x < v1 or x > v2 + * v2 v1 ignored ignored ignored NOTHING */ BAT * BATsubselect(BAT *b, BAT *s, const void *tl, const void *th, @@ -640,11 +678,24 @@ BATsubselect(BAT *b, BAT *s, const void lval = 0; hval = 0; ALGODEBUG fprintf(stderr, "#BATsubselect(b=%s#" BUNFMT - ",s=%s,anti=%d): anti-nil\n", + ",s=%s,anti=0): anti-nil\n", BATgetId(b), BATcount(b), - s ? BATgetId(s) : "NULL", anti); - } else { + s ? BATgetId(s) : "NULL"); + } else if (equi) { equi = 0; + if (!(li && hi)) { + /* antiselect for nothing: turn into + * range select for nil-nil range + * (i.e. everything but nil) */ + anti = 0; + lval = 0; + hval = 0; + ALGODEBUG fprintf(stderr, "#BATsubselect(b=%s#" + BUNFMT ",s=%s,anti=0): " + "anti-nothing\n", + BATgetId(b), BATcount(b), + s ? BATgetId(s) : "NULL"); + } } } @@ -812,36 +863,36 @@ BATsubselect(BAT *b, BAT *s, const void assert(s->tsorted); assert(s->tkey); if (BATtdense(s)) { - maximum = MIN( maximum , - MIN( oh , s->tseqbase + BATcount(s)) - - MAX( ol , s->tseqbase ) ); + maximum = MIN(maximum , + MIN(oh, s->tseqbase + BATcount(s)) + - MAX(ol, s->tseqbase)); } else { - maximum = MIN( maximum , - SORTfndfirst(s, &oh) - - SORTfndfirst(s, &ol) ) ; + maximum = MIN(maximum, + SORTfndfirst(s, &oh) + - SORTfndfirst(s, &ol)); } } if (b->tkey) { /* exact result size in special cases */ if (equi) { estimate = 1; - } else - if (!anti && lval && hval) { - if (ATOMstorage(b->ttype) == TYPE_bte) { + } else if (!anti && lval && hval) { + switch (ATOMstorage(b->ttype)) { + case TYPE_bte: estimate = (BUN) (*(bte*) th - *(bte*) tl); - } else - if (ATOMstorage(b->ttype) == TYPE_sht) { + break; + case TYPE_sht: estimate = (BUN) (*(sht*) th - *(sht*) tl); - } else - if (ATOMstorage(b->ttype) == TYPE_int) { + break; + case TYPE_int: estimate = (BUN) (*(int*) th - *(int*) tl); - } else - if (ATOMstorage(b->ttype) == TYPE_lng) { + break; + case TYPE_lng: estimate = (BUN) (*(lng*) th - *(lng*) tl); + break; } - if (estimate != BUN_NONE) { + if (estimate != BUN_NONE) estimate += li + hi - 1; - } } } /* refine upper limit by exact size (if known) */ diff --git a/monetdb5/modules/mal/language.c b/monetdb5/modules/mal/language.c --- a/monetdb5/modules/mal/language.c +++ b/monetdb5/modules/mal/language.c @@ -152,6 +152,16 @@ MALgarbagesink( Client cntxt, MalBlkPtr return MAL_SUCCEED; } +str +MALpass( Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) +{ + (void) cntxt; + (void) mb; + (void) stk; + (void) pci; + return MAL_SUCCEED; +} + str CMDregisterFunction(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) { diff --git a/monetdb5/modules/mal/language.h b/monetdb5/modules/mal/language.h --- a/monetdb5/modules/mal/language.h +++ b/monetdb5/modules/mal/language.h @@ -47,6 +47,7 @@ language_export str MALassertSht(int *re language_export str MALassertInt(int *ret, int *val, str *msg); language_export str MALassertLng(int *ret, lng *val, str *msg); language_export str MALstartDataflow( Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); +language_export str MALpass( Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); language_export str MALgarbagesink( Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); language_export str CMDregisterFunction(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); language_export str CMDsetMemoryTrace(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci); diff --git a/monetdb5/modules/mal/language.mal b/monetdb5/modules/mal/language.mal --- a/monetdb5/modules/mal/language.mal +++ b/monetdb5/modules/mal/language.mal @@ -39,6 +39,10 @@ address MALgarbagesink comment "Variables to be considered together when triggering garbage collection. Used in the dataflow blocks to avoid early release of values."; +pattern pass(v:any_1):any_1 +address MALpass +comment "Cheap instruction to disgard storage while retaining the dataflow dependency"; + pattern register(m:str,f:str,code:str,help:str):void address CMDregisterFunction comment"Compile the code string to MAL and register it as a function."; diff --git a/monetdb5/optimizer/opt_dataflow.c b/monetdb5/optimizer/opt_dataflow.c --- a/monetdb5/optimizer/opt_dataflow.c +++ b/monetdb5/optimizer/opt_dataflow.c @@ -132,34 +132,44 @@ dflowInstruction(InstrPtr p) { return FALSE; } -static InstrPtr -dflowGarbagesink(MalBlkPtr mb, InstrPtr *old, int start, int last, int var, int *usage){ - InstrPtr p, sink; +static int +dflowGarbagesink(MalBlkPtr mb, InstrPtr *old, int start, int last, int var, InstrPtr *sink, int top){ + InstrPtr p, q, r; int j,k; - if ( usage[var] == 0 || isVarConstant(mb, var) ) - return NULL; - sink= newInstruction(mb,ASSIGNsymbol); - getModuleId(sink) = languageRef; - getFunctionId(sink) = sinkRef; - getArg(sink,0)= newTmpVariable(mb,TYPE_void); - sink= pushArgument(mb, sink, var); + + q= newInstruction(NULL,ASSIGNsymbol); + getModuleId(q) = languageRef; + getFunctionId(q) = sinkRef; + getArg(q,0)= newTmpVariable(mb,TYPE_void); + q= pushArgument(mb, q, var); for ( j= start; j< last; j++){ + assert(top <mb->vsize); p = old[j]; if ( p ) for (k = p->retc; k< p->argc; k++) - if ( getArg(p,k)== var) - sink= pushArgument(mb,sink, getArg(p,0)); + if ( getArg(p,k)== var) { + r = newInstruction(NULL,ASSIGNsymbol); + getModuleId(r) = languageRef; + getFunctionId(r) = passRef; + getArg(r,0) = newTmpVariable(mb,getArgType(mb,p,0)); + r= pushArgument(mb,r, getArg(p,0)); + sink[top++] = r; + q= pushArgument(mb,q, getArg(r,0)); + break; + } } - return sink; + assert(top <mb->vsize); + sink[top++] = q; + return top; } int OPTdataflowImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p) { - int i,j,k, cnt, start=1,entries=0, actions=0; + int i,j,k, var, cnt, start=1,entries=0, actions=0; int flowblock= 0, dumbcopy=0; InstrPtr *sink, *old, q; - int limit, slimit, top = 0; + int limit, slimit, size, top = 0; Lifespan span; char *init; int *usage; @@ -187,18 +197,18 @@ OPTdataflowImplementation(Client cntxt, GDKfree(init); return 0; } - sink= (InstrPtr*) GDKzalloc(mb->stop * sizeof(InstrPtr)); - if ( usage == NULL){ + sink= (InstrPtr*) GDKzalloc(size = mb->vsize * sizeof(InstrPtr)); + if ( sink == NULL){ GDKfree(span); GDKfree(init); - GDKfree(sink); + GDKfree(usage); return 0; } limit= mb->stop; slimit= mb->ssize; old = mb->stmt; - if ( newMalBlkStmt(mb, mb->ssize+20) <0 ){ + if ( newMalBlkStmt(mb, mb->ssize+mb->vtop) <0 ){ GDKfree(span); GDKfree(init); GDKfree(usage); @@ -222,6 +232,7 @@ OPTdataflowImplementation(Client cntxt, /* close old flow block */ if (flowblock){ int sf = simpleFlow(old,start,i); + top = 0; if (!sf && entries > 1){ for( j=start ; j<i; j++) if (old[j]) { @@ -234,13 +245,12 @@ OPTdataflowImplementation(Client cntxt, } /* collect variables garbage collected within the block */ for( k=old[j]->retc; k<old[j]->argc; k++) - if( getEndLifespan(span,getArg(old[j],k)) == j) { - sink[top] = dflowGarbagesink(mb,old, start, i, getArg(old[j],k), usage); - top += sink[top] != NULL; - } - else - if( getEndLifespan(span,getArg(old[j],k)) < i) - usage[getArg(old[j],k)]++; + if( getEndLifespan(span, var = getArg(old[j],k)) == j && usage[var]==1 && !isVarConstant(mb, var) ) _______________________________________________ checkin-list mailing list checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list