Changeset: b1240dfe3ea7 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b1240dfe3ea7
Added Files:
        sql/backends/monet5/UDF/pyapi/pyapi_locatepython2.bat.in
        sql/backends/monet5/UDF/pyapi3/pyapi_locatepython3.bat.in
Removed Files:
        sql/backends/monet5/UDF/pyapi/pyapi_locatepython2.bat
        sql/backends/monet5/UDF/pyapi3/pyapi_locatepython3.bat
Modified Files:
        NT/rules.msc
        gdk/gdk.h
        gdk/gdk_atoms.h
        gdk/gdk_batop.c
        gdk/gdk_bbp.c
        gdk/gdk_delta.h
        gdk/gdk_hash.h
        gdk/gdk_private.h
        gdk/gdk_string.c
        monetdb5/mal/mal_module.c
        monetdb5/modules/mal/wlc.c
        monetdb5/optimizer/opt_oltp.c
        sql/backends/monet5/UDF/capi/capi.c
        sql/backends/monet5/UDF/pyapi/Makefile.ag
        sql/backends/monet5/UDF/pyapi3/Makefile.ag
        testing/Mtest.py.in
        tools/merovingian/client/monetdb.c
        tools/merovingian/daemon/argvcmds.c
        tools/merovingian/daemon/forkmserver.c
        tools/merovingian/utils/utils.c
Branch: linear-hashing
Log Message:

Merge with default branch.


diffs (truncated from 724 to 300 lines):

diff --git a/NT/rules.msc b/NT/rules.msc
--- a/NT/rules.msc
+++ b/NT/rules.msc
@@ -64,18 +64,24 @@ PTHREAD_LIBS =
 ODBCINST_LIBS = odbccp32.lib user32.lib $(LEGACY_STDIO_DEFINITIONS)
 ODBC_LIBS = odbc32.lib
 
+!IFNDEF PY3VER
+PY2VER=7
+!ENDIF
 !IFNDEF PYTHON2BASE
-PYTHON2BASE=C:\Python27
+PYTHON2BASE=C:\Python2$(PY2VER)
 !ENDIF
 !IFNDEF PYTHON2LIB
-PYTHON2LIB=python27.lib
+PYTHON2LIB=python2$(PY2VER).lib
 !ENDIF
 
+!IFNDEF PY3VER
+PY3VER=7
+!ENDIF
 !IFNDEF PYTHON3BASE
-PYTHON3BASE=C:\Python32
+PYTHON3BASE=C:\Python3$(PY3VER)
 !ENDIF
 !IFNDEF PYTHON3LIB
-PYTHON3LIB=python37.lib
+PYTHON3LIB=python3$(PY3VER).lib
 !ENDIF
 
 PYTHON_LIBDIR=share\MonetDB\python
@@ -416,6 +422,8 @@ CONFIGURE="$(PYTHON)" $(CONFIGURE_PY) \
        "PACKAGE=$(pkg)" \
        "PYTHON=$(PYTHON)" \
        "PYTHON_LIBDIR=$(PYTHON_LIBDIR)" \
+       "PY2VER=$(PY2VER)" \
+       "PY3VER=$(PY3VER)" \
        "PYTHON2=$(PYTHON2)" \
        "PYTHON3=$(PYTHON3)" \
        "TOPDIR=$(TOPDIR)" \
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -974,19 +974,6 @@ typedef var_t stridx_t;
 #define SIZEOF_STRIDX_T SIZEOF_VAR_T
 #define GDK_VARALIGN SIZEOF_STRIDX_T
 
-#if SIZEOF_VAR_T == 8
-#define VarHeapValRaw(b,p,w)                                           \
-       ((w) == 1 ? (var_t) ((uint8_t *) (b))[p] + GDK_VAROFFSET :      \
-        (w) == 2 ? (var_t) ((uint16_t *) (b))[p] + GDK_VAROFFSET :     \
-        (w) == 4 ? (var_t) ((uint32_t *) (b))[p] :                     \
-        ((var_t *) (b))[p])
-#else
-#define VarHeapValRaw(b,p,w)                                           \
-       ((w) == 1 ? (var_t) ((uint8_t *) (b))[p] + GDK_VAROFFSET :      \
-        (w) == 2 ? (var_t) ((uint16_t *) (b))[p] + GDK_VAROFFSET :     \
-        ((var_t *) (b))[p])
-#endif
-#define VarHeapVal(b,p,w) ((size_t) VarHeapValRaw(b,p,w))
 #define BUNtvaroff(bi,p) VarHeapVal((bi).b->theap.base, (p), (bi).b->twidth)
 
 #define BUNtloc(bi,p)  Tloc((bi).b,p)
@@ -2598,15 +2585,6 @@ gdk_export void VIEWbounds(BAT *b, BAT *
        for (q = BUNlast(r), p = 0; p < q; p++)
 
 /*
- * @- hash-table supported loop over BUNs
- * The first parameter `b' is a BAT, the second (`h') should point to
- * `b->thash', and `v' a pointer to an atomic value (corresponding
- * to the head column of `b'). The 'hb' is an integer index, pointing
- * out the `hb'-th BUN.
- */
-#define GDK_STREQ(l,r) (*(char*) (l) == *(char*) (r) && !strcmp(l,r))
-
-/*
  * @+ Common BAT Operations
  * Much used, but not necessarily kernel-operations on BATs.
  *
diff --git a/gdk/gdk_atoms.h b/gdk/gdk_atoms.h
--- a/gdk/gdk_atoms.h
+++ b/gdk/gdk_atoms.h
@@ -149,7 +149,7 @@ gdk_export const ptr ptr_nil;
 #define is_oid_nil(v)  ((v) == oid_nil)
 #define is_flt_nil(v)  isnan(v)
 #define is_dbl_nil(v)  isnan(v)
-#define is_bat_nil(v)  ((v) == bat_nil || (v) == 0)
+#define is_bat_nil(v)  (((v) & 0x7FFFFFFF) == 0) /* v == bat_nil || v == 0 */
 
 #include <math.h>
 
@@ -323,12 +323,33 @@ 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_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: \
-                         (*(const unsigned char*)(l) < *(const unsigned 
char*)(r))?-1: \
-                         (*(const unsigned char*)(l) > *(const unsigned 
char*)(r))?1: \
-                         strCmpNoNil((const unsigned char*)(l),(const unsigned 
char*)(r)))
+#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: \
+                        (*(const unsigned char*)(l) < *(const unsigned 
char*)(r))?-1: \
+                        (*(const unsigned char*)(l) > *(const unsigned 
char*)(r))?1: \
+                        strCmpNoNil((const unsigned char*)(l),(const unsigned 
char*)(r)))
+
+static inline var_t
+VarHeapValRaw(const void *b, BUN p, int w)
+{
+       switch (w) {
+       case 1:
+               return (var_t) ((const uint8_t *) b)[p] + GDK_VAROFFSET;
+       case 2:
+               return (var_t) ((const uint16_t *) b)[p] + GDK_VAROFFSET;
+#if SIZEOF_VAR_T == 8
+       case 4:
+               return (var_t) ((const uint32_t *) b)[p];
+#endif
+       default:
+               return ((const var_t *) b)[p];
+       }
+}
+
+#define VarHeapVal(b,p,w)      ((size_t) VarHeapValRaw(b,p,w))
+
 /*
  * @- Hash Function
  * The string hash function is a very simple hash function that xors
@@ -336,18 +357,20 @@ ATOMreplaceVAR(int type, Heap *heap, var
  * characters at a time (adding 16-bits to the hash value each
  * iteration).
  */
-#define GDK_STRHASH(x,y)                               \
-       do {                                            \
-               const char *_key = (const char *) (x);  \
-               BUN _i;                                 \
-               for (_i = y = 0; _key[_i]; _i++) {      \
-                   y += _key[_i];                      \
-                   y += (y << 10);                     \
-                   y ^= (y >> 6);                      \
-               }                                       \
-               y += (y << 3);                          \
-               y ^= (y >> 11);                         \
-               y += (y << 15);                         \
-       } while (0)
+static inline BUN
+GDK_STRHASH(const char *key)
+{
+       BUN y = 0;
+
+       for (BUN i = 0; key[i]; i++) {
+               y += key[i];
+               y += (y << 10);
+               y ^= (y >> 6);
+       }
+       y += (y << 3);
+       y ^= (y >> 11);
+       y += (y << 15);
+       return y;
+}
 
 #endif /* _GDK_ATOMS_H_ */
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -149,7 +149,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] : 
strHash(n->tvheap->base + off))))
+                                    ((BUN *) (b->tvheap->base + off))[-1] == 
(n->tvheap->hashash ? ((BUN *) (n->tvheap->base + off))[-1] : 
GDK_STRHASH(n->tvheap->base + off))))
                                        match++;
                                len += (strlen(n->tvheap->base + off) + 8) & ~7;
                        }
@@ -335,7 +335,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] : strHash(tp)))) {
+                            ((BUN *) (b->tvheap->base + off))[-1] == 
(n->tvheap->hashash ? ((BUN *) tp)[-1] : GDK_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) (strHash(BBP_logical(i)) & BBP_mask);
+       bat idx = (bat) (GDK_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) (strHash(s) & BBP_mask);
+       bat idx = (bat) (GDK_STRHASH(s) & BBP_mask);
 
        for (h += idx; (i = *h) != 0; h = &BBP_next(i)) {
                if (strcmp(BBP_logical(i), s) == 0) {
@@ -2019,7 +2019,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[strHash(nme) & BBP_mask]; i; i = BBP_next(i)) 
{
+               for (i = BBP_hash[GDK_STRHASH(nme) & BBP_mask]; i; i = 
BBP_next(i)) {
                        if (strcmp(BBP_logical(i), nme) == 0)
                                break;
                }
diff --git a/gdk/gdk_delta.h b/gdk/gdk_delta.h
--- a/gdk/gdk_delta.h
+++ b/gdk/gdk_delta.h
@@ -15,20 +15,21 @@
  * e.g. a BAT[void,bit] is (at least) integer aligned.  This optimizes
  * processing on such BATs (DDBENCH).
  */
-#define DELTAinit(P1)                                          \
-       do {                                                    \
-               BATsetcount((P1), 0);                           \
-               (P1)->theap.free = 0;                           \
-               (P1)->batInserted = 0;                          \
-               (P1)->tshift = ATOMelmshift(Tsize(P1));         \
-               DELTADEBUG fprintf(stderr,                      \
-                       "#DELTAinit %s free %zu ins " BUNFMT    \
-                       " base %p\n",                           \
-                       BATgetId(P1),                           \
-                       (P1)->theap.free,                       \
-                       (P1)->batInserted,                      \
-                       (P1)->theap.base);                      \
-       } while (0)
+static inline void
+DELTAinit(BAT *b)
+{
+       BATsetcount(b, 0);
+       b->theap.free = 0;
+       b->batInserted = 0;
+       b->tshift = ATOMelmshift(Tsize(b));
+       DELTADEBUG fprintf(stderr,
+                          "#DELTAinit %s free %zu ins " BUNFMT " base %p\n",
+                          BBP_logical(b->batCacheid),
+                          b->theap.free,
+                          b->batInserted,
+                          b->theap.base);
+}
+
 /*
  * Upon saving a BAT, we should convert the delta marker BUN pointers
  * into indexes and convert them back into pointers upon reload.
diff --git a/gdk/gdk_hash.h b/gdk/gdk_hash.h
--- a/gdk/gdk_hash.h
+++ b/gdk/gdk_hash.h
@@ -238,6 +238,13 @@ HASHgetlink(Hash *h, BUN i)
 #define HASHfnd_flt(x,y,z)     HASHfnd_TYPE(x,y,z,flt)
 #define HASHfnd_dbl(x,y,z)     HASHfnd_TYPE(x,y,z,dbl)
 
+/*
+ * @- hash-table supported loop over BUNs
+ * The first parameter `b' is a BAT, the second (`h') should point to
+ * `b->thash', and `v' a pointer to an atomic value (corresponding
+ * to the head column of `b'). The 'hb' is an integer index, pointing
+ * out the `hb'-th BUN.
+ */
 #define HASHloop(bi, h, hb, v)                                 \
        for (hb = HASHget(h, HASHprobe(h, v));                  \
             hb != HASHnil(h);                                  \
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -361,7 +361,7 @@ extern MT_Lock GDKtmLock;
 
 #define GDKswapLock(x)  GDKbatLock[(x)&BBP_BATMASK].swap
 #if SIZEOF_SIZE_T == 8
-#define threadmask(y)  ((int) ((mix_int((unsigned int) y) ^ mix_int((unsigned 
int) (y >> 32))) & BBP_THREADMASK))
+#define threadmask(y)  ((int) (mix_lng(y) & BBP_THREADMASK))
 #else
 #define threadmask(y)  ((int) (mix_int(y) & BBP_THREADMASK))
 #endif
diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c
--- a/gdk/gdk_string.c
+++ b/gdk/gdk_string.c
@@ -117,10 +117,7 @@ strHeap(Heap *d, size_t cap)
 BUN
 strHash(const char *s)
 {
-       BUN res;
-
-       GDK_STRHASH(s, res);
-       return res;
+       return GDK_STRHASH(s);
 }
 
 void
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to