Changeset: 1a82da10f57d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1a82da10f57d
Modified Files:
        gdk/gdk_batop.c
        gdk/gdk_rangejoin.mx
Branch: headless
Log Message:

Merging


diffs (truncated from 1672 to 300 lines):

diff --git a/gdk/Makefile.ag b/gdk/Makefile.ag
--- a/gdk/Makefile.ag
+++ b/gdk/Makefile.ag
@@ -21,13 +21,13 @@
 
 EXTRA_DIST = gdk.h gdk_cbp.h gdk_col.h gdk_delta.h \
 #      gdk_logger.h \
-       gdk_posix.h gdk_private.h gdk_qsort_impl.h gdk_ssort_impl.h 
gdk_storage.h gdk_system.h gdk_tm.h gdk_utils.h gdk_setop.h
+       gdk_posix.h gdk_private.h gdk_qsort_impl.h gdk_rangejoin.h 
gdk_ssort_impl.h gdk_storage.h gdk_system.h gdk_tm.h gdk_utils.h gdk_setop.h
 
 lib_gdk = { 
        VERSION = $(GDK_VERSION)
        NAME = bat
        SOURCES = \
-               gdk_batop.c \
+               gdk_colop.c \
                gdk_search.c \
                gdk_setop.c gdk_utils.c gdk_atoms.c \
                gdk_relop.c \
@@ -36,7 +36,7 @@
                gdk_qsort.c gdk_ssort.c gdk_storage.c gdk_col.c \
                gdk_delta.c \
                gdk_system.c gdk_value.c \
-#              gdk_rangejoin.mx \
+               gdk_rangejoin.c \
                gdk_posix.c \
 #              gdk_logger.c \
                bat.feps bat1.feps bat2.feps \
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -402,10 +402,6 @@
 #endif
 #endif
 
-/* #ifdef __cplusplus */
-/* extern "C" { */
-/* #endif */
-
 #include "gdk_system.h"
 #include "gdk_posix.h"
 #include <stream.h>
@@ -475,8 +471,7 @@
  * The interface definitions for the application programs are shown
  * below.  The global variables should not be modified directly.
  */
-#define NEG(A) (((int)(A))>0?-((int)(A)):((int)(A)))
-#define ABS(A) (((int)(A))>0?((int)(A)):-((int)(A)))
+#define ABS(A)         ((A) > 0 ? (A) : -(A))
 
 #ifndef TRUE
 #define TRUE           1
@@ -538,13 +533,13 @@
 typedef char *str;
 
 #if SIZEOF_INT==8
-#      define LL_CONSTANT(val) (val)
+# define LL_CONSTANT(val)      (val)
 #elif SIZEOF_LONG==8
-#      define LL_CONSTANT(val) (val##L)
+# define LL_CONSTANT(val)      (val##L)
 #elif defined(HAVE_LONG_LONG)
-#      define LL_CONSTANT(val) (val##LL)
+# define LL_CONSTANT(val)      (val##LL)
 #elif defined(HAVE___INT64)
-#      define LL_CONSTANT(val) (val##i64)
+# define LL_CONSTANT(val)      (val##i64)
 #endif
 
 typedef char long_str[IDLENGTH];       /* standard GDK static string */
@@ -577,47 +572,54 @@
 
 gdk_export int GDKsilent;      /* should GDK shut up? */
 
-#define FATALcheck(tst,        msg) if (tst) GDKfatal(msg);
-#define ERRORcheck(tst,        msg) if (tst) { GDKerror(msg); return 0; }
-#define WARNcheck(tst, msg) if (tst) GDKwarning(msg)
-#define COLcheck(tst,  msg)                                    \
-       if (tst == NULL) {                                      \
-               if (strchr(msg, ':'))                           \
-                       GDKerror("%s.\n",msg);                  \
-               else                                            \
-                       GDKerror("%s: COL required.\n",msg);    \
-               return 0;                                       \
-       }
+#define FATALcheck(tst,        msg) do if (tst) GDKfatal(msg); while (0)
+#define ERRORcheck(tst,        msg) do if (tst) { GDKerror(msg); return 0; } 
while (0)
+#define COLcheck(tst, msg)                                             \
+       do {                                                            \
+               if (tst == NULL) {                                      \
+                       if (strchr(msg, ':'))                           \
+                               GDKerror("%s.\n",msg);                  \
+                       else                                            \
+                               GDKerror("%s: COL required.\n",msg);    \
+                       return 0;                                       \
+               }                                                       \
+       } while (0)
 
 #define ATOMextern(t)  (ATOMstorage(t) >= TYPE_str)
 
-#define TYPEcastable(t1,t2)    (ATOMtype(t1)==ATOMtype(t2))
-#define TYPEequal(t1,t2)       (ATOMtype(t1)==ATOMtype(t2))
-#define TYPEcomp(t1,t2)        
(ATOMstorage(ATOMtype(t1))==ATOMstorage(ATOMtype(t2)))
-#define TYPEerror(t1,t2)       (!TYPEcomp(t1,t2))
-#define TYPEcheck(t1,t2)                                               \
-       if (TYPEerror(t1,t2)) {                                         \
-               GDKerror("TYPEcheck: Incompatible types %s and %s.\n",  \
-                       ATOMname(t2), ATOMname(t1));                    \
-               return 0;                                               \
-       } else if (!TYPEcomp(t1,t2)) {                                  \
-               CHECKDEBUG THRprintf(GDKout,"#Interpreting %s as %s.\n", \
-                       ATOMname(t2), ATOMname(t1));                    \
-       }
-#define COLcompatible(P1,P2) {                                         \
-       ERRORcheck(P1 == NULL, "COLcompatible: COL required\n");        \
-       ERRORcheck(P2 == NULL, "COLcompatible: COL required\n");        \
-       if (TYPEerror(COLtype(P1),COLtype(P2)))                         \
-       {                                                               \
-               GDKerror("Incompatible operands.\n");                   \
-               return 0;                                               \
-       }                                                               \
-       if (COLtype(P1) != COLtype(P2) &&                               \
-           ATOMtype((P1)->type) != ATOMtype((P2)->type)) {             \
-               CHECKDEBUG THRprintf(GDKout,"#Interpreting %s as %s.\n", \
-                       ATOMname(COLtype(P2)), ATOMname(COLtype(P1)));  \
-       }                                                               \
-}
+#define TYPEcastable(t1, t2)   (ATOMtype(t1) == ATOMtype(t2))
+#define TYPEequal(t1, t2)      (ATOMtype(t1) == ATOMtype(t2))
+#define TYPEcomp(t1,t2)        (ATOMstorage(ATOMtype(t1)) == 
ATOMstorage(ATOMtype(t2)))
+#define TYPEerror(t1, t2)      (!TYPEcomp(t1, t2))
+#define TYPEcheck(t1, t2)                                              \
+       do {                                                            \
+               if (TYPEerror(t1, t2)) {                                \
+                       GDKerror("TYPEcheck: Incompatible types %s and %s.\n", \
+                               ATOMname(t2), ATOMname(t1));            \
+                       return 0;                                       \
+               } else if (!TYPEcomp(t1, t2)) {                         \
+                       CHECKDEBUG THRprintf(GDKout,                    \
+                                            "#Interpreting %s as %s.\n", \
+                                            ATOMname(t2), ATOMname(t1)); \
+               }                                                       \
+       } while (0)
+#define COLcompatible(P1, P2)                                          \
+       do {                                                            \
+               ERRORcheck((P1) == NULL, "COLcompatible: COL required\n"); \
+               ERRORcheck((P2) == NULL, "COLcompatible: COL required\n"); \
+               if (TYPEerror(COLtype(P1),COLtype(P2)))                 \
+               {                                                       \
+                       GDKerror("Incompatible operands.\n");           \
+                       return 0;                                       \
+               }                                                       \
+               if (COLtype(P1) != COLtype(P2) &&                       \
+                   ATOMtype((P1)->type) != ATOMtype((P2)->type)) {     \
+                       CHECKDEBUG THRprintf(GDKout,                    \
+                                            "#Interpreting %s as %s.\n", \
+                                            ATOMname(COLtype(P2)),     \
+                                            ATOMname(COLtype(P1)));    \
+               }                                                       \
+       } while (0)
 
 typedef struct {
        size_t maxsize;         /* maximum realloc size (bytes) */
@@ -628,8 +630,8 @@
 
        char storage;           /* storage mode (mmap/malloc). */
        unsigned int copied:1,  /* a copy of an existing map. */
-                     hashash:1,/* the string heap contains hash values */
-                     forcemap:1;  /* force STORE_MMAP even if heap exists */
+               hashash:1,      /* the string heap contains hash values */
+               forcemap:1;     /* force STORE_MMAP even if heap exists */
        chr newstorage;         /* new desired storage mode at re-allocation. */
        chr dirty;              /* specific heap dirty marker */
        bat parentid;           /* cache id of VIEW parent bat */
@@ -721,7 +723,6 @@
                chr cval[4];
                flt fval;
                ptr pval;
-               struct COL *Bval;       /* this field is only used by mel */
                bat bval;
                batrec br;      /* bval + stamp */
                str sval;
@@ -840,7 +841,7 @@
        unsigned short width;   /* byte-width of the atom array */
        chr type;               /* type id. */
        chr shift;              /* log2 of bunwidth */
-       unsigned int 
+       unsigned int
         varsized:1,            /* varsized(>0) or fixedsized(0). */
         key:2,                 /* duplicates allowed? */
         dense:1,
@@ -1469,19 +1470,19 @@
 #endif
 
 #if SIZEOF_VAR_T == 8
-#define VarHeapValRaw(b,p,w)                                           \
-       ((w)==1 ? (var_t)((unsigned char *)(b))[p]+GDK_VAROFFSET :      \
-        ((w)==2 ? (var_t)((unsigned short *)(b))[p]+GDK_VAROFFSET :    \
+#define VarHeapValRaw(b, p, w)                                         \
+       ((w)==1 ? (var_t)((unsigned char *)(b))[p] + GDK_VAROFFSET :    \
+        ((w)==2 ? (var_t)((unsigned short *)(b))[p] + GDK_VAROFFSET :  \
          ((w)==4 ? (var_t)((unsigned int *)(b))[p] :                   \
           ((var_t *)(b))[p])))
 #else
-#define VarHeapValRaw(b,p,w)                                           \
-       ((w)==1 ? (var_t)((unsigned char *)(b))[p]+GDK_VAROFFSET :      \
-        ((w)==2 ? (var_t)((unsigned short *)(b))[p]+GDK_VAROFFSET :    \
+#define VarHeapValRaw(b, p, w)                                         \
+       ((w)==1 ? (var_t)((unsigned char *)(b))[p] + GDK_VAROFFSET :    \
+        ((w)==2 ? (var_t)((unsigned short *)(b))[p] + GDK_VAROFFSET :  \
          ((var_t *)(b))[p]))
 #endif
-#define VarHeapVal(b,p,w) ((size_t) VarHeapValRaw(b,p,w) << GDK_VARSHIFT)
-#define BUNvaroff(bi,p) VarHeapVal((bi).b->heap.base, (p), (bi).b->width)
+#define VarHeapVal(b, p, w) ((size_t) VarHeapValRaw(b,p,w) << GDK_VARSHIFT)
+#define BUNvaroff(bi, p) VarHeapVal((bi).b->heap.base, (p), (bi).b->width)
 
 #define BUNloc(bi,p)   COLelement((bi).b,p)
 #define BUNpos(bi,p)   ((bi).vid = (bi).b->seqbase + ((bi).b->seqbase == 
oid_nil ? 0 : (p) - (bi).b->first), (char *) &(bi).vid)
@@ -1577,7 +1578,7 @@
  * A special mode is append-only. It is then allowed to insert BUNs
  * at the end of the COL, but not to modify anything that already
  * was in there.
- * The COLsetreadmode operation sets COL_READ but also checks for newly added 
+ * The COLsetreadmode operation sets COL_READ but also checks for newly added
  * and dirty columns.
  */
 gdk_export str COLrename(COL *b, const char *nme);
@@ -2612,9 +2613,6 @@
 #define THRset_errbuf(t,b)     (t->data[2] = b)
 
 #ifndef GDK_NOLINK
-/* #ifdef __cplusplus */
-/*     extern "C" { */
-/* #endif */
 
 static inline bat
 CBPcheck(register bat x, register const char *y)
@@ -2644,9 +2642,6 @@
        return b;
 }
 
-/* #ifdef __cplusplus */
-/*     } */
-/* #endif */
 #endif
 
 /*
@@ -2989,9 +2984,9 @@
  * p is the iteration variable.
  */
 #define COLloop(r, p, q) \
-       for(q = COLlast(r), p = COLfirst(r);p < q; p++)
+       for (q = COLlast(r), p = COLfirst(r); p < q; p++)
 
-#define COLforloop(b, o) for( o = 0; o < b->count; o++)
+#define COLforloop(b, o) for (o = 0; o < b->count; o++)
 
 /*
  * batloop where the current element can be deleted/updated
@@ -3005,9 +3000,10 @@
  * After the delete/update has taken place, the pointer p is in an
  * inconsistent state till the next iteration of the batloop starts.
  */
-#define COLloopDEL(r, p, q)                            \
-       for(p = COLfirst(r), q = COLlast(r); p < q;     \
-           q = MIN(q,COLlast(r)), p++)
+#define COLloopDEL(r, p, q)                    \
+       for (p = COLfirst(r), q = COLlast(r);   \
+            p < q;                             \
+            q = MIN(q, COLlast(r)), p++)
 
 /*
  * sequential scan over deleted BUNs
@@ -3017,7 +3013,7 @@
  * inspect these data items.
  * Again, the b is a COL, p and q are BUNs, where p is the iteration variable.
  */
-#define DELloop(b, p, q)                                               \
+#define DELloop(b, p, q)                                       \
        for (q = (b)->first, p = (b)->deleted; p < q; p++)
 
 /*
@@ -3029,16 +3025,20 @@
  * head column of `b'). The 'hb' is an integer index, pointing out the
  * `hb'-th oid.
  */
-#define GDK_STREQ(l,r) (*(char*) (l) == *(char*) (r) && !strcmp(l,r))
+#define GDK_STREQ(l, r) (*(char*) (l) == *(char*) (r) && strcmp(l, r) == 0)
 
 #define HASHloop(bi, h, hb, v)                                         \
-       for (hb = h->hash[HASHprobe(h, v)]; hb != BUN_NONE; hb = h->link[hb])   
\
+       for (hb = h->hash[HASHprobe(h, v)]; hb != BUN_NONE; hb = h->link[hb]) \
                if (ATOMcmp(h->type, v, BUNhead(bi, hb)) == 0)
 #define HASHloop_str_hv(bi, h, hb, v)                          \
-       for (hb = (h)->hash[((oid *) (v))[-1]&(h)->mask]; hb != BUN_NONE; hb = 
(h)->link[hb]) \
+       for (hb = (h)->hash[((oid *) (v))[-1]&(h)->mask];       \
+            hb != BUN_NONE;                                    \
+            hb = (h)->link[hb])                                \
                if (GDK_STREQ(v, BUNvar(bi, hb)))
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to