Changeset: b92e6d5af624 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b92e6d5af624
Modified Files:
        monetdb5/modules/mal/cluster.c
Branch: default
Log Message:

Merge with Oct2014 branch.


diffs (truncated from 2495 to 300 lines):

diff --git a/monetdb5/modules/mal/cluster.c b/monetdb5/modules/mal/cluster.c
--- a/monetdb5/modules/mal/cluster.c
+++ b/monetdb5/modules/mal/cluster.c
@@ -64,161 +64,35 @@
 #include <mal_exception.h>
 #include "algebra.h"
 
-static void
-CLUSTER_key_bte( BAT *map, BAT *b)
-{
-       bte *bt, *be;
-       oid *o;
-
-       assert(BUNfirst(map) == 0);
-       assert(BUNfirst(b) == 0);
-       o = (oid*)Tloc(map, 0);
-       bt = (bte*)Tloc(b, 0);
-       be = bt + BATcount(b);
-       for ( ; bt < be; bt++){
-               BUN h = hash_bte(b->T->hash,bt);
-               *o++= h;
-       }
+#define CLUSTERKEY(TYPE)                                               \
+static void                                                                    
        \
+CLUSTER_key_##TYPE( BAT *map, BAT *b)                  \
+{                                                                              
                \
+       TYPE *bt, *be;                                                          
\
+       oid *o;                                                                 
        \
+                                                                               
                \
+       assert(BUNfirst(map) == 0);                                     \
+       assert(BUNfirst(b) == 0);                                       \
+       o = (oid*)Tloc(map, 0);                                         \
+       bt = (TYPE*)Tloc(b, 0);                                         \
+       be = bt + BATcount(b);                                          \
+       for ( ; bt < be; bt++){                                         \
+               BUN h = hash_##TYPE(b->T->hash,bt);             \
+               *o++= h;                                                        
        \
+       }                                                                       
                \
 }
 
-static void
-CLUSTER_key_sht( BAT *map, BAT *b)
-{
-       sht *bt, *be;
-       oid *o;
-
-       assert(BUNfirst(map) == 0);
-       assert(BUNfirst(b) == 0);
-       o = (oid*)Tloc(map, 0);
-       bt = (sht*)Tloc(b, 0);
-       be = bt + BATcount(b);
-       for ( ; bt < be; bt++){
-               BUN h = hash_sht(b->T->hash,bt);
-               *o++= h;
-       }
-}
-
-static void
-CLUSTER_key_oid( BAT *map, BAT *b)
-{
-       oid *bt, *be;
-       oid *o;
-
-       assert(BUNfirst(map) == 0);
-       assert(BUNfirst(b) == 0);
-       o = (oid*)Tloc(map, 0);
-       bt = (oid*)Tloc(b, 0);
-       be = bt + BATcount(b);
-       for ( ; bt < be; bt++){
-               BUN h = hash_oid(b->T->hash,bt);
-               *o++= h;
-       }
-}
-
-static void
-CLUSTER_key_wrd( BAT *map, BAT *b)
-{
-       wrd *bt, *be;
-       oid *o;
-
-       assert(BUNfirst(map) == 0);
-       assert(BUNfirst(b) == 0);
-       o = (oid*)Tloc(map, 0);
-       bt = (wrd*)Tloc(b, 0);
-       be = bt + BATcount(b);
-       for ( ; bt < be; bt++){
-               BUN h = hash_wrd(b->T->hash,bt);
-               *o++= h;
-       }
-}
-
-static void
-CLUSTER_key_int( BAT *map, BAT *b)
-{
-       int *bt, *be;
-       oid *o;
-
-       assert(BUNfirst(map) == 0);
-       assert(BUNfirst(b) == 0);
-       o = (oid*)Tloc(map, 0);
-       bt = (int*)Tloc(b, 0);
-       be = bt + BATcount(b);
-       for ( ; bt < be; bt++){
-               BUN h = hash_int(b->T->hash,bt);
-               *o++= h;
-       }
-}
-
-static void
-CLUSTER_key_lng( BAT *map, BAT *b)
-{
-       lng *bt, *be;
-       oid *o;
-
-       assert(BUNfirst(map) == 0);
-       assert(BUNfirst(b) == 0);
-       o = (oid*)Tloc(map, 0);
-       bt = (lng*)Tloc(b, 0);
-       be = bt + BATcount(b);
-       for ( ; bt < be; bt++){
-               BUN h = hash_lng(b->T->hash,bt);
-               *o++= h;
-       }
-}
-
+CLUSTERKEY(bte)
+CLUSTERKEY(sht)
+CLUSTERKEY(int)
+CLUSTERKEY(wrd)
+CLUSTERKEY(lng)
 #ifdef HAVE_HGE
-static void
-CLUSTER_key_hge( BAT *map, BAT *b)
-{
-       hge *bt, *be;
-       oid *o;
-
-       assert(BUNfirst(map) == 0);
-       assert(BUNfirst(b) == 0);
-       o = (oid*)Tloc(map, 0);
-       bt = (hge*)Tloc(b, 0);
-       be = bt + BATcount(b);
-       for ( ; bt < be; bt++){
-               BUN h = hash_hge(b->T->hash,bt);
-               *o++= h;
-       }
-}
+CLUSTERKEY(hge)
 #endif
-
-static void
-CLUSTER_key_flt( BAT *map, BAT *b)
-{
-       flt *bt, *be;
-       oid *o;
-
-       assert(BUNfirst(map) == 0);
-       assert(BUNfirst(b) == 0);
-       o = (oid*)Tloc(map, 0);
-       bt = (flt*)Tloc(b, 0);
-       be = bt + BATcount(b);
-       for ( ; bt < be; bt++){
-               BUN h = hash_flt(b->T->hash,bt);
-               *o++= h;
-       }
-}
-
-static void
-CLUSTER_key_dbl( BAT *map, BAT *b)
-{
-       dbl *bt, *be;
-       oid *o;
-
-       assert(BUNfirst(map) == 0);
-       assert(BUNfirst(b) == 0);
-       o = (oid*)Tloc(map, 0);
-       bt = (dbl*)Tloc(b, 0);
-       be = bt + BATcount(b);
-       for ( ; bt < be; bt++){
-               BUN h = hash_dbl(b->T->hash,bt);
-               *o++= h;
-       }
-}
-
+CLUSTERKEY(oid)
+CLUSTERKEY(flt)
+CLUSTERKEY(dbl)
 
 static void
 CLUSTER_key_str( BAT *map, BAT *b)
@@ -265,12 +139,12 @@ CLUSTER_key_str( BAT *map, BAT *b)
                break;
        }
 }
-static str  
+static str
 CLUSTER_column_any(BAT *nb, BAT *b, BAT *cmap)
 {
        oid *ct, *ce, o = 0;
        BATiter bi= bat_iterator(b);
-       
+
        ct = (oid *)Tloc(cmap, 0);
        ce = ct + BATcount(cmap);
        nb->H->heap.dirty = nb->T->heap.dirty= TRUE;
@@ -284,7 +158,7 @@ CLUSTER_column_any(BAT *nb, BAT *b, BAT 
        }
        BATsetcount(nb, BATcount(b));
        BATderiveProps(nb, 0);
-       if (!(nb->batDirty&2)) 
+       if (!(nb->batDirty&2))
                BATsetaccess(nb, BAT_READ);
        return MAL_SUCCEED;
 }
@@ -326,7 +200,7 @@ CLUSTER_key( bat *M, const bat *B){
                case TYPE_str: CLUSTER_key_str(map,b); break;
                default:
                        throw(MAL, "cluster.key", MAL_MALLOC_FAIL);
-               
+
        }
        BATsave(map);   /* dump dirty pages from memory */
        BBPunfix(*B);
@@ -347,7 +221,7 @@ typedef struct{
                BUN base,limit,nxt;
 } Basket;
 
-str  
+str
 CLUSTER_map(bat *RB, const bat *B)
 {
        BUN rng,bsize, bnr=0, h, N= 2; /* number of buckets */
@@ -378,7 +252,7 @@ CLUSTER_map(bat *RB, const bat *B)
        map->H->nonil = b->H->nonil;
        map->T->nonil = TRUE;
        BATmax(b, (ptr) &rng); /* get the maximum hash key , could use mask !*/
-       rng++; 
+       rng++;
        /*
         * The key challenge is to determine the number of clusters.
         * A large number of clusters benefits subsequent performance,
@@ -397,7 +271,7 @@ CLUSTER_map(bat *RB, const bat *B)
        bsize= (rng+N-1) / N;
 #ifdef _CLUSTER_DEBUG
        N=2; /* for debugging only */
-       mnstr_printf(GDKout,"bucket pages %d size %d max %d  N %d\n", 
+       mnstr_printf(GDKout,"bucket pages %d size %d max %d  N %d\n",
                (int)MT_npages(), (int)bsize, (int)rng, (int)N);
 #endif
        basket = (Basket*) GDKzalloc((N+1) * sizeof(Basket));
@@ -459,7 +333,7 @@ CLUSTER_map(bat *RB, const bat *B)
  * We change the BAT in place using a temporary copy
  * to guide the move.
  */
-str 
+str
 CLUSTER_apply(bat *bid, BAT *b, BAT *cmap)
 {
        BAT *nb;
@@ -498,7 +372,7 @@ CLUSTER_apply(bat *bid, BAT *b, BAT *cma
        return MAL_SUCCEED;
 }
 
-str  
+str
 CLUSTER_column( Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
        bat *res =getArgReference_bat(stk, pci, 0);
@@ -522,7 +396,7 @@ CLUSTER_column( Client cntxt, MalBlkPtr 
        return msg;
 }
 
-str  
+str
 CLUSTER_table( Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
        BAT *map,*b;
@@ -561,1854 +435,294 @@ CLUSTER_table( Client cntxt, MalBlkPtr m
 #include "cluster.h"
 #include <mal_exception.h>
 
-str
-CLS_create_bte( bat *rpsum, bat *rcmap, bat *B, int *Bits, int *offset)
-{
-       BAT *psum, *cmap, *b;
-       int i, mask = 0, off = *offset;
-       int bits = *Bits;
-       bte *bt, *be; 
-       wrd *cnt, *pos, sum, *m;
-
-       if (off < 0)
-               off = 0;
-       if (bits >= (int)sizeof(int)*8 || bits < 0)
-               throw(MAL, "cluster.new", TOO_MANY_BITS);
-
-       if ((bits) != 0)
-               bits--;
-       mask = (1<<bits) - 1;
-       if ((b = BATdescriptor(*B)) == NULL)
-               throw(MAL, "cluster.new", INTERNAL_BAT_ACCESS);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to