Changeset: 4ea40c77a6f6 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4ea40c77a6f6 Modified Files: gdk/gdk_align.c gdk/gdk_batop.c gdk/gdk_cbp.c gdk/gdk_col.c gdk/gdk_search.c gdk/gdk_search.h Branch: headless Log Message:
Converted gdk_search. HASHremove is gone, use HASHdestroy instead. diffs (truncated from 719 to 300 lines): diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c --- a/gdk/gdk_align.c +++ b/gdk/gdk_align.c @@ -543,7 +543,7 @@ /* remove any leftover private hash structures */ if (b->hash) - HASHremove(b); + HASHdestroy(b); VIEWunlink(b); if (b->type && !b->heap.parentid) { diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -248,7 +248,7 @@ /* a hash is useless for void bats */ if (b->hash && (2 * b->hash->mask) < (COLcount(b) + sz)) { - HASHremove(b); + HASHdestroy(b); } if (b->hash != NULL || (b->key & BOUND2BTRUE) != 0) fastpath = 0; @@ -948,11 +948,11 @@ if (topN > COLcount(b)) { GDKerror("COLtopN: not enough tuples in target\n"); } else if (b->varsized) { - HASHremove(b); + HASHdestroy(b); while (COLcount(b) > topN) BUNdelete(b, BUNlast(b), FALSE); } else { - HASHremove(b); + HASHdestroy(b); COLsetcount(b, topN); } return 0; diff --git a/gdk/gdk_cbp.c b/gdk/gdk_cbp.c --- a/gdk/gdk_cbp.c +++ b/gdk/gdk_cbp.c @@ -2931,7 +2931,7 @@ b->id = COLstring; } if (b->hash) - HASHremove(b); + HASHdestroy(b); if (b->props) { PROPdestroy(b->props); b->props = NULL; diff --git a/gdk/gdk_col.c b/gdk/gdk_col.c --- a/gdk/gdk_col.c +++ b/gdk/gdk_col.c @@ -453,7 +453,7 @@ /* kill all search accelerators */ if (b->hash) { - HASHremove(b); + HASHdestroy(b); } /* we must dispose of all inserted atoms */ diff --git a/gdk/gdk_search.c b/gdk/gdk_search.c --- a/gdk/gdk_search.c +++ b/gdk/gdk_search.c @@ -131,32 +131,30 @@ return h; } -@= starthash - { - @1 *v = (@1*)BUNhloc(bi, 0); - for (; r < p; r++) { - oid c = hash_@1(h, v+r); +#define starthash(TYPE) \ + do { \ + TYPE *v = (TYPE*)BUNloc(bi, 0); \ + for (; r < p; r++) { \ + oid c = hash_##TYPE(h, v+r); \ + \ + if (h->hash[c] == BUN_NONE && nslots-- == 0) \ + break; /* mask too full */ \ + h->link[r] = h->hash[c]; \ + h->hash[c] = r; \ + } \ + } while (0) - if (h->hash[c] == BUN_NONE && nslots-- == 0) - break; /* mask too full */ - h->link[r] = h->hash[c]; - h->hash[c] = r; - } - } - break; -@ -@= finishhash - { - @1 *v = (@1*)BUNhloc(bi, 0); - for (; p < q; p++) { - oid c = hash_@1(h, v+p); +#define finishhash(TYPE) \ + do { \ + TYPE *v = (TYPE*)BUNloc(bi, 0); \ + for (; p < q; p++) { \ + oid c = hash_##TYPE(h, v+p); \ + \ + h->link[p] = h->hash[c]; \ + h->hash[c] = p; \ + } \ + } while (0) - h->link[p] = h->hash[c]; - h->hash[c] = p; - } - } - break; -@ /* * @- * The prime routine for the COL layer is to create a new hash index. @@ -168,8 +166,8 @@ { COL *o = NULL; - if (VIEWhparent(b)) { - bat p = VIEWhparent(b); + if (VIEWparent(b)) { + bat p = VIEWparent(b); o = b; b = COLdescriptor(p); if (!ALIGNsynced(o, b)) { @@ -179,8 +177,8 @@ } } gdk_set_lock(GDKhashLock(ABS(b->batCacheid) & CBP_BATMASK), "COLhash"); - if (b->H->hash == NULL) { - unsigned int tpe = ATOMstorage(b->htype); + if (b->hash == NULL) { + unsigned int tpe = ATOMstorage(b->type); oid cnt = COLcount(b); oid mask; oid p = BUNfirst(b), q = BUNlast(b), r; @@ -195,8 +193,8 @@ if (!cnt) cnt = COLcapacity(b); - if (b->htype == TYPE_void) { - if (b->hseqbase == oid_nil) { + if (b->type == TYPE_void) { + if (b->seqbase == oid_nil) { ALGODEBUG THRprintf(GDKout, "#COLhash: cannot create hash-table on void-NIL column.\n"); return NULL; } @@ -239,10 +237,10 @@ hp = (Heap *) GDKzalloc(sizeof(Heap)); if (hp && (hp->filename = GDKmalloc(strlen(nme) + 12)) != NULL) - sprintf(hp->filename, "%s.%chash", nme, b->batCacheid > 0 ? 'h' : 't'); + sprintf(hp->filename, "%s.thash", nme); if (hp == NULL || hp->filename == NULL || - (h = HASHnew(hp, ATOMtype(b->htype), COLcapacity(b), mask)) == NULL) { + (h = HASHnew(hp, ATOMtype(b->type), COLcapacity(b), mask)) == NULL) { gdk_unset_lock(GDKhashLock(ABS(b->batCacheid) & CBP_BATMASK), "COLhash"); if (hp != NULL) { GDKfree(hp->filename); @@ -254,30 +252,35 @@ switch (tpe) { #ifndef NOEXPAND_CHR case TYPE_chr: - @:starthash(chr)@ + starthash(chr); + break; #endif #ifndef NOEXPAND_BTE case TYPE_bte: - @:starthash(bte)@ + starthash(bte); + break; #endif #ifndef NOEXPAND_SHT case TYPE_sht: - @:starthash(sht)@ + starthash(sht); + break; #endif #if !defined(NOEXPAND_INT) || !defined(NOEXPAND_FLT) case TYPE_int: case TYPE_flt: - @:starthash(int)@ + starthash(int); + break; #endif #if !defined(NOEXPAND_DBL) || !defined(NOEXPAND_LNG) case TYPE_dbl: case TYPE_lng: - @:starthash(lng)@ + starthash(lng); + break; #endif default: for (; r < p; r++) { ptr v = BUNhead(bi, r); - oid c = heap_hash_any(b->H->vheap, h, v); + oid c = heap_hash_any(b->vheap, h, v); if (h->hash[c] == BUN_NONE && nslots-- == 0) @@ -294,41 +297,46 @@ switch (tpe) { #ifndef NOEXPAND_CHR case TYPE_chr: - @:finishhash(chr)@ + finishhash(chr); + break; #endif #ifndef NOEXPAND_BTE case TYPE_bte: - @:finishhash(bte)@ + finishhash(bte); + break; #endif #ifndef NOEXPAND_SHT case TYPE_sht: - @:finishhash(sht)@ + finishhash(sht); + break; #endif #if !defined(NOEXPAND_INT) || !defined(NOEXPAND_FLT) case TYPE_int: case TYPE_flt: - @:finishhash(int)@ + finishhash(int); + break; #endif #if !defined(NOEXPAND_DBL) || !defined(NOEXPAND_LNG) case TYPE_dbl: case TYPE_lng: - @:finishhash(lng)@ + finishhash(lng); + break; #endif default: for (; p < q; p++) { ptr v = BUNhead(bi, p); - oid c = heap_hash_any(b->H->vheap, h, v); + oid c = heap_hash_any(b->vheap, h, v); h->link[p] = h->hash[c]; h->hash[c] = p; } break; } - b->H->hash = h; + b->hash = h; } gdk_unset_lock(GDKhashLock(ABS(b->batCacheid) & CBP_BATMASK), "COLhash"); if (o != NULL) { - o->H->hash = b->H->hash; + o->hash = b->hash; CBPunfix(b->batCacheid); b = o; } @@ -378,22 +386,21 @@ COL *bn; oid p, q; - if (!(b && b->H->hash)) + if (!(b && b->hash)) return NULL; #if SIZEOF_OID == SIZEOF_INT - bn = COLnew(COLhtype(b), TYPE_int, COLcount(b)); + bn = COLnew(TYPE_int, COLcount(b)); #else - bn = COLnew(COLhtype(b), TYPE_lng, COLcount(b)); + bn = COLnew(TYPE_lng, COLcount(b)); #endif if (bn == NULL) return NULL; COLloop(b, p, q) { - oid i = HASHprobe(b->H->hash, BUNhead(bi, p)); + oid i = HASHprobe(b->hash, BUNhead(bi, p)); - bunfastins(bn, BUNhead(bi, p), &i); + bunfastins(bn, &i); } - bn->hsorted = COLhordered(b); - bn->tsorted = FALSE; + bn->sorted = FALSE; return bn; bunins_failed: CBPreclaim(bn); @@ -418,49 +425,38 @@ } void -HASHremove(COL *b) +HASHdestroy(COL *b) { - if (b && b->H->hash) { _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list