Changeset: 67c53af26ce0 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=67c53af26ce0
Modified Files:
clients/Tests/exports.stable.out
gdk/gdk.h
gdk/gdk_atoms.mx
gdk/gdk_private.h
gdk/gdk_search.mx
monetdb5/extras/crackers/crackers_joins.mx
monetdb5/extras/crackers/crackers_select_ops.mx
monetdb5/extras/crackers/crackers_sideways.mx
monetdb5/extras/crackers/crackers_sortmerge.mx
monetdb5/mal/mal_atom.c
monetdb5/modules/kernel/group.mx
monetdb5/modules/mal/mkey.c
Branch: default
Log Message:
Cleanup in gdk_search.mx.
- Reduce reliance on MX macros.
- Use const pointers where appropriate.
- Don't export type-specific SORTfnd functions, but just the generic
ond (it's a very thin layer).
- Reformat comments.
diffs (truncated from 1256 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
@@ -261,7 +261,7 @@ size_t GDKvm_heapsize(void);
void *GDKzalloc(size_t size);
void HASHdestroy(BAT *b);
BUN HASHlist(Hash *h, BUN i);
-BUN HASHprobe(Hash *h, ptr v);
+BUN HASHprobe(Hash *h, const void *v);
void HASHremove(BAT *b);
void HEAP_free(Heap *heap, var_t block);
void HEAP_initialize(Heap *heap, size_t nbytes, size_t nprivate, int
alignment);
@@ -299,30 +299,9 @@ int OIDfromStr(const char *src, int *len
oid OIDnew(oid inc);
int OIDtoStr(str *dst, int *len, const oid *src);
void PROPdestroy(PROPrec *p);
-BUN SORTfnd_bte(BAT *b, ptr v);
-BUN SORTfnd_dbl(BAT *b, ptr v);
-BUN SORTfnd_flt(BAT *b, ptr v);
-BUN SORTfnd_int(BAT *b, ptr v);
-BUN SORTfnd_lng(BAT *b, ptr v);
-BUN SORTfnd_loc(BAT *b, ptr v);
-BUN SORTfnd_sht(BAT *b, ptr v);
-BUN SORTfnd_var(BAT *b, ptr v);
-BUN SORTfndfirst_bte(BAT *b, ptr v);
-BUN SORTfndfirst_dbl(BAT *b, ptr v);
-BUN SORTfndfirst_flt(BAT *b, ptr v);
-BUN SORTfndfirst_int(BAT *b, ptr v);
-BUN SORTfndfirst_lng(BAT *b, ptr v);
-BUN SORTfndfirst_loc(BAT *b, ptr v);
-BUN SORTfndfirst_sht(BAT *b, ptr v);
-BUN SORTfndfirst_var(BAT *b, ptr v);
-BUN SORTfndlast_bte(BAT *b, ptr v);
-BUN SORTfndlast_dbl(BAT *b, ptr v);
-BUN SORTfndlast_flt(BAT *b, ptr v);
-BUN SORTfndlast_int(BAT *b, ptr v);
-BUN SORTfndlast_lng(BAT *b, ptr v);
-BUN SORTfndlast_loc(BAT *b, ptr v);
-BUN SORTfndlast_sht(BAT *b, ptr v);
-BUN SORTfndlast_var(BAT *b, ptr v);
+BUN SORTfnd(BAT *b, const void *v);
+BUN SORTfndfirst(BAT *b, const void *v);
+BUN SORTfndlast(BAT *b, const void *v);
void *THRdata[16];
void THRdel(Thread t);
Thread THRget(int tid);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -2138,7 +2138,7 @@ typedef struct {
void *(*atomRead) (ptr a, stream *s, size_t cnt);
int (*atomWrite) (ptr a, stream *s, size_t cnt);
int (*atomCmp) (const void *v1, const void *v2);
- BUN (*atomHash) (ptr v);
+ BUN (*atomHash) (const void *v);
/* optional functions */
void (*atomConvert) (ptr v, int direction);
int (*atomFix) (ptr atom);
@@ -3078,60 +3078,6 @@ gdk_export int ALIGNsetH(BAT *b1, BAT *b
p < q; \
p++)
-#define SORTloop_TYPE(b, p, q, tl, th, TYPE) \
- if (!BATtordered(b)) \
- GDKerror("SORTloop_" #TYPE ": BAT not sorted.\n"); \
- else for (p = simple_EQ(tl, &TYPE##_nil, TYPE) ? BUNfirst(b) :
SORTfndfirst_##TYPE(b, tl), \
- q = simple_EQ(th, &TYPE##_nil, TYPE) ? BUNfirst(b) :
SORTfndlast_##TYPE(b, th); \
- p < q; \
- p++)
-
-#define SORTloop_bte(b, p, q, tl, th) SORTloop_TYPE(b, p, q, tl, th, bte)
-#define SORTloop_sht(b, p, q, tl, th) SORTloop_TYPE(b, p, q, tl, th, sht)
-#define SORTloop_int(b, p, q, tl, th) SORTloop_TYPE(b, p, q, tl, th, int)
-#define SORTloop_lng(b, p, q, tl, th) SORTloop_TYPE(b, p, q, tl, th, lng)
-#define SORTloop_flt(b, p, q, tl, th) SORTloop_TYPE(b, p, q, tl, th, flt)
-#define SORTloop_dbl(b, p, q, tl, th) SORTloop_TYPE(b, p, q, tl, th, dbl)
-#define SORTloop_oid(b, p, q, tl, th) SORTloop_TYPE(b, p, q, tl, th, oid)
-#define SORTloop_wrd(b, p, q, tl, th) SORTloop_TYPE(b, p, q, tl, th, wrd)
-
-#define SORTloop_loc(b,p,q,tl,th) \
- if (!BATtordered(b)) \
- GDKerror("SORTloop_loc: BAT not sorted.\n"); \
- else for (p = atom_EQ(tl, ATOMnilptr((b)->ttype), (b)->ttype) ?
BUNfirst(b) : SORTfndfirst_loc(b, tl), \
- q = atom_EQ(th, ATOMnilptr((b)->ttype), (b)->ttype) ?
BUNfirst(b) : SORTfndlast_loc(b, th); \
- p < q; \
- p++)
-
-#define SORTloop_var(b,p,q,tl,th) \
- if (!BATtordered(b)) \
- GDKerror("SORTloop_var: BAT not sorted.\n"); \
- else for (p = atom_EQ(tl, ATOMnilptr((b)->ttype), (b)->ttype) ?
BUNfirst(b) : SORTfndfirst_var(b, tl), \
- q = atom_EQ(th, ATOMnilptr((b)->ttype), (b)->ttype) ?
BUNfirst(b) : SORTfndlast_var(b, th); \
- p < q; \
- p++)
-
-/* OIDDEPEND */
-#if SIZEOF_OID == SIZEOF_INT
-#define SORTfnd_oid(b,v) SORTfnd_int(b,v)
-#define SORTfndfirst_oid(b,v) SORTfndfirst_int(b,v)
-#define SORTfndlast_oid(b,v) SORTfndlast_int(b,v)
-#else
-#define SORTfnd_oid(b,v) SORTfnd_lng(b,v)
-#define SORTfndfirst_oid(b,v) SORTfndfirst_lng(b,v)
-#define SORTfndlast_oid(b,v) SORTfndlast_lng(b,v)
-#endif
-#if SIZEOF_WRD == SIZEOF_INT
-#define SORTfnd_wrd(b,v) SORTfnd_int(b,v)
-#define SORTfndfirst_wrd(b,v) SORTfndfirst_int(b,v)
-#define SORTfndlast_wrd(b,v) SORTfndlast_int(b,v)
-#else
-#define SORTfnd_wrd(b,v) SORTfnd_lng(b,v)
-#define SORTfndfirst_wrd(b,v) SORTfndfirst_lng(b,v)
-#define SORTfndlast_wrd(b,v) SORTfndlast_lng(b,v)
-#endif
-#define SORTloop_bit(b,p,q,tl,th) SORTloop_bte(b,p,q,tl,th)
-
/*
* @+ Common BAT Operations
* Much used, but not necessarily kernel-operations on BATs.
diff --git a/gdk/gdk_atoms.mx b/gdk/gdk_atoms.mx
--- a/gdk/gdk_atoms.mx
+++ b/gdk/gdk_atoms.mx
@@ -372,7 +372,7 @@ ATOMproperty(str id, str property, GDKfc
if (strcmp("cmp", property) == 0) {
atomset(BATatoms[t].atomCmp, (int (*)(const void *,
const void *)) arg);
} else if (strcmp("hash", property) == 0) {
- atomset(BATatoms[t].atomHash, (BUN (*)(void *)) arg);
+ atomset(BATatoms[t].atomHash, (BUN (*)(const void *))
arg);
} else if (strcmp("length", property) == 0) {
atomset(BATatoms[t].atomLen, (int (*)(void *)) arg);
}
@@ -2091,13 +2091,13 @@ atomDesc BATatoms[MAXATOMS] = {
(int (*)(const char *, int *, ptr *)) OIDfromStr, (int (*)(str *, int
*, const void *)) OIDtoStr,
(void *(*)(void *, stream *, size_t)) voidRead, (int (*)(void *,
stream *, size_t)) voidWrite,
(int (*)(const void *, const void *)) intCmp,
- (BUN (*)(ptr)) intHash, 0,
+ (BUN (*)(const void *)) intHash, 0,
#else
TYPE_void, 1, 0, /* sizeof(void) */ 0, 0, 1, (ptr) &lng_nil,
(int (*)(const char *, int *, ptr *)) OIDfromStr, (int (*)(str *, int
*, const void *)) OIDtoStr,
(void *(*)(void *, stream *, size_t)) voidRead, (int (*)(void *,
stream *, size_t)) voidWrite,
(int (*)(const void *, const void *)) lngCmp,
- (BUN (*)(ptr)) lngHash, 0,
+ (BUN (*)(const void *)) lngHash, 0,
#endif
0, 0,
0, 0,
@@ -2107,7 +2107,7 @@ atomDesc BATatoms[MAXATOMS] = {
(int (*)(const char *, int *, ptr *)) bitFromStr, (int (*)(str *, int
*, const void *)) bitToStr,
(void *(*)(void *, stream *, size_t)) bitRead, (int (*)(void *, stream
*, size_t)) bitWrite,
(int (*)(const void *, const void *)) bteCmp,
- (BUN (*)(ptr)) bteHash, 0,
+ (BUN (*)(const void *)) bteHash, 0,
0, 0,
0, 0,
0, 0,
@@ -2116,7 +2116,7 @@ atomDesc BATatoms[MAXATOMS] = {
(int (*)(const char *, int *, ptr *)) bteFromStr, (int (*)(str *, int
*, const void *)) bteToStr,
(void *(*)(void *, stream *, size_t)) bteRead, (int (*)(void *, stream
*, size_t)) bteWrite,
(int (*)(const void *, const void *)) bteCmp,
- (BUN (*)(ptr)) bteHash, 0,
+ (BUN (*)(const void *)) bteHash, 0,
0, 0,
0, 0,
0, 0,
@@ -2125,7 +2125,7 @@ atomDesc BATatoms[MAXATOMS] = {
(int (*)(const char *, int *, ptr *)) shtFromStr, (int (*)(str *, int
*, const void *)) shtToStr,
(void *(*)(void *, stream *, size_t)) shtRead, (int (*)(void *, stream
*, size_t)) shtWrite,
(int (*)(const void *, const void *)) shtCmp,
- (BUN (*)(ptr)) shtHash, (void (*)(ptr, int)) shtConvert,
+ (BUN (*)(const void *)) shtHash, (void (*)(ptr, int)) shtConvert,
0, 0,
0, 0,
0, 0,
@@ -2134,7 +2134,7 @@ atomDesc BATatoms[MAXATOMS] = {
(int (*)(const char *, int *, ptr *)) batFromStr, (int (*)(str *, int
*, const void *)) batToStr,
(void *(*)(void *, stream *, size_t)) batRead, (int (*)(void *, stream
*, size_t)) batWrite,
(int (*)(const void *, const void *)) intCmp,
- (BUN (*)(ptr)) intHash, (void (*)(ptr, int)) intConvert,
+ (BUN (*)(const void *)) intHash, (void (*)(ptr, int)) intConvert,
(int (*)(ptr)) batFix, (int (*)(ptr)) batUnfix,
0, 0,
0, 0,
@@ -2143,7 +2143,7 @@ atomDesc BATatoms[MAXATOMS] = {
(int (*)(const char *, int *, ptr *)) intFromStr, (int (*)(str *, int
*, const void *)) intToStr,
(void *(*)(void *, stream *, size_t)) intRead, (int (*)(void *, stream
*, size_t)) intWrite,
(int (*)(const void *, const void *)) intCmp,
- (BUN (*)(ptr)) intHash, (void (*)(ptr, int)) intConvert,
+ (BUN (*)(const void *)) intHash, (void (*)(ptr, int)) intConvert,
0, 0,
0, 0,
0, 0,
@@ -2154,13 +2154,13 @@ atomDesc BATatoms[MAXATOMS] = {
(int (*)(const char *, int *, ptr *)) OIDfromStr, (int (*)(str *, int
*, const void *)) OIDtoStr,
(void *(*)(void *, stream *, size_t)) intRead, (int (*)(void *, stream
*, size_t)) intWrite,
(int (*)(const void *, const void *)) intCmp,
- (BUN (*)(ptr)) intHash, (void (*)(ptr, int)) intConvert,
+ (BUN (*)(const void *)) intHash, (void (*)(ptr, int)) intConvert,
#else
TYPE_lng, 1, sizeof(oid), sizeof(oid), 0, 0, (ptr) &lng_nil,
(int (*)(const char *, int *, ptr *)) OIDfromStr, (int (*)(str *, int
*, const void *)) OIDtoStr,
(void *(*)(void *, stream *, size_t)) lngRead, (int (*)(void *, stream
*, size_t)) lngWrite,
(int (*)(const void *, const void *)) lngCmp,
- (BUN (*)(ptr)) lngHash, (void (*)(ptr, int)) lngConvert,
+ (BUN (*)(const void *)) lngHash, (void (*)(ptr, int)) lngConvert,
#endif
0, 0,
0, 0,
@@ -2172,13 +2172,13 @@ atomDesc BATatoms[MAXATOMS] = {
(int (*)(const char *, int *, ptr *)) intFromStr, (int (*)(str *, int
*, const void *)) intToStr,
(void *(*)(void *, stream *, size_t)) intRead, (int (*)(void *, stream
*, size_t)) intWrite,
(int (*)(const void *, const void *)) intCmp,
- (BUN (*)(ptr)) intHash, (void (*)(ptr, int)) intConvert,
+ (BUN (*)(const void *)) intHash, (void (*)(ptr, int)) intConvert,
#else
TYPE_lng, 1, sizeof(wrd), sizeof(wrd), 0, 0, (ptr) &lng_nil,
(int (*)(const char *, int *, ptr *)) lngFromStr, (int (*)(str *, int
*, const void *)) lngToStr,
(void *(*)(void *, stream *, size_t)) lngRead, (int (*)(void *, stream
*, size_t)) lngWrite,
(int (*)(const void *, const void *)) lngCmp,
- (BUN (*)(ptr)) lngHash, (void (*)(ptr, int)) lngConvert,
+ (BUN (*)(const void *)) lngHash, (void (*)(ptr, int)) lngConvert,
#endif
0, 0,
0, 0,
@@ -2190,13 +2190,13 @@ atomDesc BATatoms[MAXATOMS] = {
(int (*)(const char *, int *, ptr *)) ptrFromStr, (int (*)(str *, int
*, const void *)) ptrToStr,
(void *(*)(void *, stream *, size_t)) ptrRead, (int (*)(void *, stream
*, size_t)) ptrWrite,
(int (*)(const void *, const void *)) intCmp,
- (BUN (*)(ptr)) intHash, (void (*)(ptr, int)) intConvert,
+ (BUN (*)(const void *)) intHash, (void (*)(ptr, int)) intConvert,
#else /* SIZEOF_VOID_P == SIZEOF_LNG */
TYPE_ptr, 1, sizeof(ptr), sizeof(ptr), 0, 0, (ptr) &ptr_nil,
(int (*)(const char *, int *, ptr *)) ptrFromStr, (int (*)(str *, int
*, const void *)) ptrToStr,
(void *(*)(void *, stream *, size_t)) ptrRead, (int (*)(void *, stream
*, size_t)) ptrWrite,
(int (*)(const void *, const void *)) lngCmp,
- (BUN (*)(ptr)) lngHash, (void (*)(ptr, int)) lngConvert,
+ (BUN (*)(const void *)) lngHash, (void (*)(ptr, int)) lngConvert,
#endif
0, 0,
0, 0,
@@ -2206,7 +2206,7 @@ atomDesc BATatoms[MAXATOMS] = {
(int (*)(const char *, int *, ptr *)) fltFromStr, (int (*)(str *, int
*, const void *)) fltToStr,
(void *(*)(void *, stream *, size_t)) fltRead, (int (*)(void *, stream
*, size_t)) fltWrite,
(int (*)(const void *, const void *)) fltCmp,
- (BUN (*)(ptr)) intHash, (void (*)(ptr, int)) intConvert,
+ (BUN (*)(const void *)) intHash, (void (*)(ptr, int)) intConvert,
0, 0,
0, 0,
0, 0,
@@ -2215,7 +2215,7 @@ atomDesc BATatoms[MAXATOMS] = {
(int (*)(const char *, int *, ptr *)) dblFromStr, (int (*)(str *, int
*, const void *)) dblToStr,
(void *(*)(void *, stream *, size_t)) dblRead, (int (*)(void *, stream
*, size_t)) dblWrite,
(int (*)(const void *, const void *)) dblCmp,
- (BUN (*)(ptr)) lngHash, (void (*)(ptr, int)) lngConvert,
+ (BUN (*)(const void *)) lngHash, (void (*)(ptr, int)) lngConvert,
0, 0,
0, 0,
0, 0,
@@ -2224,7 +2224,7 @@ atomDesc BATatoms[MAXATOMS] = {
(int (*)(const char *, int *, ptr *)) lngFromStr, (int (*)(str *, int
*, const void *)) lngToStr,
(void *(*)(void *, stream *, size_t)) lngRead, (int (*)(void *, stream
*, size_t)) lngWrite,
(int (*)(const void *, const void *)) lngCmp,
- (BUN (*)(ptr)) lngHash, (void (*)(ptr, int)) lngConvert,
+ (BUN (*)(const void *)) lngHash, (void (*)(ptr, int)) lngConvert,
0, 0,
0, 0,
0, 0,
@@ -2233,7 +2233,7 @@ atomDesc BATatoms[MAXATOMS] = {
(int (*)(const char *, int *, ptr *)) strFromStr, (int (*)(str *, int
*, const void *)) strToStr,
(void *(*)(void *, stream *, size_t)) strRead, (int (*)(void *, stream
*, size_t)) strWrite,
(int (*)(const void *, const void *)) strCmp,
- (BUN (*)(ptr)) strHash, 0,
+ (BUN (*)(const void *)) strHash, 0,
0, 0,
(var_t (*)(Heap *, var_t *, ptr)) strPut, 0,
(int (*)(ptr)) strLen, strHeap,
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -89,7 +89,7 @@ void *GDKvmalloc(size_t size, size_t * m
void GDKvmfree(void *blk, size_t size, size_t maxsize);
void GDKvminc(size_t len);
void *GDKvmrealloc(void *pold, size_t oldsize, size_t newsize, size_t oldmax,
size_t *maxsize, int emergency);
-int HASHgonebad(BAT *b, ptr v);
+int HASHgonebad(BAT *b, const void *v);
BUN HASHmask(BUN cnt);
Hash *HASHnew(Heap *hp, int tpe, BUN size, BUN mask);
int HEAPalloc(Heap *h, size_t nitems, size_t itemsize);
@@ -123,9 +123,31 @@ oid OIDread(str buf);
oid OIDseed(oid seed);
int oidWrite(oid *a, stream *s, size_t cnt);
int OIDwrite(stream *fp);
-BUN SORTfnd(BAT *b, ptr v);
-BUN SORTfndfirst(BAT *b, ptr v);
-BUN SORTfndlast(BAT *b, ptr v);
+/* type specific binary search implementations */
+BUN SORTfnd_bte(BAT *b, const void *v);
+BUN SORTfnd_dbl(BAT *b, const void *v);
+BUN SORTfnd_flt(BAT *b, const void *v);
+BUN SORTfnd_int(BAT *b, const void *v);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list