Update of /cvsroot/monetdb/MonetDB5/src/modules/mal
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv4246

Modified Files:
        bpm.mx 
Log Message:
Prepare the BPM to work with different decision procedures.
The cases cs={1,2,3,4}require some documentation to improve
re-use ot the actual partitioning routine.


Index: bpm.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/modules/mal/bpm.mx,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- bpm.mx      7 Jun 2007 09:34:17 -0000       1.85
+++ bpm.mx      8 Jun 2007 19:46:23 -0000       1.86
@@ -473,7 +473,6 @@
 #include "mal.h"
 #include "mal_client.h"
 #include "mal_interpreter.h"
-#include <math.h>
 
 
 /*#define _DEBUG_BPM_ */
@@ -563,6 +562,8 @@
 #include "bpm.h"
 #include "bat5.h"
 #include "algebra.h"
+#include <math.h>
+
 #define KB     1024
 #define Mmin   KB
 @-
@@ -1432,7 +1433,11 @@
        throw(MAL, "bpm.derived","NYI");
 }
 
-void findMedian(ValPtr vp, BAT * b)
[EMAIL PROTECTED]
+Take a sample from a BAT and determine the median value.
+It is the candidate split value.
[EMAIL PROTECTED]
+static void findMedian(ValPtr vp, BAT * b)
 {
        BUN p; 
        int c, tpe;
@@ -1450,8 +1455,49 @@
 }
 
 
-str
-BPMadapt(int *ret, bat *bid, ptr low, ptr hgh, bat *rs )
[EMAIL PROTECTED] Adaptive segmentation
+The adapt() routine breaks up a BAT into multiple pieces.
+Several policies will be implemented and explored.
+The SIZECPOLICY just looks at the absolute
+size of the pieces produced. They may not get too small.
+
+The ORACLEPOLICY implements a random decision based
+on the depth of the segementation sequence and relative sizes.
[EMAIL PROTECTED]
+#define SIZEPOLICY 1
+#define ORACLEPOLICY 2
+
+static int BPMsizePolicy( BAT *b, BAT *bs, int *bid, ptr low, ptr hgh)
+{
+       int cs=0;
+       lng space, space1, space2;
+       int (*cmp) (ptr, ptr);
+       ptr nilptr;
+
+       cmp= BATatoms[b->ttype].atomCmp;
+       nilptr = ATOMnilptr(b->ttype);
+
+       space1 = BATcount(bs)* (BUNsize(b) + sizeof(hash_t)) + sizeof(BATstore);
+
+       if(((*cmp)(low, nilptr)==0) || greater(*bid,tlow,low)) { 
+               cs=1; space2 = space -space1;
+       }
+       else if (((*cmp)(hgh, nilptr)==0) || less(*bid,thgh,hgh)) {
+               cs=2; space2 = space -space1;
+       }
+       else {
+               cs=3; space2 = (space -space1)/2; /* rough estimate- ToDo */
+       }
+       if ((space1 < Mmin) || (space2 < Mmin)) {
+               if (space > 8*Mmin) { 
+                       /* little parts in large segment- split on median*/
+                       cs = 4;}
+       }
+       return cs;
+}
+
+static str
+BPMadaptImpl(int *ret, bat *bid, ptr low, ptr hgh, bat *rs, int policy )
 {
        BAT *b,*bs, *bs1, *bs2;
        Partition ps, p, p2;
@@ -1459,7 +1505,7 @@
        ptr nilptr;
        ValPtr vp;
        int cs;
-       lng space, space1, space2;
+       lng space;
        (void) ret;
 
        BPMopen();
@@ -1471,7 +1517,7 @@
        cmp= BATatoms[b->ttype].atomCmp;
        nilptr = ATOMnilptr(b->ttype);
 
-/* check size */
+/* baseline size, too small BATs are never broken*/
        space = BATcount(b)* (BUNsize(b) + sizeof(hash_t)) + sizeof(BATstore);
        if (space < Mmin) { /* no re-org.*/
                BBPunfix(b->batCacheid);
@@ -1488,25 +1534,12 @@
                return MAL_SUCCEED;
        }
        @:getBATdescriptor(rs,bs,"bpm.adapt");
-       space1 = BATcount(bs)* (BUNsize(b) + sizeof(hash_t)) + sizeof(BATstore);
-
-       if(((*cmp)(low, nilptr)==0) || greater(*bid,tlow,low)) { 
-               cs=1; space2 = space -space1;
-       }
-       else if (((*cmp)(hgh, nilptr)==0) || less(*bid,thgh,hgh)) {
-               cs=2; space2 = space -space1;
-       }
-       else {
-               cs=3; space2 = (space -space1)/2; /* rough estimate- ToDo */
-       }
-       if ((space1 < Mmin) || (space2 < Mmin)) {
-               if (space > 8*Mmin) { /* little parts in large segment- split 
in median*/
-                       cs = 4;}
-               else { /* too little parts in little segment- no re-org.*/
+       if( policy == SIZEPOLICY)
+               cs= BPMsizePolicy(b,bs,bid,low,hgh);
+       if( cs==0){
                        BBPunfix(b->batCacheid);
                        BBPunfix(bs->batCacheid);
                        return MAL_SUCCEED;
-               }
        }
        
 /* re-organize */
@@ -1634,7 +1667,15 @@
        return MAL_SUCCEED;
 }
 
+str BPMadapt(int *ret, bat *bid, ptr low, ptr hgh, bat *rs )
+{
+       return BPMadaptImpl(ret,bid,low,hgh,rs,SIZEPOLICY);
+}
 
+str BPMoracle(int *ret, bat *bid, ptr low, ptr hgh, bat *rs )
+{
+       return BPMadaptImpl(ret,bid,low,hgh,rs,ORACLEPOLICY);
+}
 
 @-
 Takeing out partitions.


-------------------------------------------------------------------------
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