Changeset: 5a5648b9ef69 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5a5648b9ef69
Added Files:
        sql/test/Tests/fsum1.sql.src
        sql/test/Tests/fsum1.stable.err.src
        sql/test/Tests/fsum1.stable.out.src
        sql/test/mergetables/Tests/sqlsmith.Bug-6451.sql
        sql/test/mergetables/Tests/sqlsmith.Bug-6451.stable.err
        sql/test/mergetables/Tests/sqlsmith.Bug-6451.stable.out
        sql/test/mergetables/Tests/sqlsmith.Bug-6453.sql
        sql/test/mergetables/Tests/sqlsmith.Bug-6453.stable.err
        sql/test/mergetables/Tests/sqlsmith.Bug-6453.stable.out
        sql/test/mergetables/Tests/sqlsmith.Bug-6455.sql
        sql/test/mergetables/Tests/sqlsmith.Bug-6455.stable.err
        sql/test/mergetables/Tests/sqlsmith.Bug-6455.stable.out
Modified Files:
        clients/Tests/exports.stable.out
        gdk/gdk.h
        gdk/gdk_aggr.c
        gdk/gdk_atoms.c
        gdk/gdk_atoms.h
        gdk/gdk_bat.c
        gdk/gdk_group.c
        gdk/gdk_hash.c
        gdk/gdk_join.c
        gdk/gdk_orderidx.c
        sql/server/rel_dump.c
        sql/server/rel_optimizer.c
        sql/server/rel_rel.c
        sql/server/rel_select.c
        sql/test/Tests/All
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
        sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
        sql/test/mergetables/Tests/All
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: trails
Log Message:

Merge with default


diffs (truncated from 19631 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
@@ -10,7 +10,6 @@ void ALIGNsetH(BAT *b1, BAT *b2);
 void ALIGNsetT(BAT *b1, BAT *b2);
 int ALIGNsynced(BAT *b1, BAT *b2);
 int ATOMallocate(const char *nme);
-int ATOMcmp(int id, const void *v_1, const void *v_2);
 ptr ATOMdup(int id, const void *val);
 bte ATOMelmshift(int sz);
 char *ATOMformat(int id, const void *val);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1791,7 +1791,7 @@ gdk_export BAT *BBPquickdesc(bat b, int 
  * value. `val' is a direct pointer to the atom value. Its return
  * value should be an hash_t between 0 and 'mask'.
  *
- * @item The @emph{ATOMcmp()} operation computes two atomic
+ * @item The @emph{ATOMcmp()} operation compares two atomic
  * values. Its parameters are pointers to atomic values.
  *
  * @item The @emph{ATOMlen()} operation computes the byte length for a
@@ -1892,7 +1892,6 @@ gdk_export int ATOMindex(const char *nme
 gdk_export str ATOMname(int id);
 gdk_export size_t ATOMlen(int id, const void *v);
 gdk_export ptr ATOMnil(int id);
-gdk_export int ATOMcmp(int id, const void *v_1, const void *v_2);
 gdk_export int ATOMprint(int id, const void *val, stream *fd);
 gdk_export char *ATOMformat(int id, const void *val);
 
@@ -2769,7 +2768,7 @@ gdk_export void ALIGNsetT(BAT *b1, BAT *
        for (hb = HASHget(h, hash_##TYPE(h, v));                \
             hb != HASHnil(h);                                  \
             hb = HASHgetlink(h,hb))                            \
-               if (simple_EQ(v, BUNtloc(bi, hb), TYPE))
+               if (* (const TYPE *) v == * (const TYPE *) BUNtloc(bi, hb))
 
 #define HASHloop_bte(bi, h, hb, v)     HASHloop_TYPE(bi, h, hb, v, bte)
 #define HASHloop_sht(bi, h, hb, v)     HASHloop_TYPE(bi, h, hb, v, sht)
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -152,9 +152,13 @@ BATgroupaggrinit(BAT *b, BAT *g, BAT *e,
 /* sum */
 
 #if defined(_MSC_VER) && _MSC_VER < 1800
+#ifndef isnan
 #define isnan(x)       _isnan(x)
+#endif
+#ifndef isinf
 #define isinf(x)       (_fpclass(x) & (_FPCLASS_NINF | _FPCLASS_PINF))
 #endif
+#endif
 
 static inline int
 samesign(double x, double y)
@@ -186,6 +190,7 @@ exchange(double *x, double *y)
        *y = t;
 }
 
+/* this function was adapted from https://bugs.python.org/file10357/msum4.py */
 static BUN
 dofsum(const void *restrict values, oid seqb, BUN start, BUN end,
        void *restrict results, BUN ngrp, int tp1, int tp2,
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -34,45 +34,45 @@
 static int
 bteCmp(const bte *l, const bte *r)
 {
-       return simple_CMP(l, r, bte);
+       return (*l > *r) - (*l < *r);
 }
 
 static int
 shtCmp(const sht *l, const sht *r)
 {
-       return simple_CMP(l, r, sht);
+       return (*l > *r) - (*l < *r);
 }
 
 static int
 intCmp(const int *l, const int *r)
 {
-       return simple_CMP(l, r, int);
+       return (*l > *r) - (*l < *r);
 }
 
 static int
 fltCmp(const flt *l, const flt *r)
 {
-       return simple_CMP(l, r, flt);
+       return (*l > *r) - (*l < *r);
 }
 
 static int
 lngCmp(const lng *l, const lng *r)
 {
-       return simple_CMP(l, r, lng);
+       return (*l > *r) - (*l < *r);
 }
 
 #ifdef HAVE_HGE
 static int
 hgeCmp(const hge *l, const hge *r)
 {
-       return simple_CMP(l, r, hge);
+       return (*l > *r) - (*l < *r);
 }
 #endif
 
 static int
 dblCmp(const dbl *l, const dbl *r)
 {
-       return simple_CMP(l, r, dbl);
+       return (*l > *r) - (*l < *r);
 }
 
 /*
@@ -282,31 +282,6 @@ ATOMheap(int t, Heap *hp, size_t cap)
        return GDK_SUCCEED;
 }
 
-int
-ATOMcmp(int t, const void *l, const void *r)
-{
-       switch (ATOMbasetype(t)) {
-       case TYPE_bte:
-               return simple_CMP(l, r, bte);
-       case TYPE_sht:
-               return simple_CMP(l, r, sht);
-       case TYPE_int:
-               return simple_CMP(l, r, int);
-       case TYPE_flt:
-               return simple_CMP(l, r, flt);
-       case TYPE_lng:
-               return simple_CMP(l, r, lng);
-#ifdef HAVE_HGE
-       case TYPE_hge:
-               return simple_CMP(l, r, hge);
-#endif
-       case TYPE_dbl:
-               return simple_CMP(l, r, dbl);
-       default:
-               return (l == r) ? 0 : atom_CMP(l, r, t);
-       }
-}
-
 /*
  * Atom print avoids coercion to strings for built-in types.
  * The comparison against the NULL value is hard coded for speed.
diff --git a/gdk/gdk_atoms.h b/gdk/gdk_atoms.h
--- a/gdk/gdk_atoms.h
+++ b/gdk/gdk_atoms.h
@@ -12,30 +12,6 @@
 #define MAXATOMS       128
 
 /*
- * @- comparison macro's
- * In order to get maximum performance, we extensively use
- * out-factoring of type checks using CPP macros. To catch diverging
- * code in one CPP macro we use the following #defines for comparing
- * atoms:
- */
-#define simple_CMP(x,y,tpe)    (simple_GT(x,y,tpe) - simple_LT(x,y,tpe))
-#define simple_EQ(x,y,tpe)     ((*(const tpe*) (x)) == (*(const tpe*) (y)))
-#define simple_NE(x,y,tpe,nl)  ((*(const tpe*)(y)) != nl && (*(const tpe*) 
(x)) != (*(const tpe*) (y)))
-#define simple_LT(x,y,tpe)     ((*(const tpe*) (x))  < (*(const tpe*) (y)))
-#define simple_GT(x,y,tpe)     ((*(const tpe*) (x))  > (*(const tpe*) (y)))
-#define simple_LE(x,y,tpe)     ((*(const tpe*) (x)) <= (*(const tpe*) (y)))
-#define simple_GE(x,y,tpe)     ((*(const tpe*) (x)) >= (*(const tpe*) (y)))
-#define atom_CMP(x,y,id)       (*ATOMcompare(id))(x,y)
-#define atom_EQ(x,y,id)                ((*ATOMcompare(id))(x,y) == 0)
-#define atom_NE(x,y,id,nl)     ((*ATOMcompare(id))(y,ATOMnilptr(id)) != 0 && 
(*ATOMcompare(id))(x,y) != 0)
-#define atom_LT(x,y,id)                ((*ATOMcompare(id))(x,y) < 0)
-#define atom_GT(x,y,id)                ((*ATOMcompare(id))(x,y) > 0)
-#define atom_LE(x,y,id)                ((*ATOMcompare(id))(x,y) <= 0)
-#define atom_GE(x,y,id)                ((*ATOMcompare(id))(x,y) >= 0)
-#define simple_HASH(v,tpe,dst) ((dst) *(const tpe *) (v))
-#define atom_HASH(v,id,dst)    ((dst) ATOMhash(id, v))
-
-/*
  * @- maximum atomic string lengths
  */
 #define bitStrlen      8
@@ -188,6 +164,7 @@ gdk_export const ptr ptr_nil;
 #define ATOMfromstr(t,s,l,src) BATatoms[t].atomFromStr(src,l,s)
 #define ATOMnilptr(t)          BATatoms[t].atomNull
 #define ATOMcompare(t)         BATatoms[t].atomCmp
+#define ATOMcmp(t,l,r)         ((*ATOMcompare(t))(l, r))
 #define ATOMhash(t,src)                BATatoms[t].atomHash(src)
 #define ATOMdel(t,hp,src)      do if (BATatoms[t].atomDel) 
BATatoms[t].atomDel(hp,src); while (0)
 #define ATOMvarsized(t)                (BATatoms[t].atomPut != NULL)
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -910,7 +910,7 @@ static void
 setcolprops(BAT *b, const void *x)
 {
        int isnil = b->ttype != TYPE_void &&
-               atom_CMP(x, ATOMnilptr(b->ttype), b->ttype) == 0;
+               ATOMcmp(b->ttype, x, ATOMnilptr(b->ttype)) == 0;
        BATiter bi;
        BUN pos;
        const void *prv;
@@ -965,7 +965,7 @@ setcolprops(BAT *b, const void *x)
                bi = bat_iterator(b);
                pos = BUNlast(b);
                prv = BUNtail(bi, pos - 1);
-               cmp = atom_CMP(prv, x, b->ttype);
+               cmp = ATOMcmp(b->ttype, prv, x);
 
                if (!b->tunique && /* assume outside check if tunique */
                    b->tkey &&
@@ -1152,8 +1152,8 @@ BUNinplace(BAT *b, BUN p, const void *t,
 
        ALIGNinp(b, "BUNinplace", force, GDK_FAIL);     /* zap alignment info */
        if (b->tnil &&
-           atom_CMP(BUNtail(bi, p), ATOMnilptr(b->ttype), b->ttype) == 0 &&
-           atom_CMP(t, ATOMnilptr(b->ttype), b->ttype) != 0) {
+           ATOMcmp(b->ttype, BUNtail(bi, p), ATOMnilptr(b->ttype)) == 0 &&
+           ATOMcmp(b->ttype, t, ATOMnilptr(b->ttype)) != 0) {
                /* if old value is nil and new value isn't, we're not
                 * sure anymore about the nil property, so we must
                 * clear it */
@@ -1210,7 +1210,7 @@ BUNinplace(BAT *b, BUN p, const void *t,
        } else if (!b->tkey && (b->tnokey[0] == p || b->tnokey[1] == p))
                b->tnokey[0] = b->tnokey[1] = 0;
        if (b->tnonil)
-               b->tnonil = t && atom_CMP(t, ATOMnilptr(b->ttype), b->ttype) != 
0;
+               b->tnonil = t && ATOMcmp(b->ttype, t, ATOMnilptr(b->ttype)) != 
0;
        b->theap.dirty = TRUE;
        if (b->tvheap)
                b->tvheap->dirty = TRUE;
diff --git a/gdk/gdk_group.c b/gdk/gdk_group.c
--- a/gdk/gdk_group.c
+++ b/gdk/gdk_group.c
@@ -88,7 +88,7 @@
                        }                                               \
                }                                                       \
                if (extents)                                            \
-                       exts[ngrp] = hseqb + p;                         \
+                       exts[ngrp] = hseqb + p - lo;                    \
                if (histo)                                              \
                        cnts[ngrp] = 1;                                 \
                ngrps[r] = ngrp++;                                      \
@@ -545,6 +545,7 @@ BATgroup_internal(BAT **groups, BAT **ex
        bat parent;
 #endif
        BUN start, end, cnt;
+       BUN lo = 0;
        const oid *restrict cand, *candend;
        oid maxgrp = oid_nil;   /* maximum value of g BAT (if subgrouping) */
        PROPrec *prop;
@@ -1006,8 +1007,6 @@ BATgroup_internal(BAT **groups, BAT **ex
                       BATcheckhash(BBPdescriptor(parent)))
 #endif
                ) {
-               BUN lo;
-
                /* we already have a hash table on b, or b is
                 * persistent and we could create a hash table, or b
                 * is a view on a bat that already has a hash table */
@@ -1034,11 +1033,8 @@ BATgroup_internal(BAT **groups, BAT **ex
                        bi = bat_iterator(b);
                        start += lo;
                        end += lo;
-               } else
+               }
 #endif
-               {
-                       lo = 0;
-               }
                hs = b->thash;
                gn->tsorted = 1; /* be optimistic */
 
diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c
--- a/gdk/gdk_hash.c
+++ b/gdk/gdk_hash.c
@@ -273,44 +273,42 @@ BATcheckhash(BAT *b)
 }
 
 #ifdef PERSISTENTHASH
-struct hashsync {
-       Heap *hp;
-       bat id;
-};
-
 static void
 BAThashsync(void *arg)
 {
-       struct hashsync *hs = arg;
-       Heap *hp = hs->hp;
+       BAT *b = arg;
+       Heap *hp;
        int fd;
        lng t0 = 0;
        const char *failed = " failed";
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to