Changeset: eaca160265ed for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=eaca160265ed
Modified Files:
        gdk/gdk.h
        gdk/gdk_aggr.c
        gdk/gdk_atoms.c
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        gdk/gdk_group.c
        gdk/gdk_select.c
        gdk/gdk_setop.c
        gdk/gdk_value.c
        monetdb5/mal/mal_instruction.c
        sql/storage/bat/bat_table.c
        sql/storage/store.c
        sql/test/BugTracker-2009/Tests/primekeyconstraint.SF-2783425.stable.err
Branch: default
Log Message:

merged changes from Oct2014


diffs (truncated from 872 to 300 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1359,6 +1359,12 @@ gdk_export bte ATOMelmshift(int sz);
                (b)->batCount++;                \
        } while (0)
 
+#define bunfastapp_nocheck_inc(b, p, t)                        \
+       do {                                            \
+               bunfastapp_nocheck(b, p, t, Tsize(b));  \
+               p++;                                    \
+       } while (0)
+
 #define bunfastapp(b, t)                                               \
        do {                                                            \
                register BUN _p = BUNlast(b);                           \
@@ -2594,7 +2600,8 @@ gdk_export BAT *BATattach(int tt, const 
 #define putenv _putenv
 #endif
 
-/* also see VALget */
+/* Return a pointer to the value contained in V.  Also see VALget
+ * which returns a void *. */
 static inline const void *
 VALptr(const ValRecord *v)
 {
@@ -3346,7 +3353,6 @@ gdk_export BAT *BATsample(BAT *b, BUN n)
 /*
  *
  */
-#define ILLEGALVALUE   ((ptr)-1L)
 #define MAXPARAMS      32
 
 #ifndef NDEBUG
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -1497,6 +1497,8 @@ BATgroupavg(BAT **bnp, BAT **cntsp, BAT 
                (*cntsp)->tkey = BATcount(*cntsp) <= 1;
                (*cntsp)->tsorted = BATcount(*cntsp) <= 1;
                (*cntsp)->trevsorted = BATcount(*cntsp) <= 1;
+               (*cntsp)->T->nil = 0;
+               (*cntsp)->T->nonil = 1;
        }
        BATsetcount(bn, ngrp);
        BATseqbase(bn, min);
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -348,11 +348,9 @@ ATOMformat(int t, const void *p, char **
 {
        int (*tostr) (str *, int *, const void *);
 
-       if (p && 0 <= t && t < GDKatomcnt &&
-           (tostr = BATatoms[t].atomToStr)) {
-               int sz = 0, l = (*tostr) (buf, &sz, p);
-
-               return l;
+       if (p && 0 <= t && t < GDKatomcnt && (tostr = BATatoms[t].atomToStr)) {
+               int sz = 0;
+               return (*tostr) (buf, &sz, p);
        }
        *buf = GDKmalloc(4);
        if (*buf == NULL)
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -967,35 +967,35 @@ BATcopy(BAT *b, int ht, int tt, int writ
        if (ATOMtype(ht) == ATOMtype(b->htype)) {
                ALIGNsetH(bn, b);
        } else if (ATOMtype(ATOMstorage(ht)) == 
ATOMtype(ATOMstorage(b->htype))) {
-               bn->hsorted = b->hsorted || (cnt <= 1 && 
BATatoms[b->htype].linear);
-               bn->hrevsorted = b->hrevsorted || (cnt <= 1 && 
BATatoms[b->htype].linear);
+               bn->hsorted = b->hsorted;
+               bn->hrevsorted = b->hrevsorted;
                bn->hdense = b->hdense && ATOMtype(bn->htype) == TYPE_oid;
                if (b->hkey)
                        BATkey(bn, TRUE);
                bn->H->nonil = b->H->nonil;
        } else {
-               bn->hsorted = bn->hrevsorted = (cnt <= 1 && 
BATatoms[b->htype].linear);
+               bn->hsorted = bn->hrevsorted = 0; /* set based on count later */
                bn->hdense = bn->H->nonil = 0;
        }
        if (ATOMtype(tt) == ATOMtype(b->ttype)) {
                ALIGNsetT(bn, b);
        } else if (ATOMtype(ATOMstorage(tt)) == 
ATOMtype(ATOMstorage(b->ttype))) {
-               bn->tsorted = b->tsorted || (cnt <= 1 && 
BATatoms[b->ttype].linear);
-               bn->trevsorted = b->trevsorted || (cnt <= 1 && 
BATatoms[b->ttype].linear);
+               bn->tsorted = b->tsorted;
+               bn->trevsorted = b->trevsorted;
                bn->tdense = b->tdense && ATOMtype(bn->ttype) == TYPE_oid;
                if (b->tkey)
                        BATkey(BATmirror(bn), TRUE);
                bn->T->nonil = b->T->nonil;
        } else {
-               bn->tsorted = bn->trevsorted = (cnt <= 1 && 
BATatoms[b->ttype].linear);
+               bn->tsorted = bn->trevsorted = 0; /* set based on count later */
                bn->tdense = bn->T->nonil = 0;
        }
        if (BATcount(bn) <= 1) {
-               bn->hsorted = 1;
-               bn->hrevsorted = 1;
+               bn->hsorted = BATatoms[b->htype].linear;
+               bn->hrevsorted = BATatoms[b->htype].linear;
                bn->hkey = 1;
-               bn->tsorted = 1;
-               bn->trevsorted = 1;
+               bn->tsorted = BATatoms[b->ttype].linear;
+               bn->trevsorted = BATatoms[b->ttype].linear;
                bn->tkey = 1;
        }
        if (writable != TRUE)
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -505,9 +505,11 @@ BATappend(BAT *b, BAT *n, bit force)
                                        return 0;
                                }
                                m = (oid) (f + sz);
+                               b = BATmirror(b); /* so we can use bunfastapp */
                                for (; f < m; f++, r++) {
-                                       bunfastins_nocheck(b, r, (ptr) &f, 
NULL, Hsize(b), 0);
+                                       bunfastapp_nocheck(b, r, (ptr) &f, 
Tsize(b));
                                }
+                               b = BATmirror(b);
                        } else {
                                sz += BATcount(b);
                                BATsetcount(b, sz);
@@ -893,10 +895,10 @@ BATslice(BAT *b, BUN l, BUN h)
                }
        }
        if (bn->batCount <= 1) {
-               bn->hsorted = 1;
-               bn->tsorted = 1;
-               bn->hrevsorted = 1;
-               bn->trevsorted = 1;
+               bn->hsorted = BATatoms[b->htype].linear;
+               bn->tsorted = BATatoms[b->ttype].linear;
+               bn->hrevsorted = BATatoms[b->htype].linear;
+               bn->trevsorted = BATatoms[b->ttype].linear;
                BATkey(bn, 1);
                BATkey(BATmirror(bn), 1);
        } else {
@@ -1207,7 +1209,7 @@ BATsubsort(BAT **sorted, BAT **order, BA
        if (order) {
                /* prepare order bat */
                if (o) {
-                       /* make copy of input so that we can refine it
+                       /* make copy of input so that we can refine it;
                         * copy can be read-only if we take the shortcut
                         * below in the case g is "key" */
                        on = BATcopy(o, TYPE_void, TYPE_oid,
@@ -1226,10 +1228,12 @@ BATsubsort(BAT **sorted, BAT **order, BA
                                grps[p] = p;
                        BATsetcount(on, BATcount(bn));
                        on->tkey = 1;
+                       on->T->nil = 0;
+                       on->T->nonil = 1;
                }
                BATseqbase(on, 0);
-               on->tsorted = on->trevsorted = 0;
-               on->tdense = 0;
+               on->tsorted = on->trevsorted = 0; /* it won't be sorted */
+               on->tdense = 0;                   /* and hence not dense */
                *order = on;
        }
        if (g) {
@@ -1241,8 +1245,24 @@ BATsubsort(BAT **sorted, BAT **order, BA
                        } else {
                                BBPunfix(bn->batCacheid);
                        }
-                       if (order)
+                       if (order) {
                                *order = on;
+                               if (o) {
+                                       /* we can inherit sortedness
+                                        * after all */
+                                       on->tsorted = o->tsorted;
+                                       on->trevsorted = o->trevsorted;
+                               } else {
+                                       /* we didn't rearrange, so
+                                        * still sorted */
+                                       on->tsorted = 1;
+                                       on->trevsorted = 0;
+                               }
+                               if (BATcount(on) <= 1) {
+                                       on->tsorted = 1;
+                                       on->trevsorted = 1;
+                               }
+                       }
                        if (groups) {
                                gn = BATcopy(g, TYPE_void, g->ttype, 0, 
TRANSIENT);
                                if (gn == NULL)
@@ -1546,7 +1566,7 @@ BATmark_grp(BAT *b, BAT *g, oid *s)
                                        return NULL;
                                r = BUNfirst(gc);
                                BATloop(g, p, q) {
-                                       bunfastins_nocheck_inc(gc, r, NULL, s);
+                                       bunfastapp_nocheck_inc(gc, r, s);
                                }
                        } else {
                                BATiter gi = bat_iterator(g);
diff --git a/gdk/gdk_group.c b/gdk/gdk_group.c
--- a/gdk/gdk_group.c
+++ b/gdk/gdk_group.c
@@ -877,9 +877,15 @@ BATgroup_internal(BAT **groups, BAT **ex
        if (histo) {
                BATsetcount(hn, (BUN) ngrp);
                BATseqbase(hn, 0);
-               hn->tkey = 0;
-               hn->tsorted = 0;
-               hn->trevsorted = 0;
+               if (BATcount(hn) <= 1) {
+                       hn->tkey = 1;
+                       hn->tsorted = 1;
+                       hn->trevsorted = 1;
+               } else {
+                       hn->tkey = 0;
+                       hn->tsorted = 0;
+                       hn->trevsorted = 0;
+               }
                hn->T->nonil = 1;
                hn->T->nil = 0;
                *histo = hn;
diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -122,6 +122,8 @@ doublerange(oid l1, oid h1, oid l2, oid 
        bn->tkey = 1;
        bn->tsorted = 1;
        bn->trevsorted = BATcount(bn) <= 1;
+       bn->T->nil = 0;
+       bn->T->nonil = 1;
        return bn;
 }
 
@@ -155,6 +157,8 @@ doubleslice(BAT *b, BUN l1, BUN h1, BUN 
        bn->tkey = 1;
        bn->tsorted = 1;
        bn->trevsorted = BATcount(bn) <= 1;
+       bn->T->nil = 0;
+       bn->T->nonil = 1;
        return virtualize(bn);
 }
 
@@ -208,14 +212,9 @@ BAT_hashselect(BAT *b, BAT *s, BAT *bn, 
        if (bn->batCount == 1)
                bn->tseqbase = *(oid *) Tloc(bn, BUNfirst(bn));
        /* temporarily set head to nil so that BATorder doesn't materialize */
-       bn->hseqbase = oid_nil;
-       bn->hkey = 0;
-       bn->hsorted = bn->hrevsorted = 1;
+       BATseqbase(bn, oid_nil);
        bn = BATmirror(BATorder(BATmirror(bn)));
-       bn->hseqbase = 0;
-       bn->hkey = 1;
-       bn->hsorted = 1;
-       bn->hrevsorted = bn->batCount <= 1;
+       BATseqbase(bn, 0);
        return bn;
 }
 
diff --git a/gdk/gdk_setop.c b/gdk/gdk_setop.c
--- a/gdk/gdk_setop.c
+++ b/gdk/gdk_setop.c
@@ -485,16 +485,20 @@ diff_intersect(BAT *l, BAT *r, int diff)
            BATcount(bn) == BATcount(r)) {
                ALIGNsetH(bn, r);
        }
-       bn->hsorted = BAThordered(l);
-       bn->hrevsorted = BAThrevordered(l);
-       bn->tsorted = BATtordered(l);
-       bn->trevsorted = BATtrevordered(l);
-       if (BATcount(bn)) {
+       if (BATcount(bn) <= 1) {
+               bn->hsorted = 1;
+               bn->hrevsorted = 1;
+               bn->tsorted = 1;
+               bn->trevsorted = 1;
+               BATkey(bn, TRUE);
+               BATkey(BATmirror(bn), TRUE);
+       } else {
+               bn->hsorted = BAThordered(l);
+               bn->hrevsorted = BAThrevordered(l);
+               bn->tsorted = BATtordered(l);
+               bn->trevsorted = BATtrevordered(l);
                BATkey(bn, BAThkey(l));
                BATkey(BATmirror(bn), BATtkey(l));
-       } else {
-               BATkey(bn, TRUE);
-               BATkey(BATmirror(bn), TRUE);
        }
        bn->H->nonil = l->H->nonil;
        bn->T->nonil = l->T->nonil;
diff --git a/gdk/gdk_value.c b/gdk/gdk_value.c
--- a/gdk/gdk_value.c
+++ b/gdk/gdk_value.c
@@ -50,6 +50,9 @@
 #include "gdk.h"
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to