Changeset: 42f38daad16d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=42f38daad16d
Modified Files:
        MonetDB5/src/modules/kernel/group.mx
Branch: Jun2010
Log Message:

merge from Feb2010:
"
 changeset:   35938:890a902526af
 branch:      Feb2010
 tag:         tip
 user:        Stefan Manegold <stefan.maneg...@cwi.nl>
 date:        Fri May 14 12:01:04 2010 +0200
 files:       MonetDB5/src/modules/kernel/group.mx
 description:
 cleanup: removed unused obsolete struct map_T

 In all occurrances, variables of type struct map_T* were only NULL;
 hence, we can savely remove the struct and all related code as
 unused & obsolete.


 changeset:   35937:8765a0f12da0
 branch:      Feb2010
 parent:      35913:cd1efaaf50ba
 user:        Stefan Manegold <stefan.maneg...@cwi.nl>
 date:        Fri May 14 11:57:30 2010 +0200
 files:       MonetDB5/src/modules/kernel/group.mx
 description:
 cleanup: removed unused obsolete functions & exports

 - removed unused obsolete functions:
   CThistosum(), CTsubhisto(), GRPsubhisto()

 - removed unused obsolete exports:
   CTgroup(), CTderive(), GRPsubhisto()

 - declared only locally used functions static:
   grp_new(), ctgro...@1_@4...@5(), CTgroup(), CTgroup_custom(),
   derive_mask(), CTderive_ordered(), CTderive(), CTrefine_rev(),
   ctgro...@1_ordered()

 - exported function that is used in rdf_shredder.mx:
   CTrefine()
"


diffs (truncated from 580 to 300 lines):

diff -r c7f75e98c4fb -r 42f38daad16d MonetDB5/src/modules/kernel/group.mx
--- a/MonetDB5/src/modules/kernel/group.mx      Thu May 13 19:55:41 2010 +0200
+++ b/MonetDB5/src/modules/kernel/group.mx      Fri May 14 12:12:53 2010 +0200
@@ -264,19 +264,17 @@
 #define group_export extern
 #endif
 
-group_export int CTderive(BAT **B, BAT **H, BAT *ct_hist, BAT *ct_map, BAT *b);
-group_export int CTgroup(BAT **B, BAT **H, BAT *b);
-
+group_export str GRPprelude(void);
 group_export str GRPgroup_custom(int *rethisto, int *retbid, int *bid, int *N, 
int *rng);
 group_export str GRPgroup(int *rethisto, int *retbid, int *bid);
-
-group_export str GRPprelude(void);
 group_export str GRPgroup0(int *ret, int *bid, int *start, int *incr, int 
*grpsize);
 group_export str GRPderive(int *hid, int *mid, int *ct_histoid, int *ct_mapid, 
int *bid);
-group_export str GRPsubhisto(int *retid, int *selid, int *grpid, int *domid);
 group_export str GRPrefine(int *retid, int *bid, int *aid);
 group_export str GRPrefine_rev(int *retid, int *bid, int *aid);
 
+/* used by rdf_shredder.mx */
+group_export int CTrefine(BAT **res, BAT *b, BAT *a);
+
 #endif /* _GROUP_H_ */
 @c
 #include "mal_config.h"
@@ -285,7 +283,7 @@
 static int TYPE_mapentry;
 
 
-int
+static int
 grp_new(BAT *b, BAT *h)
 {
        if (h) {
@@ -381,28 +379,19 @@
        } pad;                  /* padding to ensure power of 2 width */
 } mapentry_t;
 
-typedef struct {
-       BAT *map;               /* [mapentry,value] elements */
-       BUN *hash, mask;        /* hash buckets and mask */
-       Heap hp;                /* storage for hash buckets */
-} map_T;
 
 @:map_init_def(STANDARD,STANDARD_MASK,4096)@
 @:map_init_def(CUSTOM,custom_MASK,custom_rng)@
 
 @= map_init_def
 #define map_in...@1(map,hash,mask,entry,mapsize)                       \
-       if (m) {                                                        \
-               map = m->map; hash = m->hash; mask = m->mask;           \
-       } else {                                                        \
-               BUN _yy;                                                \
-               map = BATnew(TYPE_mapentry, tailtype(b,TRUE), @3);      \
-               hash = (BUN*) GDKmalloc((size_t)(sizeof(BUN)*((ma...@2)+1))); \
-               if (hash) for (_yy=0; _yy<=...@2; _yy++) {                      
\
-                       hash[_yy] = BUN_NONE;                           \
-               }                                                       \
+       BUN _yy;                                                        \
+       map = BATnew(TYPE_mapentry, tailtype(b,TRUE), @3);              \
+       hash = (BUN*) GDKmalloc((size_t)(sizeof(BUN)*((ma...@2)+1)));   \
+       if (hash) for (_yy=0; _yy<=...@2; _yy++) {                              
\
+               hash[_yy] = BUN_NONE;                                   \
        }                                                               \
-       entry.use.cnt = 1;                                                      
\
+       entry.use.cnt = 1;                                              \
        if (map == NULL || hash == NULL) {                              \
                if (map) BBPunfix(map->batCacheid);                     \
                if (hash) GDKfree(hash);                                \
@@ -410,18 +399,6 @@
        }                                                               \
        mapsize = BUNlast(map);
 @c
-#if 0
-static void
-map_free(map_T m)
-{
-       BBPreclaim(m.map);
-       HEAPfree(&m.hp);
-}
-#endif
-
-#ifndef offsetof
-#define offsetof(type, member) ((size_t) &((type *) 0)->member)
-#endif
 
 static BAT *
 map2histo(BAT *map)
@@ -491,8 +468,8 @@
 #define group_params_CUSTOM   BUN custom_MASK, BUN custom_rng,
 
 @= groupAll
-BAT *
-ctgro...@1_@4...@5(group_para...@5 BAT *b, BAT *bn, map_T *m)
+static BAT *
+ctgro...@1_@4...@5(group_para...@5 BAT *b, BAT *bn)
 {
        BATiter bi = bat_iterator(b), mapi;
        oid *hdst = (oid*) Hloc(bn, BUNfirst(bn)), *dst = (oid*) Tloc(bn, 
BUNfirst(bn));
@@ -520,18 +497,13 @@
                        r = zz;
                        e = (mapentry_t*) BUNhloc(mapi,r);
                        if (tst_g...@4(@3_EQ, b...@2(mapi,r), @1)) {
-                               if (m == NULL)
-                                       e->use.cnt++;
+                               e->use.cnt++;
                                goto found;
                        }
                }
 
                /* not found-> insert new element in map (and hash) */
-               if (m) {
-                       zz = mapsize;
-               } else {
-                       entry.use.gid = *(oid*) BUNhead(bi,p);
-               }
+               entry.use.gid = *(oid*) BUNhead(bi,p);
                entry.use.link = hash[c];
                hash[c] = mapsize++;
                bunfastins(map, &entry, tcur);
@@ -541,25 +513,21 @@
 found:         /* ultra-fast 'insert' of [oid,gid] into ct */
                if (bn->htype)
                        *hdst++ = *(oid*) BUNhead(bi,p);
-               *dst++ = m?zz:e->use.gid;
+               *dst++ = e->use.gid;
        }
        BATsetcount(bn, BATcount(b));
        bn->tsorted = 0;
        bn->T->nonil = 0;
        ALIGNsetH(bn,b);
        if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);
-       if (hash && !m)
+       if (hash)
                GDKfree(hash);
-       if (m)
-               BATaccessEnd(map, USE_HEAD|USE_TAIL, MMAP_WILLNEED);
        BATaccessEnd(b, USE_HEAD|USE_TAIL, MMAP_SEQUENTIAL);
-       return m ? NULL : map2histo(map);
+       return map2histo(map);
 bunins_failed:
-       if (m)
-               BATaccessEnd(map, USE_HEAD|USE_TAIL, MMAP_WILLNEED);
        BATaccessEnd(b, USE_HEAD|USE_TAIL, MMAP_SEQUENTIAL);
        BBPreclaim(bn);
-       if (hash && !m)
+       if (hash)
                GDKfree(hash);
        return NULL;
 }
@@ -611,7 +579,7 @@
 #define declare_mask_STANDARD  /* fixed */
 #define declare_mask_CUSTOM    BUN mask = (((BUN)1) << *N) - 1;
 
-int
+static int
 CTgroup(BAT **retval,          /* put pointer to BAT[oid,oid] record here. */
        BAT **hbat,             /* put histogram BAT here */
        BAT *b                  /* pointer to BAT[oid,oid] record. */
@@ -620,7 +588,7 @@
        @:CTgroupbody(STANDARD)@
 }
 
-int
+static int
 CTgroup_custom(BAT **retval,   /* put pointer to BAT[oid,oid] record here. */
    BAT **hbat, /* put histogram BAT here */
    BAT *b,             /* pointer to BAT[oid,oid] record. */
@@ -666,9 +634,9 @@
 
                /* Poor man's clustered test: sorted & !keyed => clustered  */
                if ( ((b->tsorted)&1) && !(b->tkey) ) {
-                       
@:choosegr...@1(tailtype(b,TRUE),bn,NULL,clustered,histo)@
+                       @:choosegr...@1(tailtype(b,TRUE),bn,clustered,histo)@
                } else {
-                       
@:choosegr...@1(tailtype(b,TRUE),bn,NULL,unclustered,histo)@
+                       @:choosegr...@1(tailtype(b,TRUE),bn,unclustered,histo)@
                }
                if (histo == NULL) {
                        BBPreclaim(bn);
@@ -686,60 +654,63 @@
        return grp_new(bn, histo);
 
 @= choosegroupSTANDARD
-       /* Choose appropriate @4 CTgroup implementation */
+       /* Choose appropriate @3 CTgroup implementation */
        switch(@1) {
        case TYPE_bte:
-               @?...@5:returnvalue(@5)@ ctgroup_b...@4_standard(b,@2,@3);
+               @?...@4:returnvalue(@4)@ ctgroup_b...@3_standard(b,@2);
                break;
        case TYPE_sht:
-               @?...@5:returnvalue(@5)@ ctgroup_s...@4_standard(b,@2,@3);
+               @?...@4:returnvalue(@4)@ ctgroup_s...@3_standard(b,@2);
                break;
        case TYPE_int:
-               @?...@5:returnvalue(@5)@ ctgroup_i...@4_standard(b,@2,@3);
+               @?...@4:returnvalue(@4)@ ctgroup_i...@3_standard(b,@2);
                break;
        case TYPE_lng:
-               @?...@5:returnvalue(@5)@ ctgroup_l...@4_standard(b,@2,@3);
+               @?...@4:returnvalue(@4)@ ctgroup_l...@3_standard(b,@2);
                break;
        case TYPE_str:
                if (b->T->vheap->hashash) {
-                       @?...@5:returnvalue(@5)@ 
ctgroup_str_...@4_standard(b,@2,@3);
+                       @?...@4:returnvalue(@4)@ 
ctgroup_str_...@3_standard(b,@2);
                        break;
                }
                /* fall through */
        default:
-               @?...@5:returnvalue(@5)@ ctgroup_a...@4_standard(b,@2,@3);
+               @?...@4:returnvalue(@4)@ ctgroup_a...@3_standard(b,@2);
                break;
        }
 
 @= choosegroupCUSTOM
-       /* Choose appropriate @4 CTgroup implementation */
+       /* Choose appropriate @3 CTgroup implementation */
        switch(@1) {
        case TYPE_bte:
-               @?...@5:returnvalue(@5)@ 
ctgroup_b...@4_custom(mask,*rng,b,@2,@3);
+               @?...@4:returnvalue(@4)@ ctgroup_b...@3_custom(mask,*rng,b,@2);
                break;
        case TYPE_sht:
-               @?...@5:returnvalue(@5)@ 
ctgroup_s...@4_custom(mask,*rng,b,@2,@3);
+               @?...@4:returnvalue(@4)@ ctgroup_s...@3_custom(mask,*rng,b,@2);
                break;
        case TYPE_int:
-               @?...@5:returnvalue(@5)@ 
ctgroup_i...@4_custom(mask,*rng,b,@2,@3);
+               @?...@4:returnvalue(@4)@ ctgroup_i...@3_custom(mask,*rng,b,@2);
                break;
        case TYPE_lng:
-               @?...@5:returnvalue(@5)@ 
ctgroup_l...@4_custom(mask,*rng,b,@2,@3);
+               @?...@4:returnvalue(@4)@ ctgroup_l...@3_custom(mask,*rng,b,@2);
                break;
        case TYPE_str:
                if (b->T->vheap->hashash) {
-                       @?...@5:returnvalue(@5)@ 
ctgroup_str_...@4_custom(mask,*rng,b,@2,@3);
+                       @?...@4:returnvalue(@4)@ 
ctgroup_str_...@3_custom(mask,*rng,b,@2);
                        break;
                }
                /* fall through */
        default:
-               @?...@5:returnvalue(@5)@ 
ctgroup_a...@4_custom(mask,*rng,b,@2,@3);
+               @?...@4:returnvalue(@4)@ ctgroup_a...@3_custom(mask,*rng,b,@2);
                break;
        }
 
 @c
+static int
+CTderive(BAT **M, BAT **H, BAT *ct_histo, BAT *ct_map, BAT *b);
+
 #define SAMPLE_SIZE    1024
-BUN
+static BUN
 derive_mask( BAT *ct_map, BAT *ct_histo, BAT *b)
 {
        BUN cnt = BATcount(b);
@@ -781,7 +752,7 @@
 
 @= derive
 static BAT *
-ctderi...@1_@2...@5(BAT* ct_map, BAT *ct_histo, BAT *b, BAT *bn, map_T *m)
+ctderi...@1_@2...@5(BAT* ct_map, BAT *ct_histo, BAT *b, BAT *bn)
 {
        BATiter bi = bat_iterator(b), mapi, ct_mapi = bat_iterator(ct_map);
        oid *hdst = (oid*) Hloc(bn, BUNfirst(bn)), *dst = (oid*) Tloc(bn, 
BUNfirst(bn));
@@ -818,17 +789,12 @@
                        r = zz;
                        e = (mapentry_t*) Hloc(map,r);
                        if (tst_deri...@5(@4_EQ, b...@3(mapi,r), @2)) {
-                               if (m == NULL)
-                                       e->use.cnt++;
+                               e->use.cnt++;
                                goto found;
                        }
                }
                /* not found-> insert new element in map (and hash) */
-               if (m) {
-                       zz = mapsize;
-               } else {
-                       entry.use.gid = *(oid*) BUNhead(bi,p);
-               }
+               entry.use.gid = *(oid*) BUNhead(bi,p);
                entry.use.hcur = hcur;
                entry.use.link = hash[c];
                hash[c] = mapsize++;
@@ -839,21 +805,17 @@
 found:         /* ultra-fast 'insert' of [oid,gid] into result ct */
                if (bn->htype)
                        *hdst++ = *(oid*) BUNhead(bi,p);
-               *dst++ = m?zz:e->use.gid;
+               *dst++ = e->use.gid;
        }
        BATsetcount(bn, (BUN) (dst - (oid *) bn->T->heap.base)); 
-       if (hash && !m)
+       if (hash)
_______________________________________________
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to