Changeset: 890a902526af for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=890a902526af
Modified Files:
MonetDB5/src/modules/kernel/group.mx
Branch: Feb2010
Log Message:
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.
diffs (truncated from 312 to 300 lines):
diff -r 8765a0f12da0 -r 890a902526af MonetDB5/src/modules/kernel/group.mx
--- a/MonetDB5/src/modules/kernel/group.mx Fri May 14 11:57:30 2010 +0200
+++ b/MonetDB5/src/modules/kernel/group.mx Fri May 14 12:01:04 2010 +0200
@@ -359,28 +359,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); \
@@ -388,18 +379,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)
@@ -470,7 +449,7 @@
@= groupAll
static BAT *
-ctgro...@1_@4...@5(group_para...@5 BAT *b, BAT *bn, map_T *m)
+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));
@@ -498,18 +477,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);
@@ -519,25 +493,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;
}
@@ -644,9 +614,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);
@@ -664,54 +634,54 @@
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;
}
@@ -762,7 +732,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));
@@ -799,17 +769,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++;
@@ -820,21 +785,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)
GDKfree(hash);
if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);
- 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);
- if (hash && !m)
+ if (hash)
GDKfree(hash);
BBPreclaim(bn);
return NULL;
@@ -864,25 +825,25 @@
/* Choose appropriate (@1 && @2) CTderive implementation */
switch(tt) {
case TYPE_bte:
- histo = ctderi...@1_bte_@2(ct_map,ct_histo,b,bn,m);
+ histo = ctderi...@1_bte_@2(ct_map,ct_histo,b,bn);
break;
case TYPE_sht:
- histo = ctderi...@1_sht_@2(ct_map,ct_histo,b,bn,m);
+ histo = ctderi...@1_sht_@2(ct_map,ct_histo,b,bn);
break;
case TYPE_int:
- histo = ctderi...@1_int_@2(ct_map,ct_histo,b,bn,m);
+ histo = ctderi...@1_int_@2(ct_map,ct_histo,b,bn);
break;
case TYPE_lng:
- histo = ctderi...@1_lng_@2(ct_map,ct_histo,b,bn,m);
+ histo = ctderi...@1_lng_@2(ct_map,ct_histo,b,bn);
break;
case TYPE_str:
if (b->T->vheap->hashash) {
- histo = ctderi...@1_str_hv_@2(ct_map,ct_histo,b,bn,m);
+ histo = ctderi...@1_str_hv_@2(ct_map,ct_histo,b,bn);
break;
}
/* fall through */
default:
- histo = ctderi...@1_any_@2(ct_map,ct_histo,b,bn,m);
+ histo = ctderi...@1_any_@2(ct_map,ct_histo,b,bn);
break;
}
@c
@@ -1042,7 +1003,7 @@
@c
static int
-derive(BAT **H, BAT **M, BAT *ct_histo, BAT *ct_map, BAT *b, int tt, map_T *m)
+derive(BAT **H, BAT **M, BAT *ct_histo, BAT *ct_map, BAT *b, int tt)
{
BAT *histo = NULL, *bn = NULL;
int synced = ALIGNsynced(ct_map, b);
@@ -1122,7 +1083,7 @@
{
int ret;
- ret = derive(H, M, ct_histo, ct_map, b, tailtype(b, TRUE), NULL);
+ ret = derive(H, M, ct_histo, ct_map, b, tailtype(b, TRUE));
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list