Changeset: a94facf62cf5 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a94facf62cf5
Modified Files:
        clients/Tests/exports.stable.out
        gdk/gdk_atoms.c
        gdk/gdk_atoms.h
        gdk/gdk_group.c
        gdk/gdk_hash.h
        gdk/gdk_private.h
        gdk/gdk_string.c
        geom/monetdb5/geom.c
        monetdb5/mal/mal_authorize.c
        monetdb5/mal/mal_interpreter.c
        monetdb5/modules/atoms/blob.c
        monetdb5/modules/atoms/color.c
        monetdb5/modules/atoms/inet.c
        monetdb5/modules/atoms/json.c
        monetdb5/modules/atoms/mtime.c
        monetdb5/modules/atoms/str.c
        monetdb5/modules/atoms/url.c
        monetdb5/modules/atoms/uuid.c
        monetdb5/modules/atoms/xml.c
        monetdb5/modules/kernel/batcolor.c
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql_rank.c
        sql/backends/monet5/sql_result.c
        sql/backends/monet5/sql_round_impl.h
        sql/server/rel_optimizer.c
        sql/server/rel_psm.c
        sql/server/rel_select.c
        sql/server/sql_atom.c
        sql/server/sql_mvc.c
        sql/server/sql_parser.y
        sql/server/sql_symbol.c
        sql/server/sql_symbol.h
        sql/server/sql_tokens.h
        sql/test/analytics/Tests/analytics01.stable.out
        sql/test/analytics/Tests/analytics02.sql
        sql/test/analytics/Tests/analytics02.stable.err
        sql/test/analytics/Tests/analytics02.stable.out
        sql/test/miscellaneous/Tests/simple_selects.sql
        sql/test/miscellaneous/Tests/simple_selects.stable.out
        sql/test/sample/Tests/sample.15.sql
        sql/test/sample/Tests/sample.15.stable.err
        sql/test/sample/Tests/sample.15.stable.out
Branch: default
Log Message:

Merged with linear-hashing


diffs (truncated from 2333 to 300 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
@@ -510,8 +510,6 @@ ssize_t shtToStr(str *dst, size_t *len, 
 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);
-size_t strLen(const char *s);
-int strNil(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.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -450,7 +450,7 @@ bitFromStr(const char *src, size_t *len,
 
        **dst = bit_nil;
 
-       if (GDK_STRNIL(src))
+       if (strNil(src))
                return 1;
 
        while (GDKisspace(*p))
@@ -508,7 +508,7 @@ batFromStr(const char *src, size_t *len,
 
        atommem(sizeof(bat));
 
-       if (GDK_STRNIL(src)) {
+       if (strNil(src)) {
                **dst = bat_nil;
                return 1;
        }
@@ -665,7 +665,7 @@ numFromStr(const char *src, size_t *len,
         * values */
        atommem(sz);
 
-       if (GDK_STRNIL(src)) {
+       if (strNil(src)) {
                memcpy(*dst, ATOMnilptr(tp), sz);
                return 1;
        }
@@ -903,7 +903,7 @@ ptrFromStr(const char *src, size_t *len,
        atommem(sizeof(ptr));
 
        **dst = ptr_nil;
-       if (GDK_STRNIL(src))
+       if (strNil(src))
                return 1;
 
        while (GDKisspace(*p))
@@ -956,7 +956,7 @@ dblFromStr(const char *src, size_t *len,
        /* alloc memory */
        atommem(sizeof(dbl));
 
-       if (GDK_STRNIL(src)) {
+       if (strNil(src)) {
                **dst = dbl_nil;
                return 1;
        }
@@ -1029,7 +1029,7 @@ fltFromStr(const char *src, size_t *len,
        /* alloc memory */
        atommem(sizeof(flt));
 
-       if (GDK_STRNIL(src)) {
+       if (strNil(src)) {
                **dst = flt_nil;
                return 1;
        }
@@ -1110,7 +1110,7 @@ OIDfromStr(const char *src, size_t *len,
        atommem(sizeof(oid));
 
        **dst = oid_nil;
-       if (GDK_STRNIL(src))
+       if (strNil(src))
                return 1;
 
        while (GDKisspace(*p))
diff --git a/gdk/gdk_atoms.h b/gdk/gdk_atoms.h
--- a/gdk/gdk_atoms.h
+++ b/gdk/gdk_atoms.h
@@ -69,8 +69,6 @@ gdk_export ssize_t dblToStr(str *dst, si
 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 strLen(const char *s);
-gdk_export int strNil(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);
 /*
@@ -323,11 +321,31 @@ ATOMreplaceVAR(int type, Heap *heap, var
  * though we have to take corrective action to ensure that str(nil) is
  * the smallest value of the domain.
  */
-#define GDK_STREQ(l,r) (strcmp(l,r) == 0)
-#define GDK_STRNIL(s)  ((s) == NULL || *(const char*) (s) == '\200')
-#define GDK_STRLEN(s)  ((GDK_STRNIL(s)?1:strlen(s))+1)
-#define GDK_STRCMP(l,r)        
(GDK_STRNIL(l)?(GDK_STRNIL(r)?0:-1):GDK_STRNIL(r)?1: \
-                        strcmp((const char*)(l), (const char*)(r)))
+static inline bool
+strEQ(const char *l, const char *r)
+{
+       return strcmp(l, r) == 0;
+}
+
+static inline bool
+strNil(const char *s)
+{
+       return s == NULL || *s == '\200';
+}
+
+static inline size_t
+strLen(const char *s)
+{
+       return strNil(s) ? 2 : strlen(s) + 1;
+}
+
+static inline int
+strCmp(const char *l, const char *r)
+{
+       return strNil(r)
+               ? !strNil(l)
+               : strNil(l) ? -1 : strcmp(l, r);
+}
 
 static inline var_t
 VarHeapValRaw(const void *b, BUN p, int w)
diff --git a/gdk/gdk_group.c b/gdk/gdk_group.c
--- a/gdk/gdk_group.c
+++ b/gdk/gdk_group.c
@@ -420,16 +420,23 @@ rev(oid x)
 }
 
 /* population count: count number of 1 bits in a value */
-#ifdef __GNUC__
-#if SIZEOF_OID == SIZEOF_INT
-#define pop(x)         __builtin_popcount(x)
-#else
-#define pop(x)         __builtin_popcountl(x)
-#endif
-#else
 static inline int
 pop(oid x)
 {
+#ifdef __GNUC__
+#if SIZEOF_OID == SIZEOF_INT
+       return __builtin_popcount(x);
+#else
+       return __builtin_popcountl(x);
+#endif
+#else
+#ifdef _MSC_VER
+#if SIZEOF_OID == SIZEOF_INT
+       return (int) __popcnt((unsigned int) (x));
+#else
+       return (int) __popcnt64((unsigned __int64) (x));
+#endif
+#else
        /* divide and conquer implementation */
 #if SIZEOF_OID == 8
        x = (x & 0x5555555555555555) + ((x >>  1) & 0x5555555555555555);
@@ -446,8 +453,9 @@ pop(oid x)
        x = (x & 0x0000FFFF) + ((x >> 16) & 0x0000FFFF);
 #endif
        return (int) x;
+#endif
+#endif
 }
-#endif
 
 #define GRP_create_partial_hash_table_core(INIT_1,HASH,EQUAL,ASSERT,GRPTST) \
        do {                                                            \
diff --git a/gdk/gdk_hash.h b/gdk/gdk_hash.h
--- a/gdk/gdk_hash.h
+++ b/gdk/gdk_hash.h
@@ -196,12 +196,12 @@ HASHgetlink(Hash *h, BUN i)
        for (hb = HASHget(h, HASHbucket(h, ((BUN *) (v))[-1])); \
             hb != HASHnil(h);                                  \
             hb = HASHgetlink(h, hb))                           \
-               if (GDK_STREQ(v, BUNtvar(bi, hb)))
+               if (strEQ(v, BUNtvar(bi, hb)))
 #define HASHloop_str(bi, h, hb, v)                             \
        for (hb = HASHget(h, HASHbucket(h, strHash(v)));        \
             hb != HASHnil(h);                                  \
             hb = HASHgetlink(h, hb))                           \
-               if (GDK_STREQ(v, BUNtvar(bi, hb)))
+               if (strEQ(v, BUNtvar(bi, hb)))
 
 #define HASHlooploc(bi, h, hb, v)                              \
        for (hb = HASHget(h, HASHprobe(h, v));                  \
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -232,8 +232,6 @@ void IMPSprint(BAT *b)              /* never called:
        __attribute__((__visibility__("hidden")));
 __hidden void strCleanHash(Heap *hp, bool rebuild)
        __attribute__((__visibility__("hidden")));
-__hidden int strCmp(const char *l, const char *r)
-       __attribute__((__visibility__("hidden")));
 __hidden void strHeap(Heap *d, size_t cap)
        __attribute__((__visibility__("hidden")));
 __hidden var_t strLocate(Heap *h, const char *v)
diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c
--- a/gdk/gdk_string.c
+++ b/gdk/gdk_string.c
@@ -64,24 +64,6 @@
 
 const char str_nil[2] = { '\200', 0 };
 
-int
-strNil(const char *s)
-{
-       return GDK_STRNIL(s);
-}
-
-size_t
-strLen(const char *s)
-{
-       return GDK_STRLEN(s);
-}
-
-int
-strCmp(const char *l, const char *r)
-{
-       return GDK_STRCMP(l, r);
-}
-
 void
 strHeap(Heap *d, size_t cap)
 {
@@ -144,7 +126,7 @@ strCleanHash(Heap *h, bool rebuild)
                        strhash = GDK_STRHASH(s);
                off = strhash & GDK_STRHASHMASK;
                newhash[off] = (stridx_t) (pos - extralen - sizeof(stridx_t));
-               pos += GDK_STRLEN(s);
+               pos += strLen(s);
        }
        /* only set dirty flag if the hash table actually changed */
        if (memcmp(newhash, h->base, sizeof(newhash)) != 0) {
@@ -165,7 +147,7 @@ strCleanHash(Heap *h, bool rebuild)
                        pos += pad + extralen;
                        s = h->base + pos;
                        assert(strLocate(h, s) != 0);
-                       pos += GDK_STRLEN(s);
+                       pos += strLen(s);
                }
        }
 #endif
@@ -194,7 +176,7 @@ strLocate(Heap *h, const char *v)
        /* search the linked list */
        for (ref = ((stridx_t *) h->base) + off; *ref; ref = next) {
                next = (stridx_t *) (h->base + *ref);
-               if (GDK_STRCMP(v, (str) (next + 1) + extralen) == 0)
+               if (strCmp(v, (str) (next + 1) + extralen) == 0)
                        return (var_t) ((sizeof(stridx_t) + *ref + extralen));  
/* found */
        }
        return 0;
@@ -205,7 +187,7 @@ strPut(Heap *h, var_t *dst, const char *
 {
        size_t elimbase = GDK_ELIMBASE(h->free);
        size_t pad;
-       size_t pos, len = GDK_STRLEN(v);
+       size_t pos, len = strLen(v);
        const size_t extralen = h->hashash ? EXTRALEN : 0;
        stridx_t *bucket;
        BUN off, strhash;
@@ -224,7 +206,7 @@ strPut(Heap *h, var_t *dst, const char *
 
                        do {
                                pos = *ref + sizeof(stridx_t) + extralen;
-                               if (GDK_STRCMP(v, h->base + pos) == 0) {
+                               if (strCmp(v, h->base + pos) == 0) {
                                        /* found */
                                        return *dst = (var_t) pos;
                                }
@@ -235,7 +217,7 @@ strPut(Heap *h, var_t *dst, const char *
                         * linked list, so only look at single
                         * entry */
                        pos = *bucket + extralen;
-                       if (GDK_STRCMP(v, h->base + pos) == 0) {
+                       if (strCmp(v, h->base + pos) == 0) {
                                /* already in heap: reuse */
                                return *dst = (var_t) pos;
                        }
@@ -604,7 +586,7 @@ strFromStr(const char *restrict src, siz
                return (ssize_t) strcpy_len(*dst, src, sz);
        }
 
-       if (GDK_STRNIL(src)) {
+       if (strNil(src)) {
                atommem(2);
                strcpy(*dst, str_nil);
                return 1;
@@ -761,7 +743,7 @@ strToStr(char **restrict dst, size_t *re
                atommem(sz);
                return (ssize_t) strcpy_len(*dst, src, sz);
        }
-       if (GDK_STRNIL(src)) {
+       if (strNil(src)) {
                atommem(4);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to