Changeset: 183679f4699d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=183679f4699d
Modified Files:
        clients/Tests/exports.stable.out
        gdk/gdk_atoms.h
        gdk/gdk_batop.c
        gdk/gdk_bbp.c
        gdk/gdk_string.c
        gdk/gdk_system.h
        monetdb5/mal/mal_module.c
        monetdb5/optimizer/opt_oltp.c
        sql/backends/monet5/UDF/capi/capi.c
Branch: linear-hashing
Log Message:

Replace GDK_STRHASH by inline function strHash.


diffs (186 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -484,7 +484,6 @@ ssize_t shtFromStr(const char *src, size
 ssize_t shtToStr(str *dst, size_t *len, const sht *src, bool external);
 const sht sht_nil;
 ssize_t strFromStr(const char *restrict src, size_t *restrict len, str 
*restrict dst, bool external);
-BUN strHash(const char *s);
 const char str_nil[2];
 gdk_return void_inplace(BAT *b, oid id, const void *val, bool force) 
__attribute__((__warn_unused_result__));
 int win_mkdir(const char *, const int mode);
diff --git a/gdk/gdk_atoms.h b/gdk/gdk_atoms.h
--- a/gdk/gdk_atoms.h
+++ b/gdk/gdk_atoms.h
@@ -131,7 +131,6 @@ gdk_export ssize_t dblFromStr(const char
 gdk_export ssize_t dblToStr(str *dst, size_t *len, const dbl *src, bool 
external);
 gdk_export ssize_t GDKstrFromStr(unsigned char *restrict dst, const unsigned 
char *restrict src, ssize_t len);
 gdk_export ssize_t strFromStr(const char *restrict src, size_t *restrict len, 
str *restrict dst, bool external);
-gdk_export BUN strHash(const char *s);
 gdk_export size_t escapedStrlen(const char *restrict src, const char *sep1, 
const char *sep2, int quote);
 gdk_export size_t escapedStr(char *restrict dst, const char *restrict src, 
size_t dstlen, const char *sep1, const char *sep2, int quote);
 /*
@@ -436,8 +435,9 @@ VarHeapValRaw(const void *b, BUN p, int 
  * characters at a time (adding 16-bits to the hash value each
  * iteration).
  */
+static BUN strHash(const char *key) __attribute__((__pure__));
 static inline BUN
-GDK_STRHASH(const char *key)
+strHash(const char *key)
 {
        BUN y = 0;
 
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -153,7 +153,7 @@ insert_string_bat(BAT *b, BAT *n, BAT *s
                                if (off < b->tvheap->free &&
                                    strcmp(b->tvheap->base + off, 
n->tvheap->base + off) == 0 &&
                                    (!b->tvheap->hashash ||
-                                    ((BUN *) (b->tvheap->base + off))[-1] == 
(n->tvheap->hashash ? ((BUN *) (n->tvheap->base + off))[-1] : 
GDK_STRHASH(n->tvheap->base + off))))
+                                    ((BUN *) (b->tvheap->base + off))[-1] == 
(n->tvheap->hashash ? ((BUN *) (n->tvheap->base + off))[-1] : 
strHash(n->tvheap->base + off))))
                                        match++;
                                len += (strlen(n->tvheap->base + off) + 8) & ~7;
                        }
@@ -338,7 +338,7 @@ insert_string_bat(BAT *b, BAT *n, BAT *s
                        if (off < b->tvheap->free &&
                            strcmp(b->tvheap->base + off, tp) == 0 &&
                            (!b->tvheap->hashash ||
-                            ((BUN *) (b->tvheap->base + off))[-1] == 
(n->tvheap->hashash ? ((BUN *) tp)[-1] : GDK_STRHASH(tp)))) {
+                            ((BUN *) (b->tvheap->base + off))[-1] == 
(n->tvheap->hashash ? ((BUN *) tp)[-1] : strHash(tp)))) {
                                /* we found the string at the same
                                 * offset in b's string heap as it was
                                 * in n's string heap, so we don't
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -127,7 +127,7 @@ static bool havehge = false;
 static void
 BBP_insert(bat i)
 {
-       bat idx = (bat) (GDK_STRHASH(BBP_logical(i)) & BBP_mask);
+       bat idx = (bat) (strHash(BBP_logical(i)) & BBP_mask);
 
        BBP_next(i) = BBP_hash[idx];
        BBP_hash[idx] = i;
@@ -138,7 +138,7 @@ BBP_delete(bat i)
 {
        bat *h = BBP_hash;
        const char *s = BBP_logical(i);
-       bat idx = (bat) (GDK_STRHASH(s) & BBP_mask);
+       bat idx = (bat) (strHash(s) & BBP_mask);
 
        for (h += idx; (i = *h) != 0; h = &BBP_next(i)) {
                if (strcmp(BBP_logical(i), s) == 0) {
@@ -2031,7 +2031,7 @@ BBP_find(const char *nme, bool lock)
                /* must lock since hash-lookup traverses other BATs */
                if (lock)
                        MT_lock_set(&GDKnameLock);
-               for (i = BBP_hash[GDK_STRHASH(nme) & BBP_mask]; i; i = 
BBP_next(i)) {
+               for (i = BBP_hash[strHash(nme) & BBP_mask]; i; i = BBP_next(i)) 
{
                        if (strcmp(BBP_logical(i), nme) == 0)
                                break;
                }
diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c
--- a/gdk/gdk_string.c
+++ b/gdk/gdk_string.c
@@ -84,12 +84,6 @@ strHeap(Heap *d, size_t cap)
 }
 
 
-BUN
-strHash(const char *s)
-{
-       return GDK_STRHASH(s);
-}
-
 void
 strCleanHash(Heap *h, bool rebuild)
 {
@@ -123,7 +117,7 @@ strCleanHash(Heap *h, bool rebuild)
                if (h->hashash)
                        strhash = ((const BUN *) s)[-1];
                else
-                       strhash = GDK_STRHASH(s);
+                       strhash = strHash(s);
                off = strhash & GDK_STRHASHMASK;
                newhash[off] = (stridx_t) (pos - extralen - sizeof(stridx_t));
                pos += strLen(s);
@@ -167,7 +161,7 @@ strLocate(Heap *h, const char *v)
 
        /* search hash-table, if double-elimination is still in place */
        BUN off;
-       off = GDK_STRHASH(v);
+       off = strHash(v);
        off &= GDK_STRHASHMASK;
 
        /* should only use strLocate iff fully double eliminated */
@@ -192,7 +186,7 @@ strPut(Heap *h, var_t *dst, const char *
        stridx_t *bucket;
        BUN off, strhash;
 
-       off = GDK_STRHASH(v);
+       off = strHash(v);
        strhash = off;
        off &= GDK_STRHASHMASK;
        bucket = ((stridx_t *) h->base) + off;
diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h
--- a/gdk/gdk_system.h
+++ b/gdk/gdk_system.h
@@ -37,6 +37,7 @@
 #define __has_attribute__malloc__ 1
 #define __has_attribute__nonstring__ 0
 #define __has_attribute__noreturn__ 1
+#define __has_attribute__pure__ 0
 #define __has_attribute__returns_nonnull__ 0
 #define __has_attribute__visibility__ 1
 #define __has_attribute__warn_unused_result__ 1
@@ -61,6 +62,9 @@
 #if !__has_attribute(__noreturn__)
 #define __noreturn__
 #endif
+#if !__has_attribute(__pure__)
+#define __pure__
+#endif
 /* these are used in some *private.h files */
 #if !__has_attribute(__visibility__)
 #define __visibility__(a)
diff --git a/monetdb5/mal/mal_module.c b/monetdb5/mal/mal_module.c
--- a/monetdb5/mal/mal_module.c
+++ b/monetdb5/mal/mal_module.c
@@ -82,7 +82,7 @@ mal_module_reset(void)
 }
 
 static int getModuleIndex(str name) {
-       return (int) (GDK_STRHASH(name) % MODULE_HASH_SIZE);
+       return (int) (strHash(name) % MODULE_HASH_SIZE);
 }
 
 static void clrModuleIndex(Module cur){
diff --git a/monetdb5/optimizer/opt_oltp.c b/monetdb5/optimizer/opt_oltp.c
--- a/monetdb5/optimizer/opt_oltp.c
+++ b/monetdb5/optimizer/opt_oltp.c
@@ -22,7 +22,7 @@ addLock(Client cntxt, OLTPlocks locks, M
        (void) cntxt;
        r =(sch?getVarConstant(mb, getArg(p,sch)).val.sval : "sqlcatalog");
        s =(tbl? getVarConstant(mb, getArg(p,tbl)).val.sval : "");
-       hash = (GDK_STRHASH(r)  ^ GDK_STRHASH(s)) % MAXOLTPLOCKS ;
+       hash = (strHash(r)  ^ strHash(s)) % MAXOLTPLOCKS ;
        hash += (hash == 0);
        locks[hash] = 1;
 }
diff --git a/sql/backends/monet5/UDF/capi/capi.c 
b/sql/backends/monet5/UDF/capi/capi.c
--- a/sql/backends/monet5/UDF/capi/capi.c
+++ b/sql/backends/monet5/UDF/capi/capi.c
@@ -562,8 +562,8 @@ static str CUDFeval(Client cntxt, MalBlk
        // begin the compilation phase
        // first look up if we have already compiled this function
        expression_hash = 0;
-       expression_hash = GDK_STRHASH(exprStr);
-       funcname_hash = GDK_STRHASH(funcname);
+       expression_hash = strHash(exprStr);
+       funcname_hash = strHash(funcname);
        funcname_hash = funcname_hash % FUNCTION_CACHE_SIZE;
        j = 0;
        for (i = 0; i < (size_t)pci->argc; i++) {
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to