Changeset: 74658f8b16ba for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=74658f8b16ba
Added Files:
        gdk/gdk_search.c
        gdk/gdk_search.h
Removed Files:
        gdk/gdk_search.mx
Modified Files:
        gdk/Makefile.ag
        gdk/gdk_private.h
        gdk/gdk_relop.mx
Branch: default
Log Message:

De-mx gdk_search.
The type-specific interfaces for SORTfnd, SORTfndfirst, and
SORTfndlast are gone, but the code itself still uses type-specific
inner loops.


diffs (truncated from 970 to 300 lines):

diff --git a/gdk/Makefile.ag b/gdk/Makefile.ag
--- a/gdk/Makefile.ag
+++ b/gdk/Makefile.ag
@@ -35,8 +35,10 @@ lib_gdk = {
                gdk_scanselect_defs_fix.mx \
                gdk_scanselect_defs_var.mx \
                gdk_scanselect.mx gdk.h gdk_batop.c \
-               gdk_search.mx gdk_tm.c gdk_align.c gdk_bbp.c gdk_bbp.h \
-               gdk_heap.c gdk_setop.mx gdk_utils.c gdk_utils.h gdk_atoms.c 
gdk_atoms.h \
+               gdk_search.c gdk_search.h gdk_tm.c \
+               gdk_align.c gdk_bbp.c gdk_bbp.h \
+               gdk_heap.c gdk_setop.mx gdk_utils.c gdk_utils.h \
+               gdk_atoms.c gdk_atoms.h \
                gdk_qsort.c gdk_qsort_impl.h gdk_ssort.c gdk_ssort_impl.h \
                gdk_storage.c gdk_bat.c gdk_bat.h \
                gdk_delta.c gdk_relop.mx gdk_system.c gdk_value.c \
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -101,31 +101,6 @@ oid OIDread(str buf);
 oid OIDseed(oid seed);
 int oidWrite(oid *a, stream *s, size_t cnt);
 int OIDwrite(stream *fp);
-/* 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);
-BUN SORTfnd_lng(BAT *b, const void *v);
-BUN SORTfnd_loc(BAT *b, const void *v);
-BUN SORTfnd_sht(BAT *b, const void *v);
-BUN SORTfnd_var(BAT *b, const void *v);
-BUN SORTfndfirst_bte(BAT *b, const void *v);
-BUN SORTfndfirst_dbl(BAT *b, const void *v);
-BUN SORTfndfirst_flt(BAT *b, const void *v);
-BUN SORTfndfirst_int(BAT *b, const void *v);
-BUN SORTfndfirst_lng(BAT *b, const void *v);
-BUN SORTfndfirst_loc(BAT *b, const void *v);
-BUN SORTfndfirst_sht(BAT *b, const void *v);
-BUN SORTfndfirst_var(BAT *b, const void *v);
-BUN SORTfndlast_bte(BAT *b, const void *v);
-BUN SORTfndlast_dbl(BAT *b, const void *v);
-BUN SORTfndlast_flt(BAT *b, const void *v);
-BUN SORTfndlast_int(BAT *b, const void *v);
-BUN SORTfndlast_lng(BAT *b, const void *v);
-BUN SORTfndlast_loc(BAT *b, const void *v);
-BUN SORTfndlast_sht(BAT *b, const void *v);
-BUN SORTfndlast_var(BAT *b, const void *v);
 void strCleanHash(Heap *hp, int rebuild);
 int strCmpNoNil(const unsigned char *l, const unsigned char *r);
 int strElimDoubles(Heap *h);
@@ -175,8 +150,8 @@ extern MT_Lock MT_system_lock;
 #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); \
+       else for (p = simple_EQ(tl, &TYPE##_nil, TYPE) ? BUNfirst(b) : 
SORTfndfirst(b, tl), \
+                 q = simple_EQ(th, &TYPE##_nil, TYPE) ? BUNfirst(b) : 
SORTfndlast(b, th); \
                  p < q;                                                \
                  p++)
 
@@ -192,36 +167,11 @@ extern MT_Lock MT_system_lock;
 #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); \
+       else for (p = atom_EQ(tl, ATOMnilptr((b)->ttype), (b)->ttype) ? 
BUNfirst(b) : SORTfndfirst(b, tl), \
+                         q = atom_EQ(th, ATOMnilptr((b)->ttype), (b)->ttype) ? 
BUNfirst(b) : SORTfndlast(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++)
+#define SORTloop_var(b,p,q,tl,th) SORTloop_loc(b,p,q,tl,th)
 
-/* 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)
diff --git a/gdk/gdk_relop.mx b/gdk/gdk_relop.mx
--- a/gdk/gdk_relop.mx
+++ b/gdk/gdk_relop.mx
@@ -237,7 +237,7 @@ All Rights Reserved.
                                        /* use binary search after failed scan 
or if scanning is impossible (l not sorted) */
                                        if (r_scan < 0 || r_start < r_last) {
                                                /* if merge not ended (or if no 
merge at all) */
-                                               r_start = (BUN) 
SORTfndfirst_@4(rr, v1);
+                                               r_start = (BUN) 
SORTfndfirst(rr, v1);
                                        }
                                        if (r_start < r_last) {
                                                v2 = BUNh@3(ri, r_start);
@@ -2032,7 +2032,7 @@ BATnlthetajoin(BAT *l, BAT *r, int op, B
                BATloop(l, lp, lq) {
                        ptr v = BUNh@1(li, lp);
 
-                       if (!@3_EQ(v, nil, @2) && SORTfnd_@2(r, v) != BUN_NONE) 
{
+                       if (!@3_EQ(v, nil, @2) && SORTfnd(r, v) != BUN_NONE) {
                                bunfastins(bn, v, BUNtail(li, lp));
                        }
                }
@@ -3131,7 +3131,7 @@ BATmultijoin(int argc, BAT *argv[], RowF
 #define STDcmp(v1,v2)  (*cmp)(v1,v2)
 
        if (ATOMstorage(lead_col->b->htype) == ATOMstorage(TYPE_oid)) {
-               @:multijoin(hloc,OID,_oid,_oid)@
+               @:multijoin(hloc,OID,_oid)@
        } else {
                int (*cmp) (const void *, const void *) = 
BATatoms[lead_col->b->htype].atomCmp;
 
@@ -3258,7 +3258,7 @@ BATmultijoin(int argc, BAT *argv[], RowF
                                BUN last = BUNlast(b);
 
                                if (n->binsearch) {
-                                       n->cur = (BUN) 
SORTfndfirst@4(BATmirror(b), h);
+                                       n->cur = (BUN) 
SORTfndfirst(BATmirror(b), h);
                                        if (n->cur >= last)
                                                break;  /* NOT FOUND */
                                } else {
diff --git a/gdk/gdk_search.mx b/gdk/gdk_search.c
rename from gdk/gdk_search.mx
rename to gdk/gdk_search.c
--- a/gdk/gdk_search.mx
+++ b/gdk/gdk_search.c
@@ -1,25 +1,26 @@
-@/
-The contents of this file are subject to the MonetDB Public License
-Version 1.1 (the "License"); you may not use this file except in
-compliance with the License. You may obtain a copy of the License at
-http://www.monetdb.org/Legal/MonetDBLicense
+/*
+ * The contents of this file are subject to the MonetDB Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.monetdb.org/Legal/MonetDBLicense
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the MonetDB Database System.
+ *
+ * The Initial Developer of the Original Code is CWI.
+ * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+ * Copyright August 2008-2012 MonetDB B.V.
+ * All Rights Reserved.
+ */
 
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is the MonetDB Database System.
-
-The Initial Developer of the Original Code is CWI.
-Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
-Copyright August 2008-2012 MonetDB B.V.
-All Rights Reserved.
-@
-
-@f gdk_search
-
-@c
+/*
+ * @f gdk_search
+ *
+ */
 /*
  * @a M. L. Kersten, P. Boncz, N. Nes
  *
@@ -62,219 +63,6 @@ All Rights Reserved.
  *
  * @+ Interface Declarations
  */
-@h
-#ifndef _GDK_SEARCH_H_
-#define _GDK_SEARCH_H_
-/*
- * @+ Hash indexing
- *
- * This is a highly efficient implementation of simple bucket-chained
- * hashing.
- *
- * In the past, we used integer modulo for hashing, with bucket chains
- * of mean size 4.  This was shown to be inferior to direct hashing
- * with integer anding. The new implementation reflects this.
- */
-gdk_export void HASHremove(BAT *b);
-gdk_export void HASHdestroy(BAT *b);
-gdk_export BUN HASHprobe(Hash *h, const void *v);
-gdk_export BUN HASHlist(Hash *h, BUN i);
-
-#define mix_sht(X)            (((X)>>7)^(X))
-#define mix_int(X)            (((X)>>7)^((X)>>13)^((X)>>21)^(X))
-#define hash_loc(H,V)         hash_any(H,V)
-#define hash_var(H,V)         hash_any(H,V)
-#define hash_any(H,V)         (ATOMhash((H)->type, (V)) & (H)->mask)
-#define heap_hash_any(hp,H,V) ((hp) && (hp)->hashash ? ((BUN *) (V))[-1] & 
(H)->mask : hash_any(H,V))
-#define hash_bte(H,V)         ((BUN) (*(const unsigned char*) (V)) & (H)->mask)
-#define hash_sht(H,V)         ((BUN) mix_sht(*((const unsigned short*) (V))) & 
(H)->mask)
-#define hash_int(H,V)         ((BUN) mix_int(*((const unsigned int*) (V))) & 
(H)->mask)
-/* XXX return size_t-sized value for 8-byte oid? */
-#define hash_lng(H,V)         ((BUN) mix_int((unsigned int) (*(const lng *)(V) 
^ (*(lng *)(V) >> 32))) & (H)->mask)
-#if SIZEOF_OID == SIZEOF_INT
-#define hash_oid(H,V)         ((BUN) mix_int((unsigned int) *((const oid*) 
(V))) & (H)->mask)
-#else
-#define hash_oid(H,V)         ((BUN) mix_int((unsigned int) (*(const oid *)(V) 
^ (*(const oid *)(V) >> 32))) & (H)->mask)
-#endif
-#if SIZEOF_WRD == SIZEOF_INT
-#define hash_wrd(H,V)         ((BUN) mix_int((unsigned int) *((const wrd*) 
(V))) & (H)->mask)
-#else
-#define hash_wrd(H,V)         ((BUN) mix_int((unsigned int) (*(const wrd *)(V) 
^ (*(const wrd *)(V) >> 32))) & (H)->mask)
-#endif
-
-#define hash_flt(H,V)         hash_int(H,V)
-#define hash_dbl(H,V)         hash_lng(H,V)
-
-#define HASHfnd_str(x,y,z)                                             \
-       do {                                                            \
-               BUN _i;                                                 \
-               (x) = BUN_NONE;                                         \
-               if ((y).b->H->hash || BAThash((y).b, 0) ||              \
-                   GDKfatal("HASHfnd_str: hash build failed on %s.\n", \
-                            BATgetId((y).b)))                          \
-                       HASHloop_str((y), (y).b->H->hash, _i, (z)) {    \
-                               (x) = _i;                               \
-                               break;                                  \
-                       }                                               \
-       } while (0)
-#define HASHfnd_str_hv(x,y,z)                                          \
-       do {                                                            \
-               BUN _i;                                                 \
-               (x) = BUN_NONE;                                         \
-               if ((y).b->H->hash || BAThash((y).b, 0) ||              \
-                   GDKfatal("HASHfnd_str_hv: hash build failed on %s.\n", \
-                            BATgetId((y).b)))                          \
-                       HASHloop_str_hv((y), (y).b->H->hash, _i, (z)) { \
-                               (x) = _i;                               \
-                               break;                                  \
-                       }                                               \
-       } while (0)
-#define HASHfnd(x,y,z)                                                 \
-       do {                                                            \
-               BUN _i;                                                 \
-               (x) = BUN_NONE;                                         \
-               if ((y).b->H->hash || BAThash((y).b, 0) ||              \
-                   GDKfatal("HASHfnd: hash build failed on %s.\n",     \
-                            BATgetId((y).b)))                          \
-                       HASHloop((y), (y).b->H->hash, _i, (z)) {        \
-                               (x) = _i;                               \
-                               break;                                  \
-                       }                                               \
-       } while (0)
-#define HASHfnd_TYPE(x,y,z,TYPE)                                       \
-       do {                                                            \
-               BUN _i;                                                 \
-               (x) = BUN_NONE;                                         \
-               if ((y).b->H->hash || BAThash((y).b, 0) ||              \
-                   GDKfatal("HASHfnd_" #TYPE ": hash build failed on %s.\n", \
-                            BATgetId((y).b)))                          \
-                       HASHloop_##TYPE((y), (y).b->H->hash, _i, (z)) { \
-                               (x) = _i;                               \
-                               break;                                  \
-                       }                                               \
-       } while (0)
-#define HASHfnd_bte(x,y,z)     HASHfnd_TYPE(x,y,z,bte)
-#define HASHfnd_sht(x,y,z)     HASHfnd_TYPE(x,y,z,sht)
-#define HASHfnd_int(x,y,z)     HASHfnd_TYPE(x,y,z,int)
-#define HASHfnd_lng(x,y,z)     HASHfnd_TYPE(x,y,z,lng)
-#define HASHfnd_oid(x,y,z)     HASHfnd_TYPE(x,y,z,oid)
-#define HASHfnd_wrd(x,y,z)     HASHfnd_TYPE(x,y,z,wrd)
-
-#if SIZEOF_VOID_P == SIZEOF_INT
-#define HASHfnd_ptr(x,y,z)     HASHfnd_int(x,y,z)
-#else /* SIZEOF_VOID_P == SIZEOF_LNG */
-#define HASHfnd_ptr(x,y,z)     HASHfnd_lng(x,y,z)
_______________________________________________
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to