Changeset: d41e1b744c79 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d41e1b744c79
Modified Files:
        monetdb5/optimizer/opt_costModel.c
        monetdb5/optimizer/opt_mitosis.c
Branch: default
Log Message:

better compilation/code fix than changeset 458c274a87ee: use correct types 
instead of excessive casting;

rowcnt is of type BUN, hence we use type BUN instead of type wrd.

For more information about correct and portable use of types, see also
https://www.monetdb.org/wiki/MonetDB_type_system


diffs (86 lines):

diff --git a/monetdb5/optimizer/opt_costModel.c 
b/monetdb5/optimizer/opt_costModel.c
--- a/monetdb5/optimizer/opt_costModel.c
+++ b/monetdb5/optimizer/opt_costModel.c
@@ -15,9 +15,12 @@
 #define newRows(W,X,Y,Z) {\
                c1 = getRowCnt(mb, getArg(p,W));\
                c2 = getRowCnt(mb, getArg(p,X));\
-               if (c1 == -1 || c2 == -1) \
+               /* just to ensure that rowcnt was/is never set to -1 */\
+               assert(c1 != (BUN) -1);\
+               assert(c2 != (BUN) -1);\
+               if (c1 == BUN_NONE || c2 == BUN_NONE) \
                        continue;\
-               setRowCnt(mb, getArg(p,Z), (BUN)(Y));\
+               setRowCnt(mb, getArg(p,Z), (Y));\
 }
 /*
  * The cost will be used in many places to make decisions.
@@ -33,7 +36,7 @@ int
 OPTcostModelImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci)
 {
        int i;
-       wrd c1, c2;
+       BUN c1, c2;
        InstrPtr p;
 
        (void) cntxt;
@@ -131,8 +134,10 @@ OPTcostModelImplementation(Client cntxt,
                } else if( p->token == ASSIGNsymbol && p->argc== 2){
                        /* copy the rows property */
                        c1 = getRowCnt(mb, getArg(p,1));
-                       if (c1 != -1)
-                               setRowCnt(mb, getArg(p,0), (BUN) c1);
+                       /* just to ensure that rowcnt was/is never set to -1 */\
+                       assert(c1 != (BUN) -1);\
+                       if (c1 != BUN_NONE)
+                               setRowCnt(mb, getArg(p,0), c1);
                }
        }
        return 1;
diff --git a/monetdb5/optimizer/opt_mitosis.c b/monetdb5/optimizer/opt_mitosis.c
--- a/monetdb5/optimizer/opt_mitosis.c
+++ b/monetdb5/optimizer/opt_mitosis.c
@@ -61,7 +61,7 @@ OPTmitosisImplementation(Client cntxt, M
 {
        int i, j, limit, slimit, estimate = 0, pieces = 1, mito_parts = 0, 
mito_size = 0, row_size = 0, mt = -1;
        str schema = 0, table = 0;
-       wrd r = 0, rowcnt = 0;    /* table should be sizeable to consider 
parallel execution*/
+       BUN r = 0, rowcnt = 0;    /* table should be sizeable to consider 
parallel execution*/
        InstrPtr q, *old, target = 0;
        size_t argsize = 6 * sizeof(lng);
        /*     per op:   6 = (2+1)*2   <=  2 args + 1 res, each with head & 
tail */
@@ -136,7 +136,7 @@ OPTmitosisImplementation(Client cntxt, M
         * Take into account the number of client connections, 
         * because all user together are responsible for resource contentions
         */
-       r = (wrd) (monet_memory / argsize);
+       r = monet_memory / argsize;
        /* if data exceeds memory size,
         * i.e., (rowcnt*argsize > monet_memory),
         * i.e., (rowcnt > monet_memory/argsize = r) */
@@ -151,13 +151,13 @@ OPTmitosisImplementation(Client cntxt, M
        } else if (rowcnt > MINPARTCNT) {
        /* exploit parallelism, but ensure minimal partition size to
         * limit overhead */
-               pieces = (int) MIN((rowcnt / MINPARTCNT), (wrd) threads);
+               pieces = (int) MIN(rowcnt / MINPARTCNT, (BUN) threads);
        }
        /* when testing, always aim for full parallelism, but avoid
         * empty pieces */
        FORCEMITODEBUG
        if (pieces < threads)
-               pieces = (int) MIN((wrd) threads, rowcnt);
+               pieces = (int) MIN((BUN) threads, rowcnt);
        /* prevent plan explosion */
        if (pieces > MAXSLICES)
                pieces = MAXSLICES;
@@ -173,7 +173,7 @@ OPTmitosisImplementation(Client cntxt, M
 
        OPTDEBUGmitosis
        mnstr_printf(cntxt->fdout, "#opt_mitosis: target is %s.%s "
-                                                          " with " SSZFMT " 
rows of size %d into " SSZFMT 
+                                                          " with " BUNFMT " 
rows of size %d into " BUNFMT
                                                                " rows/piece %d 
threads %d pieces"
                                                                " fixed parts 
%d fixed size %d\n",
                                 getVarConstant(mb, getArg(target, 2)).val.sval,
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to