Changeset: 340fc40864f2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=340fc40864f2
Modified Files:
        gdk/gdk_hash.c
        gdk/gdk_hash.h
        monetdb5/modules/kernel/bat5.c
Branch: linear-hashing
Log Message:

No need for macro.


diffs (127 lines):

diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c
--- a/gdk/gdk_hash.c
+++ b/gdk/gdk_hash.c
@@ -94,7 +94,7 @@ HASHclear(Hash *h)
         * rather than iteratively assigning individual
         * BUNi_NONE values in a for-loop
         */
-       memset(h->Bckt, 0xFF, NHASHBUCKETS(h) * h->width);
+       memset(h->Bckt, 0xFF, h->nbucket * h->width);
 }
 
 #define HASH_VERSION           3
@@ -188,7 +188,7 @@ HASHcollisions(BAT *b, Hash *h, const ch
        if (b == 0 || h == 0)
                return;
        nil = HASHnil(h);
-       for (i = 0, j = NHASHBUCKETS(h); i < j; i++)
+       for (i = 0, j = h->nbucket; i < j; i++)
                if ((p = HASHget(h, i)) != nil) {
                        entries++;
                        cnt = 0;
@@ -200,10 +200,10 @@ HASHcollisions(BAT *b, Hash *h, const ch
                }
        fprintf(stderr,
                "#%s: %s(" ALGOBATFMT "): statistics " BUNFMT ", "
-               "entries " LLFMT ", nunique " BUNFMT ", nbuckets " BUNFMT ", "
+               "entries " LLFMT ", nunique " BUNFMT ", nbucket " BUNFMT ", "
                "max " LLFMT ", avg %2.6f;\n",
                MT_thread_getname(), func, ALGOBATPAR(b), BATcount(b), entries,
-               h->nunique, NHASHBUCKETS(h), max,
+               h->nunique, h->nbucket, max,
                entries == 0 ? 0 : total / entries);
 }
 
@@ -296,7 +296,7 @@ HASHgrowbucket(BAT *b)
 {
        Hash *h = b->thash;
        BUN nbucket;
-       BUN onbucket = NHASHBUCKETS(h);
+       BUN onbucket = h->nbucket;
        lng t0 = 0;
 
        ACCELDEBUG t0 = GDKusec();
@@ -317,7 +317,7 @@ HASHgrowbucket(BAT *b)
                                return GDK_FAIL;
                }
        }
-       while (h->nunique >= (nbucket = NHASHBUCKETS(h)) * 7 / 8) {
+       while (h->nunique >= (nbucket = h->nbucket) * 7 / 8) {
                BUN new = h->nbucket;
                BUN old = new & h->mask1;
                BATiter bi = bat_iterator(b);
@@ -381,13 +381,13 @@ HASHgrowbucket(BAT *b)
                else
                        HASHputlink(h, lold, HASHnil(h));
                BATsetprop_nolock(b, GDK_HASH_BUCKETS, TYPE_oid,
-                                 &(oid){NHASHBUCKETS(h)});
+                                 &(oid){h->nbucket});
        }
-       ACCELDEBUG if (NHASHBUCKETS(h) > onbucket) {
+       ACCELDEBUG if (h->nbucket > onbucket) {
                fprintf(stderr, "#%s: %s(" ALGOBATFMT ") " BUNFMT
                        " -> " BUNFMT " buckets (" LLFMT " usec)\n",
                        MT_thread_getname(), __func__, ALGOBATPAR(b),
-                       onbucket, NHASHBUCKETS(h), GDKusec() - t0);
+                       onbucket, h->nbucket, GDKusec() - t0);
                HASHcollisions(b, h, __func__);
        }
        return GDK_SUCCEED;
@@ -490,7 +490,7 @@ BATcheckhash(BAT *b)
                                                                        b,
                                                                        
GDK_HASH_BUCKETS,
                                                                        
TYPE_oid,
-                                                                       
&(oid){NHASHBUCKETS(h)});
+                                                                       
&(oid){h->nbucket});
                                                                
BATsetprop_nolock(
                                                                        b,
                                                                        
GDK_NUNIQUE,
@@ -903,7 +903,7 @@ BAThash_impl(BAT *b, BAT *s, const char 
                break;
        }
        if (s == NULL) {
-               BATsetprop_nolock(b, GDK_HASH_BUCKETS, TYPE_oid, 
&(oid){NHASHBUCKETS(h)});
+               BATsetprop_nolock(b, GDK_HASH_BUCKETS, TYPE_oid, 
&(oid){h->nbucket});
                BATsetprop_nolock(b, GDK_NUNIQUE, TYPE_oid, &(oid){h->nunique});
        }
        h->heapbckt.parentid = b->batCacheid;
@@ -1043,7 +1043,7 @@ HASHgonebad(BAT *b, const void *v)
        if (h == NULL)
                return true;    /* no hash is bad hash? */
 
-       if (NHASHBUCKETS(h) * 2 < BATcount(b)) {
+       if (h->nbucket * 2 < BATcount(b)) {
                int (*cmp) (const void *, const void *) = ATOMcompare(b->ttype);
                BUN i = HASHget(h, (BUN) HASHprobe(h, v)), nil = HASHnil(h);
                for (cnt = hit = 1; i != nil; i = HASHgetlink(h, i), cnt++)
diff --git a/gdk/gdk_hash.h b/gdk/gdk_hash.h
--- a/gdk/gdk_hash.h
+++ b/gdk/gdk_hash.h
@@ -23,7 +23,7 @@ typedef struct Hash {
        Heap heaplink;          /* heap where the hash links are stored */
        Heap heapbckt;          /* heap where the hash buckets are stored */
 } Hash;
-#define NHASHBUCKETS(h)                ((h)->nbucket)
+
 static inline BUN
 HASHbucket(const Hash *h, BUN v)
 {
diff --git a/monetdb5/modules/kernel/bat5.c b/monetdb5/modules/kernel/bat5.c
--- a/monetdb5/modules/kernel/bat5.c
+++ b/monetdb5/modules/kernel/bat5.c
@@ -91,13 +91,13 @@ HASHinfo(BAT *bk, BAT *bv, Hash *h, str 
        if (BUNappend(bk, pre(s, "type"), false) != GDK_SUCCEED ||
            BUNappend(bv, ATOMname(h->type),false) != GDK_SUCCEED ||
            BUNappend(bk, pre(s, "mask"), false) != GDK_SUCCEED ||
-           BUNappend(bv, local_utoa(NHASHBUCKETS(h), buf),false) != 
GDK_SUCCEED)
+           BUNappend(bv, local_utoa(h->nbucket, buf),false) != GDK_SUCCEED)
                return GDK_FAIL;
 
        for (i = 0; i < COLLISION + 1; i++) {
                cnt[i] = 0;
        }
-       for (i = 0; i < NHASHBUCKETS(h); i++) {
+       for (i = 0; i < h->nbucket; i++) {
                j = HASHlist(h, i);
                for (k = 0; j; k++)
                        j >>= 1;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to