Update of /cvsroot/monetdb/MonetDB4/src/modules/plain
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11545/src/modules/plain

Modified Files:
      Tag: MonetDB_4-20
        xtables.mx 
Log Message:
performance fix in derive: we now do an sample now to make a more educated guess


Index: xtables.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB4/src/modules/plain/xtables.mx,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -d -r1.4 -r1.4.2.1
--- xtables.mx  6 Sep 2007 13:25:22 -0000       1.4
+++ xtables.mx  22 Oct 2007 19:55:13 -0000      1.4.2.1
@@ -700,6 +700,30 @@
                break;
        }
 
[EMAIL PROTECTED]
+#define SAMPLE_SIZE    1024
+hash_t
+derive_mask( BAT *ct_histo, BAT *b)
+{
+       int n = bits(BATcount(ct_histo)), *N = &n;
+
+       if (BATcount(b) > (SAMPLE_SIZE<<3)) {
+               BAT *s = BATsample(b, SAMPLE_SIZE);
+               BAT *u = BATkunique(BATmirror(s)); 
+               size_t uc = BATcount(u);
+
+               BBPunfix(s->batCacheid);
+               BBPunfix(u->batCacheid);
+               if (uc > 0) {
+                       size_t ratio = (((dbl)BATcount(b)/SAMPLE_SIZE) * uc);
+                       if (ratio > 0)
+                               return (1<<bits(*N * ratio)) - 1;
+               }
+       }
+       /* default to */
+       return (1<<*N) - 1;
+}
+
 @= derive
 static BAT *
 [EMAIL PROTECTED]@[EMAIL PROTECTED](BAT* ct_map, BAT *ct_histo, BAT *b, BAT 
*bn, map_T *m)
@@ -710,9 +734,8 @@
        BUN p, q, r, cp = BUNfirst(ct_map) - yy;
        mapentry_t entry, *e;
        BAT *map;
-       int n = bits(BATcount(ct_histo)), *N = &n;
        [EMAIL PROTECTED]
-       declare_mask_CUSTOM
+       hash_t mask = derive_mask(ct_histo, b); 
        int custom_rng = BATcount(ct_histo); /* expected number of groups */
        hash_t custom_MASK = mask;
 


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to