Changeset: a5564bbe8960 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a5564bbe8960
Modified Files:
        monetdb5/mal/mal_type.h
        monetdb5/modules/mal/mosaic.c
        monetdb5/modules/mal/mosaic.mal
        monetdb5/optimizer/opt_mosaic.c
        sql/test/mosaic/Tests/compression.sql
Branch: mosaic
Log Message:

Fixes to the mosaic optimizer code.


diffs (171 lines):

diff --git a/monetdb5/mal/mal_type.h b/monetdb5/mal/mal_type.h
--- a/monetdb5/mal/mal_type.h
+++ b/monetdb5/mal/mal_type.h
@@ -29,7 +29,7 @@
 
 #define newBatType(H,T)  (1<<16 | (((H & 0377) <<8) | (T & 0377) ))
 #define getHeadType(X)  ((X>>8) & 0377 )
-//#define getTailType(X)  ((X) & 0377 )
+#define getTailType(X)  ((X) & 0377 )
 #define isaBatType(X)   ((1<<16) & (X) && (X)!= TYPE_any)
 #define setAnyHeadIndex(X,I) X |= ((I & 017)<<22);
 //#define setAnyTailIndex(X,I) X |= ((I & 017)<<18);
diff --git a/monetdb5/modules/mal/mosaic.c b/monetdb5/modules/mal/mosaic.c
--- a/monetdb5/modules/mal/mosaic.c
+++ b/monetdb5/modules/mal/mosaic.c
@@ -49,14 +49,14 @@ static void
 MOSdumpTask(Client cntxt,MOStask task)
 {
        int i;
-       flt perc = task->size/100.0;
+       dbl perc = task->size/100.0;
 
        mnstr_printf(cntxt->fdout,"# ");
        mnstr_printf(cntxt->fdout,"clk " LLFMT"\tsizes "LLFMT"\t"LLFMT 
"\t%3.0f%%\t%10.2fx\t", 
                task->timer,task->size,task->xsize, task->xsize/perc, 
task->xsize ==0 ? 0:(flt)task->size/task->xsize);
        for ( i=0; i < MOSAIC_METHODS; i++)
        if( task->blks[i])
-               mnstr_printf(cntxt->fdout, "%s\t"LLFMT "\t"LLFMT "\t" , 
filtername[i], task->blks[i], task->elms[i]);
+               mnstr_printf(cntxt->fdout, "%s\t"LLFMT "\t"LLFMT " " LLFMT"\t" 
, filtername[i], task->blks[i], task->elms[i], task->elms[i]/task->blks[i]);
 }
 
 // dump a compressed BAT
@@ -171,7 +171,7 @@ MOScompressInternal(Client cntxt, int *r
        lng percentage=0, perc;
        int filter[MOSAIC_METHODS];
        
-       if( properties)
+       if( properties && !strstr(properties,"compress"))
                for( i = 0; i< MOSAIC_METHODS; i++)
                        filter[i]= strstr(properties,filtername[i]) != 0;
        else
@@ -872,7 +872,7 @@ str MOSleftfetchjoin(Client cntxt, MalBl
        task->cl = ol;
        task->n = cnt;
        if( cnt)
-               first = *ol;
+               first = ol? *ol:o;
 
        first = MOSfindChunk(cntxt,task,first);
 
diff --git a/monetdb5/modules/mal/mosaic.mal b/monetdb5/modules/mal/mosaic.mal
--- a/monetdb5/modules/mal/mosaic.mal
+++ b/monetdb5/modules/mal/mosaic.mal
@@ -36,6 +36,9 @@ comment "Dump the compressed structure";
 pattern subselect(b:bat[:oid,:bte], low:bte, high:bte, li:bit, hi:bit, 
anti:bit) :bat[:oid,:oid]
 address MOSsubselect;
 
+pattern subselect(b:bat[:oid,:bit], low:bit, high:bit, li:bit, hi:bit, 
anti:bit) :bat[:oid,:oid]
+address MOSsubselect;
+
 pattern subselect(b:bat[:oid,:sht], low:sht, high:sht, li:bit, hi:bit, 
anti:bit) :bat[:oid,:oid]
 address MOSsubselect;
 
@@ -69,6 +72,9 @@ comment "Overloaded selection routine";
 pattern subselect(b:bat[:oid,:bte], cand:bat[:oid,:oid], low:bte, high:bte, 
li:bit, hi:bit, anti:bit) :bat[:oid,:oid]
 address MOSsubselect;
 
+pattern subselect(b:bat[:oid,:bit], cand:bat[:oid,:oid], low:bit, high:bit, 
li:bit, hi:bit, anti:bit) :bat[:oid,:oid]
+address MOSsubselect;
+
 pattern subselect(b:bat[:oid,:sht], cand:bat[:oid,:oid], low:sht, high:sht, 
li:bit, hi:bit, anti:bit) :bat[:oid,:oid]
 address MOSsubselect;
 
@@ -102,6 +108,9 @@ comment "Overloaded selection routine";
 pattern thetasubselect(b:bat[:oid,:bte], low:bte, oper:str) :bat[:oid,:oid]
 address MOSthetasubselect;
 
+pattern thetasubselect(b:bat[:oid,:bit], low:bit, oper:str) :bat[:oid,:oid]
+address MOSthetasubselect;
+
 pattern thetasubselect(b:bat[:oid,:sht], low:sht, oper:str) :bat[:oid,:oid]
 address MOSthetasubselect;
 
@@ -135,6 +144,9 @@ comment "Overloaded selection routine";
 pattern thetasubselect(b:bat[:oid,:bte], c:bat[:oid,:oid], low:bte, oper:str) 
:bat[:oid,:oid]
 address MOSthetasubselect;
 
+pattern thetasubselect(b:bat[:oid,:bit], c:bat[:oid,:oid], low:bit, oper:str) 
:bat[:oid,:oid]
+address MOSthetasubselect;
+
 pattern thetasubselect(b:bat[:oid,:sht], c:bat[:oid,:oid], low:sht, oper:str) 
:bat[:oid,:oid]
 address MOSthetasubselect;
 
@@ -168,6 +180,9 @@ comment "Overloaded selection routine";
 pattern leftfetchjoin(b:bat[:oid,:oid], cand:bat[:oid,:bte]) :bat[:oid,:bte]
 address MOSleftfetchjoin;
 
+pattern leftfetchjoin(b:bat[:oid,:oid], cand:bat[:oid,:bit]) :bat[:oid,:bit]
+address MOSleftfetchjoin;
+
 pattern leftfetchjoin(b:bat[:oid,:oid], cand:bat[:oid,:sht]) :bat[:oid,:sht]
 address MOSleftfetchjoin;
 
diff --git a/monetdb5/optimizer/opt_mosaic.c b/monetdb5/optimizer/opt_mosaic.c
--- a/monetdb5/optimizer/opt_mosaic.c
+++ b/monetdb5/optimizer/opt_mosaic.c
@@ -31,8 +31,9 @@
 
 static int OPTmosaicType(MalBlkPtr mb, InstrPtr pci, int idx)
 {      int type;
-       switch(type = getArgType(mb,pci,idx)){
+       switch(type = getTailType( getArgType(mb,pci,idx))){
        case TYPE_bte:
+       case TYPE_bit:
        case TYPE_sht:
        case TYPE_int:
        case TYPE_lng:
@@ -72,7 +73,7 @@ OPTmosaicImplementation(Client cntxt, Ma
        (void) stk;
 
        // pre-scan to identify all potentially compressed columns
-    for( i=1; i < mb->stop; i++){
+    for( i=1; i < limit; i++){
         p = old[i];
         if ( getModuleId(p) == sqlRef && getFunctionId(p) == bindRef && 
getVarConstant(mb,getArg(p,5)).val.ival == 0 && OPTmosaicType(mb,p,0)){
                                check[getArg(p,0)] = 1;
@@ -80,7 +81,7 @@ OPTmosaicImplementation(Client cntxt, Ma
         if ( getModuleId(p) == sqlRef && getFunctionId(p) == bindRef && 
getVarConstant(mb,getArg(p,5)).val.ival != 0){
                        // locate the corresponding base column and turn it off
                        for( k= i-1; k>0; k--){
-                               q = getInstrPtr(mb,k);
+                               q = old[k];
                                if ( getArg(q,2) == getArg(p,2) && getArg(q,3) 
== getArg(p,3) && getArg(q,4) == getArg(p,4))
                                        check[getArg(q,0)] = 0;
                        }
@@ -94,6 +95,7 @@ OPTmosaicImplementation(Client cntxt, Ma
         if ( getModuleId(p) == algebraRef && getFunctionId(p) == joinRef && 
(check[getArg(p,2)] || check[getArg(p,1)]))
                 /* ok */;
                else
+               // mark all that needs decompression
                for(j= p->retc; j<p->argc; j++)
                if( check[getArg(p,j)] )
                        check[getArg(p,j)] = -1;
@@ -112,13 +114,13 @@ OPTmosaicImplementation(Client cntxt, Ma
                        p = q;
                } else
                // preferrably use compressed version
-        if ( getModuleId(p) == algebraRef && (getFunctionId(p) == subselectRef 
|| getFunctionId(p) == thetasubselectRef) && check[getArg(p,1)] > 0)
+        if ( getModuleId(p) == algebraRef && (getFunctionId(p) == subselectRef 
|| getFunctionId(p) == thetasubselectRef) && check[getArg(p,1)] != 0)
                 setModuleId(p, mosaicRef);
                else
-        if ( getModuleId(p) == algebraRef && getFunctionId(p) == 
leftfetchjoinRef && check[getArg(p,2)] > 0)
+        if ( getModuleId(p) == algebraRef && getFunctionId(p) == 
leftfetchjoinRef && check[getArg(p,2)] != 0)
                 setModuleId(p, mosaicRef);
                 else
-        if ( getModuleId(p) == algebraRef && getFunctionId(p) == joinRef && 
(check[getArg(p,2)] || check[getArg(p,1)] > 0))
+        if ( getModuleId(p) == algebraRef && getFunctionId(p) == joinRef && 
(check[getArg(p,2)] || check[getArg(p,1)] != 0))
                 setModuleId(p, mosaicRef);
                pushInstruction(mb,p);
     }
diff --git a/sql/test/mosaic/Tests/compression.sql 
b/sql/test/mosaic/Tests/compression.sql
--- a/sql/test/mosaic/Tests/compression.sql
+++ b/sql/test/mosaic/Tests/compression.sql
@@ -92,7 +92,6 @@ alter table tmp3 set read only;
 
 explain select * from tmp3;
 select * from tmp3;
---explain select sum(i) from tmp3 where i <5;
 
 alter table tmp3 alter column i set storage 'none';
 alter table tmp3 alter column b set storage 'none';
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to