Update of /cvsroot/monetdb/MonetDB5/src/optimizer
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13193/src/optimizer
Modified Files:
opt_costModel.mx opt_crack.mx opt_deadcode.mx opt_emptySet.mx
opt_evaluate.mx opt_garbageCollector.mx opt_inline.mx
opt_joinpath.mx opt_joinselect.mx opt_mergetable.mx
opt_prelude.mx opt_pushranges.mx opt_reduce.mx
opt_singleton.mx opt_support.mx
Log Message:
implemented a new property scheme
Index: opt_pushranges.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_pushranges.mx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- opt_pushranges.mx 17 Aug 2007 13:56:56 -0000 1.10
+++ opt_pushranges.mx 9 Dec 2007 16:21:12 -0000 1.11
@@ -211,13 +211,14 @@
x= x && getConstant(mb,getArg(p,4)).val.cval[0];
x= x && getConstant(mb,getArg(p,5)).val.cval[0];
if( z > 0 || (z==0 && p->argc>4 && !x)) {
- lng zero= 0;
- if( mb->var[getArg(p,0)]->props== NULL)
- mb->var[getArg(p,0)]->props=
newPropertySet();
- setProperty(mb->var[getArg(p,0)]->props,
-
"rows","=",TYPE_lng,&zero);
+ int var = getArg(p, 0);
+ lng zero = 0;
+ ValRecord v, *vp;
+
+ vp = VALset(&v, TYPE_lng, &zero);
+ varSetProp(mb, var, rowsProp, op_eq,
vp);
/* create an empty replacement */
- x= getArgType(mb, p, 1);
+ x = getArgType(mb, p, 1);
p->argc=1;
getModuleId(p)= batRef;
getFunctionId(p)= newRef;
Index: opt_deadcode.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_deadcode.mx,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- opt_deadcode.mx 6 Nov 2007 18:08:46 -0000 1.27
+++ opt_deadcode.mx 9 Dec 2007 16:21:10 -0000 1.28
@@ -93,8 +93,9 @@
(void) pci;
(void) stk; /* to fool compilers */
- if( fndArgProperty(mb,mb->stmt[0],0,putName("inline",6)) )
+ if (varGetProp(mb, getArg(mb->stmt[0], 0), inlineProp) != NULL)
return 0;
+
setLifespan(mb);
#ifdef DEBUG_OPT_DEAD
stream_printf(GDKout,"ENTERING DEAD CODE ELIMINATION\n");
Index: opt_joinselect.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_joinselect.mx,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- opt_joinselect.mx 31 Oct 2007 10:45:41 -0000 1.13
+++ opt_joinselect.mx 9 Dec 2007 16:21:12 -0000 1.14
@@ -83,50 +83,51 @@
if (start == -1)
start = i;
- if(fndArgProperty(mb,p,1,"stable")){
+ if (varGetProp(mb, getArg(p,1), stableProp) != NULL){
*(int*)ps = i;
ps += xx;
}
- if(fndArgProperty(mb,p,1,"insertions")){
+ if (varGetProp(mb, getArg(p,1), insertionsProp) !=
NULL){
*(int*)pi = i;
pi += xx;
}
- if(fndArgProperty(mb,p,1,"updates")){
+ if (varGetProp(mb, getArg(p,1), updatesProp) != NULL){
*(int*)pu = i;
pu += xx;
}
}
if (match2(p, batRef, reverseRef)){
- if(fndArgProperty(mb,p,1,"deletes")){
- *(int*)pd = i;
- pd += xx;
+ if (varGetProp(mb, getArg(p,1), deletesProp) != NULL){
+ *(int*)pd = i;
+ pd += xx;
}
}
if (match2(p, sqlRef, bindRef)){
switch( getVar(mb,getArg(p,4))->value.val.ival ){
case 0:
- setArgProperty(mb,p,0,"stable","=", TYPE_int,
&i);
+ varSetProp(mb, getArg(p,0), stableProp, 0,
NULL);
break;
case 1:
- setArgProperty(mb,p,0,"insertions","=",
TYPE_int, &i);
+ varSetProp(mb, getArg(p,0), insertionsProp, 0,
NULL);
break;
case 3:
- setArgProperty(mb,p,0,"updates","=", TYPE_int,
&i);
+ varSetProp(mb, getArg(p,0), updatesProp, 0,
NULL);
+ break;
}
}
if (match2(p, sqlRef, binddbatRef))
- setArgProperty(mb,p,0,"deletes","=", TYPE_int, &i);
+ varSetProp(mb, getArg(p,0), deletesProp, 0, NULL);
if (match2(p, batRef, setWriteModeRef)){
- if(fndArgProperty(mb,p,1,"stable"))
-
setArgProperty(mb,p,0,"stable","=", TYPE_int, &i);
- if(fndArgProperty(mb,p,1,"insertions"))
-
setArgProperty(mb,p,0,"insertions","=", TYPE_int, &i);
- if(fndArgProperty(mb,p,1,"updates"))
-
setArgProperty(mb,p,0,"updates","=", TYPE_int, &i);
- }
+ if (varGetProp(mb, getArg(p,1), stableProp) != NULL)
+ varSetProp(mb, getArg(p,0), stableProp, 0,
NULL);
+ if (varGetProp(mb, getArg(p,1), insertionsProp) != NULL)
+ varSetProp(mb, getArg(p,0), insertionsProp, 0,
NULL);
+ if (varGetProp(mb, getArg(p,1), updatesProp) != NULL)
+ varSetProp(mb, getArg(p,0), updatesProp, 0,
NULL);
+ }
if (match2(p, algebraRef, markTRef)){
pivot = i;
Index: opt_singleton.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_singleton.mx,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- opt_singleton.mx 31 Oct 2007 10:45:41 -0000 1.15
+++ opt_singleton.mx 9 Dec 2007 16:21:15 -0000 1.16
@@ -343,9 +343,8 @@
for (i = 1; i < mb->stop; i++) {
p = getInstrPtr(mb, i);
for (j = 0; j < p->retc; j++)
- if (fndProperty(getVarProperties(mb, getArg(p, j)),
"singleton")) {
+ if (varGetProp(mb, getArg(p, j), singletonProp) != NULL)
vars[cnt++] = getArg(p, j);
- }
}
return STevaluate(mb, cnt, vars);
}
Index: opt_emptySet.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_emptySet.mx,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- opt_emptySet.mx 31 Oct 2007 08:27:38 -0000 1.41
+++ opt_emptySet.mx 9 Dec 2007 16:21:10 -0000 1.42
@@ -135,8 +135,8 @@
InstrPtr *old = mb->stmt, *constraints;
/* get query property */
- runonce= fndArgProperty(mb,old[0],0,putName("runonce",7)) != NULL;
- if( fndArgProperty(mb,old[0],0,putName("inline",6)) )
+ runonce = (varGetProp(mb, getArg(old[0], 0), runonceProp) != NULL);
+ if (varGetProp(mb, getArg(old[0], 0), inlineProp) != NULL)
return 0;
newMalBlkStmt(mb, mb->ssize); /* a new statement stack */
@@ -291,8 +291,6 @@
{
char *empty;
int i;
- lng *rows;
- PropertySet ps;
empty = (char *) alloca(mb->vsize * sizeof(char));
memset(empty,0,mb->vsize);
@@ -303,8 +301,9 @@
printFunction(GDKout, mb, LIST_MAL_ALL);
#endif
for (i = 0; i < mb->vtop; i++) {
- ps = getVarProperties(mb, i);
- if ( (rows= (lng*) getPropertyValue(ps, "rows")) && *rows ==
0) {
+ VarPtr rowsp;
+ if ((rowsp = varGetProp(mb, i, rowsProp)) != NULL
+ && rowsp->value.val.lval == 0) {
#ifdef DEBUG_OPT_EMPTYSET
stream_printf(GDKout, "START emptyset optimizer %d", i);
#endif
Index: opt_costModel.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_costModel.mx,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- opt_costModel.mx 16 Jul 2007 10:52:33 -0000 1.32
+++ opt_costModel.mx 9 Dec 2007 16:21:09 -0000 1.33
@@ -84,26 +84,36 @@
#include "mal_config.h"
#include "opt_costModel.h"
-static void
-fixPropertySet(MalBlkPtr mb, int dst)
+static lng
+getVarRows(MalBlkPtr mb, int v)
{
- if (mb->var[dst]->props == 0)
- mb->var[dst]->props = newPropertySet();
+ VarPtr p = varGetProp(mb, v, rowsProp);
+
+ if (!p)
+ return -1;
+ if (p->value.vtype == TYPE_lng)
+ return p->value.val.lval;
+ if (p->value.vtype == TYPE_int)
+ return p->value.val.ival;
+ if (p->value.vtype == TYPE_sht)
+ return p->value.val.shval;
+ if (p->value.vtype == TYPE_bte)
+ return p->value.val.btval;
+ return -1;
}
-#define getVarRows(Y) (lng*)getPropertyTypedValue(mb->var[Y]->props,"rows",
TYPE_lng)
-#define getVarSize(Y) (int*)getPropertyTypedValue(mb->var[Y]->props,"size",
TYPE_int)
@-
The cost formula are repetative
@= newRows
{
- c1 = getVarRows(getArg(p,@1));
- c2 = getVarRows(getArg(p,@2));
- if (c1 == NULL || c2 == NULL)
+ ValRecord v;
+
+ c1 = getVarRows(mb, getArg(p,@1));
+ c2 = getVarRows(mb, getArg(p,@2));
+ if (c1 == -1 || c2 == -1)
continue;
k = (@3);
- fixPropertySet(mb, getArg(p,@4));
- setProperty(getProps(mb,getArg(p,@4)),"rows","=", TYPE_lng, &k);
+ varSetProp(mb, getArg(p,@4), rowsProp, op_eq,
VALset(&v,TYPE_lng,&k));
#ifdef DEBUG_OPT_COSTMODEL
stream_printf(GDKout,"COST of @1 @2 into @4: " LLFMT "\n",k);
printInstruction(GDKout,mb,p,0);
@@ -112,23 +122,26 @@
@= newRows1
@:newRows(@1,@1,@2,0)@
@= newRows2
- @:newRows(@1,@2,@3,0)@
+ @:newRows(1,2,@1,0)@
@-
SQL specific back propagation of table size may be needed to avoid
the empty-set optimizer to through away a BAT we need.
@c
static void
OPTbackpropagate(MalBlkPtr mb, int i, int idx){
- lng *rows;
+ lng rows;
InstrPtr p;
+ rows = getVarRows(mb, idx);
+ if (rows == -1)
+ return;
for( ; i > 0; i--){
- p= getInstrPtr(mb,i);
- if( getFunctionId(p) == setWriteModeRef){
- rows = getVarRows(getArg(p,1));
- if (rows == NULL || *rows)
- continue;
- *rows = *getVarRows(idx);
+ p = getInstrPtr(mb,i);
+ if (getFunctionId(p) == setWriteModeRef){
+ if (getVarRows(mb, getArg(p,1)) == 0) {
+ ValRecord v, *vp = VALset(&v, TYPE_lng, &rows);
+ varSetProp(mb, getArg(p,1), rowsProp, op_eq,
vp);
+ }
}
}
}
@@ -146,7 +159,7 @@
OPTcostModelImplementation(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
int i;
- lng k,*c1, *c2;
+ lng k, c1, c2;
InstrPtr p;
str sortrevRef= putName("sortReverse",11);
str sortrevTailRef= putName("sortReverseTail",15);
@@ -154,7 +167,7 @@
(void) stk;
(void) pci;
- if( fndArgProperty(mb,mb->stmt[0],0,putName("inline",6)) )
+ if (varGetProp(mb, getArg(mb->stmt[0], 0), inlineProp) != NULL)
return 0;
for (i = 0; i < mb->stop; i++) {
@@ -168,38 +181,37 @@
getFunctionId(p) == sortrevRef ||
getFunctionId(p) == sortrevTailRef ||
getFunctionId(p) == projectRef ){
- @:newRows1(1, *c1)@
- } else
- if( getFunctionId(p) == unionRef ||
+ @:newRows1(1, c1)@
+ } else if(getFunctionId(p) == unionRef ||
getFunctionId(p) == kunionRef) {
- @:newRows2(1,2, *c1+*c2,1)@
+ @:newRows2(c1+c2)@
} else if (getFunctionId(p)== kdifferenceRef) {
- @:newRows2(1, 2, *c1==0? 0: *c2==0? *c1: *c1 -
*c2 < 0 ? 1 : *c1 - *c2+1)@
+ @:newRows2(c1==0?0:c2==0?c1: c1 - c2 < 0 ? 1 :
c1 - c2+1)@
} else if (getFunctionId(p) == joinRef ) {
/* assume 1-1 joins */
- @:newRows2(1, 2, *c1 < *c2 ? *c1 : *c2)@
+ @:newRows2(c1 < c2 ? c1 : c2)@
} else if (getFunctionId(p) == semijoinRef ) {
/* assume 1-1 semijoins */
- @:newRows2(1, 2, *c1 < *c2 ? *c1 : *c2)@
+ @:newRows2(c1 < c2? c1 : c2)@
} else if (getFunctionId(p) == selectRef ||
getFunctionId(p) == uselectRef) {
- @:newRows1(1, *c1 > 100 ? *c1 / 2 +1: *c1)@
+ @:newRows1(1, c1 > 100 ? c1 / 2 +1: c1)@
} else if (getFunctionId(p) == crossRef) {
- @:newRows2(1, 2, (log((double) *c1) +
log((double) *c2) > log(INT_MAX) ? INT_MAX : *c1 * *c2 +1))@
+ @:newRows2((log((double) c1) + log((double) c2)
> log(INT_MAX) ? INT_MAX : c1 * c2 +1))@
} else if (getFunctionId(p) == tuniqueRef ) {
- @:newRows1(1, *c1 < 50 ? *c1 : *c1 / 10+1)@
+ @:newRows1(1, c1 < 50 ? c1 : c1 / 10+1)@
}
} else if (getModuleId(p) == batcalcRef) {
if( isaBatType(getArgType(mb,p,1)) )
- @:newRows1(1, *c1)@
+ @:newRows1(1, c1)@
else
- @:newRows1(2, *c2)@
+ @:newRows1(2, c2)@
} else if (getModuleId(p) == batRef) {
if (getFunctionId(p) == reverseRef ||
getFunctionId(p) == setWriteModeRef ||
getFunctionId(p) == hashRef ||
getFunctionId(p) == mirrorRef) {
- @:newRows1(1, *c1)@
+ @:newRows1(1, c1)@
} else if (getFunctionId(p) == appendRef ||
getFunctionId(p) == insertRef ){
@-
@@ -217,50 +229,51 @@
@c
if( isaBatType(getArgType(mb,p,2)) ){
/* insert BAT */
- @:newRows(1,2, *c1 + *c2+1,1)@
+ @:newRows(1,2, c1 + c2+1,1)@
OPTbackpropagate(mb,i,getArg(p,1));
} else {
/* insert scalars */
- @:newRows(1,1, *c1 +1,1)@
+ @:newRows(1,1, c1 +1,1)@
OPTbackpropagate(mb,i,getArg(p,1));
}
} else if (getFunctionId(p) == deleteRef){
if( isaBatType(getArgType(mb,p,2)) ){
/* delete BAT */
- @:newRows(1,2, (*c1 - *c2 ==0? 1:
*c1-*c2),1)@
+ @:newRows(1,2, (c1 - c2 ==0? 1:
c1-c2),1)@
OPTbackpropagate(mb,i,getArg(p,1));
} else {
/* insert scalars */
- @:newRows(1,1, *c1==1?1: *c1-1,1)@
+ @:newRows(1,1, c1==1?1: c1-1,1)@
OPTbackpropagate(mb,i,getArg(p,1));
}
OPTbackpropagate(mb,i,getArg(p,1));
- } else if ( getFunctionId(p) == insertRef){
- @:newRows1(1, *c1 + 1)@ /* faked */
+ } else if (getFunctionId(p) == insertRef){
+ @:newRows1(1, c1 + 1)@ /* faked */
OPTbackpropagate(mb,i,getArg(p,1));
}
} else if (getModuleId(p)==groupRef) {
if (getFunctionId(p) ==newRef) {
- @:newRows1(1, *c1 / 10+1)@
+ @:newRows1(1, c1 / 10+1)@
} else {
- @:newRows1(1, *c1)@
+ @:newRows1(1, c1)@
}
} else if (getModuleId(p)== aggrRef) {
if (getFunctionId(p) == sumRef ||
getFunctionId(p) == minRef ||
getFunctionId(p) == maxRef ||
getFunctionId(p) == avgRef) {
- @:newRows1(1, *c1?*c1:*c1+1)@
+ @:newRows1(1, c1?c1:c1+1)@
} else if (getFunctionId(p) == countRef){
@:newRows1(1, 1)@
}
} else if( p->token == ASSIGNsymbol && p->argc== 2){
- /* copy the rows property */
- c1 = getVarRows(getArg(p,1));
- if( c1 != NULL){
- fixPropertySet(mb, getArg(p,0));
-
setProperty(getProps(mb,getArg(p,0)),"rows","=", TYPE_lng, c1);
- }
+ /* copy the rows property */
+ c1 = getVarRows(mb, getArg(p,1));
+ if (c1 != -1) {
+ ValRecord v;
+
+ varSetProp(mb, getArg(p,0), rowsProp, op_eq,
VALset(&v, TYPE_lng, &c1));
+ }
}
}
return 1;
Index: opt_mergetable.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_mergetable.mx,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- opt_mergetable.mx 14 Nov 2007 10:18:27 -0000 1.24
+++ opt_mergetable.mx 9 Dec 2007 16:21:12 -0000 1.25
@@ -15,7 +15,7 @@
@' All Rights Reserved.
@f opt_mergetable
[EMAIL PROTECTED] M. Kersten
[EMAIL PROTECTED] M. Kersten, N. Nes
@- Merge Tables
A merge association table (MAT) descriptor defines an ordered collection
of type compatible BATs, whose union represents a single (virtual) BAT.
@@ -144,67 +144,205 @@
#include "opt_mergetable.h"
#include "bpm.h"
[...1172 lines suppressed...]
- r= MATpackAll(mb, NULL, m, mat, mvar, &mtop);
- actions++;
- break;
+ for (k = p->retc; k<p->argc; k++) {
+ if((m=isMATalias(getArg(p,k), mat, mtop)) >= 0){
+ r= MATpackAll(mb, NULL, mat, m, &mtop);
+ actions++;
+ break;
+ }
}
-#ifdef DEBUG_OPT_MERGETABLE
- stream_printf(GDKout,"last option\n");
- printInstruction(GDKout,mb,p,0);
-#endif
pushInstruction(mb,p);
}
- GDKfree(hr);
GDKfree(old);
@-
As a final optimization, we could remove the mal.new definitions,
Index: opt_inline.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_inline.mx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- opt_inline.mx 16 Jul 2007 10:52:42 -0000 1.4
+++ opt_inline.mx 9 Dec 2007 16:21:11 -0000 1.5
@@ -51,30 +51,25 @@
int i;
InstrPtr q,sig;
int actions = 0;
- PropertySet ps;
(void) p;
for (i = 1; i < mb->stop; i++) {
q = getInstrPtr(mb, i);
if( q->blk ){
- sig= getInstrPtr(q->blk,0);
- ps= getVar(q->blk, getArg(sig,0))->props;
- if( sig->token == FUNCTIONsymbol &&
- isPropertyDefined(ps,"inline") ){
+ sig = getInstrPtr(q->blk,0);
+ if (sig->token == FUNCTIONsymbol &&
+ varGetProp(q->blk, getArg(sig, 0), inlineProp) !=
NULL) {
(void) inlineMALblock(mb,i,q->blk);
actions++;
#ifdef DEBUG_OPT_INLINE
printFunction(GDKout, mb, LIST_MAL_ALL);
#endif
- } else {
- ps= getVar(mb, getArg(q,0))->props;
- if( isPropertyDefined(ps,"inline") ){
- inlineMALblock(mb,i,q->blk);
- actions++;
+ } else if (varGetProp(mb, getArg(q,0), inlineProp) !=
NULL) {
+ inlineMALblock(mb,i,q->blk);
+ actions++;
#ifdef DEBUG_OPT_INLINE
- printFunction(GDKout, mb, LIST_MAL_ALL);
+ printFunction(GDKout, mb, LIST_MAL_ALL);
#endif
- }
}
}
}
Index: opt_prelude.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_prelude.mx,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- opt_prelude.mx 14 Nov 2007 12:24:28 -0000 1.31
+++ opt_prelude.mx 9 Dec 2007 16:21:12 -0000 1.32
@@ -57,7 +57,6 @@
opt_export str groupRef;
opt_export str groupbyRef;
opt_export str hashRef;
-opt_export str hrangeRef;
opt_export str identityRef;
opt_export str inplaceRef;
opt_export str insertRef;
@@ -122,15 +121,32 @@
opt_export str tuniqueRef;
opt_export str unionRef;
opt_export str unpackRef;
-opt_export str unsafeRef;
opt_export str updateRef;
opt_export str uselectRef;
+opt_export int canBeCrackedProp; /* binary */
+opt_export int inlineProp; /* binary */
+opt_export int keepProp; /* binary */
+opt_export int notnilProp; /* binary */
+opt_export int rowsProp; /* long */
+opt_export int runonceProp; /* binary */
+opt_export int singletonProp; /* binary */
+opt_export int unsafeProp; /* binary */
+
+opt_export int stableProp; /* binary */
+opt_export int insertionsProp; /* binary */
+opt_export int updatesProp; /* binary */
+opt_export int deletesProp; /* binary */
+
+opt_export int hlbProp; /* any (head lower bound) */
+opt_export int hubProp; /* any (head upper bound) */
+opt_export int tlbProp; /* any (tail lower bound) */
+opt_export int tubProp; /* any (tail upper bound) */
+
opt_export void optimizerInit(void);
#endif
@c
#include "mal_config.h"
-#include "opt_support.h"
#include "opt_prelude.h"
str aggrRef;
@@ -168,7 +184,6 @@
str groupRef;
str groupbyRef;
str hashRef;
-str hrangeRef;
str identityRef;
str inplaceRef;
str insertRef;
@@ -233,10 +248,28 @@
str tuniqueRef;
str unionRef;
str unpackRef;
-str unsafeRef;
str updateRef;
str uselectRef;
+int canBeCrackedProp;
+int inlineProp;
+int keepProp;
+int notnilProp;
+int rowsProp;
+int runonceProp;
+int singletonProp;
+int unsafeProp;
+
+int stableProp;
+int insertionsProp;
+int updatesProp;
+int deletesProp;
+
+int hlbProp;
+int hubProp;
+int tlbProp;
+int tubProp;
+
void optimizerInit(){
if(batRef == NULL){
aggrRef = putName("aggr",4);
@@ -274,7 +307,6 @@
groupRef = putName("group",5);
groupbyRef = putName("groupby",7);
hashRef = putName("hash",4);
- hrangeRef = putName("hrange",6);
identityRef = putName("identity",8);
inplaceRef = putName("inplace",7);
insertRef = putName("insert",6);
@@ -338,8 +370,26 @@
tuniqueRef = putName("tunique",7);
unionRef= putName("union",5);
unpackRef = putName("unpack",6);
- unsafeRef = putName("unsafe",6);
updateRef = putName("update",6);
uselectRef = putName("uselect",7);
+
+ canBeCrackedProp = PropertyIndex("canBeCracked");
+ inlineProp = PropertyIndex("inline");
+ keepProp = PropertyIndex("keep");
+ notnilProp = PropertyIndex("notnil");
+ rowsProp = PropertyIndex("rows");
+ runonceProp = PropertyIndex("runonce");
+ singletonProp = PropertyIndex("singleton");
+ unsafeProp = PropertyIndex("unsafe");
+
+ stableProp = PropertyIndex("stableProp");
+ insertionsProp = PropertyIndex("insertionsProp");
+ updatesProp = PropertyIndex("updatesProp");
+ deletesProp = PropertyIndex("deletesProp");
+
+ hlbProp = PropertyIndex("hlb");
+ hubProp = PropertyIndex("hub");
+ tlbProp = PropertyIndex("tlb");
+ tubProp = PropertyIndex("tub");
}
}
Index: opt_joinpath.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_joinpath.mx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- opt_joinpath.mx 6 Nov 2007 18:08:46 -0000 1.12
+++ opt_joinpath.mx 9 Dec 2007 16:21:11 -0000 1.13
@@ -71,7 +71,7 @@
InstrPtr q,r;
(void) stk;
- if( fndArgProperty(mb,mb->stmt[0],0,putName("inline",6)) )
+ if (varGetProp(mb, getArg(mb->stmt[0], 0), inlineProp) != NULL)
return 0;
pc= (int*) alloca(sizeof(int)* mb->vtop); /* to find last assignment */
Index: opt_garbageCollector.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_garbageCollector.mx,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- opt_garbageCollector.mx 31 Oct 2007 10:36:24 -0000 1.28
+++ opt_garbageCollector.mx 9 Dec 2007 16:21:10 -0000 1.29
@@ -158,11 +158,9 @@
can be marked with the proper 'keep'.
@c
static int
-OPTkeepVariable(MalBlkPtr mb, InstrPtr p, int idx){
- static char *keep=0;
- if( keep == 0)
- keep= putName("keep",4);
- return isPropertyDefined( getProps(mb, getArg(p,idx)),keep);
+OPTkeepVariable(MalBlkPtr mb, InstrPtr p, int idx)
+{
+ return (varGetProp(mb, getArg(p, idx), keepProp) != NULL);
}
@c
static int
@@ -176,7 +174,7 @@
(void) pci;
(void) stk; /* to fool compilers */
- if( fndArgProperty(mb,mb->stmt[0],0,putName("inline",6)) )
+ if (varGetProp(mb, getArg(mb->stmt[0], 0), inlineProp) != NULL)
return 0;
setLifespan(mb);
Index: opt_support.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_support.mx,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- opt_support.mx 14 Nov 2007 10:18:27 -0000 1.50
+++ opt_support.mx 9 Dec 2007 16:21:15 -0000 1.51
@@ -493,6 +493,7 @@
#include "mal_function.h"
#include "mal_scenario.h"
#include "mal_builder.h"
+#include "mal_properties.h"
/* #define DEBUG_OPT_OPTIMIZER show partial result */
@@ -829,7 +830,7 @@
p= getInstrPtr(q->blk,0);
if( p->retc== 0)
return TRUE;
- return isPropertyDefined( getVar(q->blk,getArg(p,0))->props, unsafeRef);
+ return (varGetProp( q->blk, getArg(p,0), unsafeProp ) != NULL);
/* check also arguments for 'unsafe' property */
}
Index: opt_evaluate.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_evaluate.mx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- opt_evaluate.mx 6 Nov 2007 18:08:46 -0000 1.10
+++ opt_evaluate.mx 9 Dec 2007 16:21:10 -0000 1.11
@@ -91,7 +91,7 @@
(void) stk;
(void) pci;
- if( fndArgProperty(mb,mb->stmt[0],0,putName("inline",6)) )
+ if (varGetProp(mb, getArg(mb->stmt[0], 0), inlineProp) != NULL)
return 0;
#ifdef DEBUG_OPT_CX
@@ -108,7 +108,7 @@
for (k=i= first ; i < limit; i++) {
p = getInstrPtr(mb,i);
j = OPTallConstant(mb,p);
- if(j && nxt == first) nxt=i;
+ if (j && nxt == first) nxt=i;
#ifdef DEBUG_OPT_CX
stream_printf(GDKout,"Constants:%d\n",j);
stream_printf(GDKout,"retc %d var
%s\n",p->retc,getVarName(mb,getArg(p,0)));
@@ -141,14 +141,20 @@
GDKfree(msg);
mb->stmt[k++]=p;
}
- } else mb->stmt[k++]=p;
+ } else {
+ mb->stmt[k++]=p;
+ }
+ /* make sure we don't have instructions twice */
+ if (k <= i)
+ mb->stmt[i] = NULL;
}
- if( k != mb->stop){
- mb->stop= k;
+ if( k != mb->stop) {
+ mb->stop = k;
setLifespan(mb); /* the lastUpdate property
changes */
- } else
+ } else {
mb->stop= k;
- first= nxt;
+ }
+ first = nxt;
} while( again );
clearStack(env); /* garbage collect */
freeStack(env);
Index: opt_reduce.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_reduce.mx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- opt_reduce.mx 16 Jul 2007 10:52:57 -0000 1.14
+++ opt_reduce.mx 9 Dec 2007 16:21:15 -0000 1.15
@@ -61,31 +61,39 @@
void MRconstant(MalBlkPtr mb){
int i,j;
int *cst,*alias,top=0;
- InstrPtr p;
cst= (int*) alloca(mb->vtop *sizeof(int));
alias= (int*) alloca(mb->vtop *sizeof(int));
for(i = 0; i< mb->vtop; i++)
- if( isConstant(mb,i) ){
- alias[i]= i;
- for(j=0; j<top; j++)
- if( getVarType(mb,i) == getVarType(mb,cst[j]) &&
- ATOMcmp(getVarType(mb,i),
- VALget(&getVar(mb,i)->value),
- VALget(&getVar(mb,cst[j])->value)) == 0){
- alias[i]= cst[j];
+ if (isConstant(mb,i)){
+ alias[i] = i;
+ for(j=0; j<top; j++) {
+ if (getVarType(mb,i) == getVarType(mb,cst[j]) &&
+ ATOMcmp(getVarType(mb,i),
+ VALget(&getVar(mb,i)->value),
+ VALget(&getVar(mb,cst[j])->value)) == 0) {
+ alias[i] = cst[j];
break;
}
- cst[top++]= i;
+ }
+ cst[top++] = i;
}
for( i=0; i< mb->stop; i++){
- p= getInstrPtr(mb,i);
+ InstrPtr p = getInstrPtr(mb,i);
+
for(j=p->retc; j < p->argc; j++)
- if( isConstant(mb, getArg(p,j)) )
- getArg(p,j) = alias[getArg(p,j)];
+ if (isConstant(mb, getArg(p,j)))
+ getArg(p,j) = alias[getArg(p,j)];
+ }
+ for( i=0; i< mb->ptop; i++){
+ MalProp *p= mb->prps+i;
+
+ if (p->var)
+ p->var = alias[p->var];
}
}
+
static int
OPTreduceImplementation(MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
{
@@ -108,7 +116,11 @@
q= getInstrPtr(mb,i);
for(j=0; j<q->argc; j++)
- used[getArg(q,j)]= 1;
+ used[getArg(q,j)] = 1;
+ }
+ for (i=0; i<mb->ptop; i++) {
+ if (mb->prps[i].var)
+ used[mb->prps[i].var] = 1;
}
/* build the alias table */
for (i = 0; i < mb->vtop; i++) {
@@ -141,6 +153,12 @@
for (j = 0; j < q->argc; j++)
getArg(q, j) = vars[getArg(q, j)];
}
+ for( i=0; i< mb->ptop; i++){
+ MalProp *p= mb->prps+i;
+
+ if (p->var)
+ p->var = vars[p->var];
+ }
}
#ifdef DEBUG_OPT_REDUCE
stream_printf(GDKout, "After reduction \n");
Index: opt_crack.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_crack.mx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- opt_crack.mx 16 Jul 2007 10:52:34 -0000 1.7
+++ opt_crack.mx 9 Dec 2007 16:21:09 -0000 1.8
@@ -81,21 +81,22 @@
if (getModuleId(p)== sqlRef &&
mb->var[getArg(p,4)]->value.val.ival != 0 )
continue;
- setArgProperty(mb,p,0,"canBeCracked","=", TYPE_int, &i);
+ varSetProp(mb, getArg(p, 0), canBeCrackedProp, 0, NULL);
actions++;
}
if (match2(p, batRef, setWriteModeRef)){ /* propagete the
canBeCracked property */
- if(fndArgProperty(mb,p,1,"canBeCracked")){
- setArgProperty(mb,p,0,"canBeCracked","=",
TYPE_int, &i);
- actions++;
+ if (varGetProp(mb, getArg(p, 1), canBeCrackedProp) !=
NULL){
+ varSetProp(mb, getArg(p, 0), canBeCrackedProp,
0, NULL);
+ actions++;
}
}
if (match2(p, algebraRef, selectRef) ||
- match2(p, algebraRef, uselectRef)){
- if(fndArgProperty(mb,p,1,"canBeCracked"))
-
setModuleId(p,putName("crackers",8));
- actions++;
+ match2(p, algebraRef, uselectRef)){
+ if (varGetProp(mb, getArg(p,1), canBeCrackedProp) !=
NULL){
+ setModuleId(p,putName("crackers",8));
+ actions++;
+ }
}
if (p == pci)
removeInstruction(mb, p);
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins