Changeset: 19775df76ede for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=19775df76ede
Modified Files:
        gdk/gdk_aggr.c
        sql/server/rel_rel.c
        sql/storage/store.c
Branch: default
Log Message:

Merge with Jun2016 branch.


diffs (73 lines):

diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -1542,7 +1542,7 @@ BATgroupavg(BAT **bnp, BAT **cntsp, BAT 
                        n++;                                            \
                }                                                       \
                /* the sum fit, so now we can calculate the average */  \
-               *avg = (dbl) sum / n;                                   \
+               *avg = n > 0 ? (dbl) sum / n : dbl_nil;                 \
                if (0) {                                                \
                  overflow##TYPE:                                       \
                        /* we get here if sum(x[0],...,x[i]) doesn't */ \
@@ -1551,6 +1551,9 @@ BATgroupavg(BAT **bnp, BAT **cntsp, BAT 
                        /* the rest of the calculation is done */       \
                        /* according to the loop invariant described */ \
                        /* in the below loop */                         \
+                       /* note that n necessarily is > 0 (else no */   \
+                       /* overflow possible) */                        \
+                       assert(n > 0);                                  \
                        if (sum >= 0) {                                 \
                                a = (TYPE) (sum / (lng_hge) n); /* this fits */ 
\
                                r = (BUN) (sum % (SBUN) n);             \
@@ -1566,24 +1569,25 @@ BATgroupavg(BAT **bnp, BAT **cntsp, BAT 
                        if (cand)                                       \
                                --cand;                                 \
                                                                        \
-                       for (; i < end; i++) {                          \
+                       for (;;) {                                      \
                                /* loop invariant: */                   \
                                /* a + r/n == average(x[0],...,x[n]); */ \
-                               /* 0 <= r < n (if n > 0) */             \
-                               /* or if n == 0: a == 0; r == 0 */      \
+                               /* 0 <= r < n */                        \
                                if (cand) {                             \
-                                       if (i < *cand - b->hseqbase)    \
-                                               continue;               \
-                                       assert(i == *cand - b->hseqbase); \
-                                       if (++cand == candend)          \
-                                               end = i + 1;            \
+                                       if (cand == candend)            \
+                                               break;                  \
+                                       i = *cand++ - b->hseqbase;      \
+                               } else {                                \
+                                       i = start++;                    \
                                }                                       \
+                               if (i >= end)                           \
+                                       break;                          \
                                x = ((const TYPE *) src)[i];            \
                                if (x == TYPE##_nil)                    \
                                        continue;                       \
                                AVERAGE_ITER(TYPE, x, a, r, n);         \
                        }                                               \
-                       *avg = n > 0 ? a + (dbl) r / n : dbl_nil;       \
+                       *avg = a + (dbl) r / n;                         \
                }                                                       \
        } while (0)
 
diff --git a/sql/server/rel_rel.c b/sql/server/rel_rel.c
--- a/sql/server/rel_rel.c
+++ b/sql/server/rel_rel.c
@@ -1074,6 +1074,12 @@ rel_or(mvc *sql, sql_rel *l, sql_rel *r,
                rel_destroy(r);
                append(nl, e);
                l->exps = nl;
+               if (ll->op == l->op) {
+                       list_merge(ll->exps,l->exps, (fdup)NULL);
+                       l->l = NULL;
+                       rel_destroy(l);
+                       return ll;
+               }
                return l;
        }
        l = rel_project(sql->sa, l, rel_projections(sql, l, NULL, 1, 1));
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to