Changeset: d4f4b96b756d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d4f4b96b756d
Modified Files:
gdk/gdk.h
gdk/gdk_atoms.h
gdk/gdk_batop.c
gdk/gdk_cbp.h
gdk/gdk_col.c
gdk/gdk_col.h
gdk/gdk_delta.h
gdk/gdk_inspect.c
gdk/gdk_logger.h
gdk/gdk_rangejoin.c
gdk/gdk_relop.c
gdk/gdk_search.c
gdk/gdk_setop.c
monetdb5/mal/mal_dataflow.c
monetdb5/mal/mal_interpreter.c
monetdb5/mal/mal_recycle.c
monetdb5/mal/mal_runtime.c
monetdb5/optimizer/opt_statistics.c
Branch: headless
Log Message:
Mostly cosmetics.
Use COLforloop for looping over a COL.
Don't use ABS for cacheid's: they're never negative.
diffs (truncated from 823 to 300 lines):
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -471,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
@@ -534,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 */
@@ -573,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) */
@@ -624,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 */
@@ -717,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;
@@ -836,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,
@@ -1465,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)
@@ -1573,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);
@@ -2979,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
@@ -2995,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
@@ -3007,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++)
/*
@@ -3019,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)))
-#define HASHloop_str(bi, h, hb, v) \
- for (hb = (h)->hash[strHash(v)&(h)->mask]; hb != BUN_NONE; hb =
(h)->link[hb]) \
+#define HASHloop_str(bi, h, hb, v) \
+ for (hb = (h)->hash[strHash(v)&(h)->mask]; \
+ hb != BUN_NONE; \
+ hb = (h)->link[hb]) \
if (GDK_STREQ(v, BUNvar(bi, hb)))
/*
* @-
@@ -3041,7 +3051,8 @@
*/
#define HASHloop_fstr(bi, h, hb, idx, v) \
for (hb = h->hash[strHash(v)&h->mask], idx =
strLocate((bi.b)->vheap,v); \
- hb != BUN_NONE; hb = h->link[hb]) \
+ hb != BUN_NONE; \
+ hb = h->link[hb]) \
if (VarHeapValRaw((bi).b->heap.base, hb, (bi).b->width) == idx)
/*
* The following example shows how the hashloop is used:
@@ -3309,9 +3320,3 @@
gdk_export ptr COLget(COL *b, oid o);
#endif /* _GDK_H_ */
-/*
- * @iftex
- * %\bibliographystyle{plain}
- * \bibliography{gdk}
- * @end iftex
- */
diff --git a/gdk/gdk_atoms.h b/gdk/gdk_atoms.h
--- a/gdk/gdk_atoms.h
+++ b/gdk/gdk_atoms.h
@@ -28,13 +28,13 @@
* of typechecks using Mx macros. To catch diverging code in one Mx macro
* we use the following #defines for comparing atoms:
*/
-#define simple_CMP(x,y,tpe) (simple_LT(x,y,tpe)?-1:simple_GT(x,y,tpe))
-#define simple_EQ(x,y,tpe) ((*(tpe*) (x)) == (*(tpe*) (y)))
-#define simple_NE(x,y,tpe,nl) ((*(tpe*)(y)) != nl && (*(tpe*) (x)) !=
(*(tpe*) (y)))
-#define simple_LT(x,y,tpe) ((*(tpe*) (x)) < (*(tpe*) (y)))
-#define simple_GT(x,y,tpe) ((*(tpe*) (x)) > (*(tpe*) (y)))
-#define simple_LE(x,y,tpe) ((*(tpe*) (x)) <= (*(tpe*) (y)))
-#define simple_GE(x,y,tpe) ((*(tpe*) (x)) >= (*(tpe*) (y)))
+#define simple_CMP(x,y,TYPE) (simple_LT(x,y,TYPE)?-1:simple_GT(x,y,TYPE))
+#define simple_EQ(x,y,TYPE) ((*(TYPE*) (x)) == (*(TYPE*) (y)))
+#define simple_NE(x,y,TYPE,nl) ((*(TYPE*)(y)) != nl && (*(TYPE*) (x)) !=
(*(TYPE*) (y)))
+#define simple_LT(x,y,TYPE) ((*(TYPE*) (x)) < (*(TYPE*) (y)))
+#define simple_GT(x,y,TYPE) ((*(TYPE*) (x)) > (*(TYPE*) (y)))
+#define simple_LE(x,y,TYPE) ((*(TYPE*) (x)) <= (*(TYPE*) (y)))
+#define simple_GE(x,y,TYPE) ((*(TYPE*) (x)) >= (*(TYPE*) (y)))
#define atom_CMP(x,y,id) (*COLatoms[id].atomCmp)(x,y)
#define atom_EQ(x,y,id) ((*COLatoms[id].atomCmp)(x,y) == 0)
#define atom_NE(x,y,id,nl)
((*COLatoms[id].atomCmp)(y,COLatoms[id].atomNull) != 0 &&
(*COLatoms[id].atomCmp)(x,y) != 0)
@@ -42,7 +42,7 @@
#define atom_GT(x,y,id) ((*COLatoms[id].atomCmp)(x,y) > 0)
#define atom_LE(x,y,id) ((*COLatoms[id].atomCmp)(x,y) <= 0)
#define atom_GE(x,y,id) ((*COLatoms[id].atomCmp)(x,y) >= 0)
-#define simple_HASH(v,tpe,dst) ((dst) *(tpe *) (v))
+#define simple_HASH(v,TYPE,dst) ((dst) *(TYPE *) (v))
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list