Update of /cvsroot/monetdb/MonetDB5/src/optimizer
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12961/optimizer

Modified Files:
        opt_emptySet.mx opt_evaluate.mx opt_partitions.mx 
        opt_pushranges.mx opt_remap.mx opt_remoteQueries.mx 
        opt_support.mx optimizer.mx 
Log Message:
The primary change is to remap >(bat,cst) into <(bat,cst)
in opt_remap. Took the opportunity to rename a macro


Index: opt_pushranges.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_pushranges.mx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- opt_pushranges.mx   18 May 2007 20:11:15 -0000      1.6
+++ opt_pushranges.mx   1 Jun 2007 06:48:28 -0000       1.7
@@ -157,8 +157,8 @@
                        if( range[x].lcst && isConstant(mb,y) ){
                                /* merge lowerbound */
                                if( ATOMcmp( getVarType(mb,y), 
-                                               VALptr( 
&getVarConstant(mb,range[x].lcst)), 
-                                               VALptr( &getVarConstant(mb,y)) 
) > 0){
+                                               VALptr( 
&getConstant(mb,range[x].lcst)), 
+                                               VALptr( &getConstant(mb,y)) ) > 
0){
                                        getArg(p,2)= range[x].lcst;
                                        z= range[x].srcvar;
                                        if( getArg(p,1) == x && 
@@ -170,10 +170,10 @@
                                y= getArg(p,3);
                                /* merge higherbound */
                                if( ATOMcmp( getVarType(mb,y), 
-                                               VALptr( 
&getVarConstant(mb,range[x].hcst)), 
-                                               VALptr( &getVarConstant(mb,y)) 
) < 0 ||
+                                               VALptr( 
&getConstant(mb,range[x].hcst)), 
+                                               VALptr( &getConstant(mb,y)) ) < 
0 ||
                                        ATOMcmp( getVarType(mb,y),
-                                               VALptr( &getVarConstant(mb,y)),
+                                               VALptr( &getConstant(mb,y)),
                                                 ATOMnilptr(getVarType(mb,y)) ) 
== 0){
                                        getArg(p,3)= range[x].hcst;
                                        z= range[x].srcvar;
@@ -207,13 +207,13 @@
                        if( isConstant(mb, x)  &&
                                isConstant(mb, y)  ){
                                z =ATOMcmp( getVarType(mb,y),
-                        VALptr( &getVarConstant(mb,x)),
-                        VALptr( &getVarConstant(mb,y)));
+                        VALptr( &getConstant(mb,x)),
+                        VALptr( &getConstant(mb,y)));
                                x=  p->argc > 4;
                                x= x && isConstant(mb,getArg(p,4));
                                x= x && isConstant(mb,getArg(p,5));
-                               x= x && 
getVarConstant(mb,getArg(p,4)).val.cval[0];
-                               x= x && 
getVarConstant(mb,getArg(p,5)).val.cval[0];
+                               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)

Index: opt_remoteQueries.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_remoteQueries.mx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- opt_remoteQueries.mx        7 Jan 2007 14:13:43 -0000       1.9
+++ opt_remoteQueries.mx        1 Jun 2007 06:48:29 -0000       1.10
@@ -193,7 +193,7 @@
        if( location[getArg(p,0)] == 0){
                db = 0;
                if( isConstant(mb,getArg(p,@1)) )
-                       db= getVarConstant(mb, getArg(p,@1)).val.sval;
+                       db= getConstant(mb, getArg(p,@1)).val.sval;
                for(k=0; k<dbtop; k++)
                        if( strcmp(db, dbalias[k].dbname)== 0)
                                break;

Index: optimizer.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/optimizer.mx,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- optimizer.mx        18 Apr 2007 14:09:11 -0000      1.69
+++ optimizer.mx        1 Jun 2007 06:48:29 -0000       1.70
@@ -236,8 +236,8 @@
        str nme, fcn,msg=MAL_SUCCEED;
 
        (void)stk;
-       nme= getVarConstant(mb, getArg(p,1)).val.sval;
-       fcn= getVarConstant(mb, getArg(p,2)).val.sval;
+       nme= getConstant(mb, getArg(p,1)).val.sval;
+       fcn= getConstant(mb, getArg(p,2)).val.sval;
 #ifdef DEBUG_OPT_MACRO
        printf("@1optimizer: %s.%s\n",nme,fcn);
 #endif
@@ -272,7 +272,7 @@
 
        (void) stk; 
        removeInstruction(mb,p);
-       fcn= getVarConstant(mb, getArg(p,1)).val.sval;
+       fcn= getConstant(mb, getArg(p,1)).val.sval;
        s= findModule(MCgetClient()->nspace, putName(fcn,strlen(fcn)));
 #ifdef DEBUG_OPT_MACRO
        printf("@1optimizer: %s\n",fcn);

Index: opt_emptySet.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_emptySet.mx,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- opt_emptySet.mx     18 May 2007 20:11:15 -0000      1.36
+++ opt_emptySet.mx     1 Jun 2007 06:48:28 -0000       1.37
@@ -175,10 +175,10 @@
                        if( f == bindRef && runonce == FALSE) {
                                for( j=ctop-1; j>=0; j--){
                                        q= constraints[j];
-                                       if( 
strcmp(getVarConstant(mb,getArg(q,1)).val.sval, 
getVarConstant(mb,getArg(p,1)).val.sval)==0 &&
-                                           
strcmp(getVarConstant(mb,getArg(q,2)).val.sval, 
getVarConstant(mb,getArg(p,2)).val.sval)==0 &&
-                                           
getVarConstant(mb,getArg(p,4)).val.ival<=2 && /* no updates etc */
-                                           
getVarConstant(mb,getArg(q,4)).val.ival == 
getVarConstant(mb,getArg(p,4)).val.ival
+                                       if( 
strcmp(getConstant(mb,getArg(q,1)).val.sval, 
getConstant(mb,getArg(p,1)).val.sval)==0 &&
+                                           
strcmp(getConstant(mb,getArg(q,2)).val.sval, 
getConstant(mb,getArg(p,2)).val.sval)==0 &&
+                                           
getConstant(mb,getArg(p,4)).val.ival<=2 && /* no updates etc */
+                                           
getConstant(mb,getArg(q,4)).val.ival == getConstant(mb,getArg(p,4)).val.ival
                                        ) 
                                                /* don't generate the assertion 
*/
                                                goto ignoreConstraint;

Index: opt_remap.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_remap.mx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- opt_remap.mx        18 Apr 2007 11:58:10 -0000      1.6
+++ opt_remap.mx        1 Jun 2007 06:48:29 -0000       1.7
@@ -115,6 +115,51 @@
        return 1;
 }
 
[EMAIL PROTECTED]
+The comparison multiplex operations with a constant head may be supported
+by reverse of the operation.
[EMAIL PROTECTED]
+static struct{
+       char *src, *dst;
+       int len;
+}OperatorMap[]={
+{"<", ">",1},
+{">", "<",1},
+{">=", "<=",2},
+{"<=", ">=",2},
+{"==", "==",2},
+{"!=", "!=",2},
+{0,0,0}};
+
+static int
+OPTremapSwitched(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, Module scope){
+       char *fcn;
+       int r,i;
+       (void) stk;
+       (void) scope;
+
+       if( getModuleId(pci)!= malRef &&
+           getFunctionId(pci) != multiplexRef &&
+           !isConstant(mb,getArg(pci,1)) &&
+           !isConstant(mb,getArg(pci,2)) &&
+           !isConstant(mb,getArg(pci,4))) 
+                       return 0;
+       fcn = VALget(&getVar(mb, getArg(pci, 2))->value);
+       for(i=0;OperatorMap[i].src;i++)
+       if( strcmp(fcn,OperatorMap[i].src)==0){
+               /* found a candidate for a switch */
+               getConstant(mb, getArg(pci, 2)).val.sval= 
putName(OperatorMap[i].dst,OperatorMap[i].len);
+               getConstant(mb, getArg(pci, 2)).len= strlen(fcn);
+               r= getArg(pci,3); getArg(pci,3)=getArg(pci,4);getArg(pci,4)=r;
+               r=OPTremapDirect(mb, stk, pci, scope);
+               if( r) return 1;
+               /* restore the state */
+               r= getArg(pci,3); getArg(pci,3)=getArg(pci,4);getArg(pci,4)=r;
+               getConstant(mb, getArg(pci, 2)).val.sval= fcn;
+               getConstant(mb, getArg(pci, 2)).len= strlen(fcn);
+       }
+       return 0;
+}
 static int
 OPTremapImplementation(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
@@ -133,7 +178,8 @@
                p = old[i];
                if ( getModuleId(p) == malRef && 
                        getFunctionId(p) == multiplexRef) {
-                       if(OPTremapDirect(mb, stk, p, scope)){
+                       if(     OPTremapDirect(mb, stk, p, scope) ||
+                               OPTremapSwitched(mb, stk, p, scope)){
                                freeInstruction(p); 
                                doit++;
                        } else{

Index: opt_partitions.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_partitions.mx,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- opt_partitions.mx   20 May 2007 07:51:29 -0000      1.19
+++ opt_partitions.mx   1 Jun 2007 06:48:28 -0000       1.20
@@ -249,9 +249,9 @@
                        alias[getArg(p,0)]= getArg(q,0);
                        bpm[getArg(p,0)] = 1;
                        snprintf(name,1024,"%s_%s_%s",
-                               getVarConstant(mb, getArg(p,1)).val.sval,
-                               getVarConstant(mb, getArg(p,2)).val.sval,
-                               getVarConstant(mb, getArg(p,3)).val.sval );
+                               getConstant(mb, getArg(p,1)).val.sval,
+                               getConstant(mb, getArg(p,2)).val.sval,
+                               getConstant(mb, getArg(p,3)).val.sval );
                        pushStr(mb, q,name);
                        continue;
                }

Index: opt_support.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_support.mx,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- opt_support.mx      17 May 2007 19:17:32 -0000      1.40
+++ opt_support.mx      1 Jun 2007 06:48:29 -0000       1.41
@@ -693,8 +693,8 @@
                if( q->argv[k]!= p->argv[k]){
                        if( isConstant(mb,getArg(p,k)) && 
isConstant(mb,getArg(q,k)) ) {
                                        ValPtr w,u;
-                                       w= &getVarConstant(mb,getArg(p,k));
-                                       u= &getVarConstant(mb,getArg(q,k));
+                                       w= &getConstant(mb,getArg(p,k));
+                                       u= &getConstant(mb,getArg(q,k));
 
                                        if( ATOMcmp(w->vtype, VALptr(w), 
VALptr(u)) == 0)
                                                continue;

Index: opt_evaluate.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_evaluate.mx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- opt_evaluate.mx     2 May 2007 21:21:44 -0000       1.5
+++ opt_evaluate.mx     1 Jun 2007 06:48:28 -0000       1.6
@@ -130,7 +130,7 @@
 @c
                                        isConstant(mb,getArg(p,0))= TRUE;
                                        setFixed(mb,getArg(p,0));
-                                       getVarConstant(mb,getArg(p,0)) = 
env->stk[getArg(p,0)];
+                                       getConstant(mb,getArg(p,0)) = 
env->stk[getArg(p,0)];
                                        env->stk[getArg(p,0)].vtype= TYPE_int; 
/* no garbage */
                                        freeInstruction(p);
 #ifdef DEBUG_OPT_CX


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to