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

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



Index: group.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/modules/kernel/group.mx,v
retrieving revision 1.93
retrieving revision 1.93.2.1
diff -u -d -r1.93 -r1.93.2.1
--- group.mx    5 Sep 2007 14:16:48 -0000       1.93
+++ group.mx    22 Oct 2007 19:55:59 -0000      1.93.2.1
@@ -646,6 +646,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_histo, BAT *ct_map, BAT *b, BAT 
*bn, map_T *m)
@@ -656,9 +680,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