Changeset: b68d23e2fc22 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b68d23e2fc22
Modified Files:
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        gdk/gdk_bbp.c
        gdk/gdk_heap.c
        gdk/gdk_private.h
        gdk/gdk_string.c
        monetdb5/optimizer/opt_dataflow.c
        testing/sqllogictest.py
Branch: default
Log Message:

Merge with Jul2021 branch.


diffs (truncated from 2072 to 300 lines):

diff --git a/clients/examples/C/bincopydata.c b/clients/examples/C/bincopydata.c
--- a/clients/examples/C/bincopydata.c
+++ b/clients/examples/C/bincopydata.c
@@ -183,7 +183,7 @@ gen_newline_strings(FILE *f, bool bytesw
 {
        (void)byteswap;
        for (long i = 0; i < nrecs; i++) {
-               fprintf(f, "rn\r\nr\r%ld", i);
+               fprintf(f, "RN\r\nR\r%ld", i);
                fputc(0, f);
        }
 }
diff --git a/common/utils/mcrypt.c b/common/utils/mcrypt.c
--- a/common/utils/mcrypt.c
+++ b/common/utils/mcrypt.c
@@ -514,7 +514,6 @@ mcrypt_hashPassword(
                return NULL;
        }
 
-#if (defined(HAVE_OPENSSL) || defined(HAVE_COMMONCRYPTO))
        snprintf(ret, sizeof(ret),
                        "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
                        "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
@@ -542,7 +541,6 @@ mcrypt_hashPassword(
        ret[len] = '\0';
 
        return strdup(ret);
-#endif
 }
 
 #ifndef HAVE_SHA512_UPDATE
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -526,7 +526,6 @@ gdk_return
 BATextend(BAT *b, BUN newcap)
 {
        size_t theap_size;
-       gdk_return rc = GDK_SUCCEED;
 
        assert(newcap <= BUN_MAX);
        BATcheck(b, GDK_FAIL);
@@ -554,21 +553,9 @@ BATextend(BAT *b, BUN newcap)
        if (b->theap->base) {
                TRC_DEBUG(HEAP, "HEAPgrow in BATextend %s %zu %zu\n",
                          b->theap->filename, b->theap->size, theap_size);
-               MT_lock_set(&b->theaplock);
-               if (ATOMIC_GET(&b->theap->refs) == 1) {
-                       rc = HEAPextend(b->theap, theap_size, b->batRestricted 
== BAT_READ);
-               } else {
-                       MT_lock_unset(&b->theaplock);
-                       Heap *h = HEAPgrow(b->theap, theap_size);
-                       if (h == NULL)
-                               return GDK_FAIL;
-                       MT_lock_set(&b->theaplock);
-                       HEAPdecref(b->theap, false);
-                       b->theap = h;
-               }
-               MT_lock_unset(&b->theaplock);
+               return HEAPgrow(&b->theaplock, &b->theap, theap_size, 
b->batRestricted == BAT_READ);
        }
-       return rc;
+       return GDK_SUCCEED;
 }
 
 
@@ -1014,148 +1001,6 @@ COLcopy(BAT *b, int tt, bool writable, r
        return NULL;
 }
 
-static void
-setcolprops(BAT *b, const void *x)
-{
-       bool isnil = b->ttype != TYPE_void &&
-               ATOMnilptr(b->ttype) != NULL &&
-               ATOMcmp(b->ttype, x, ATOMnilptr(b->ttype)) == 0;
-       BATiter bi;
-       BUN pos;
-       const void *prv;
-       int cmp;
-
-       /* x may only be NULL if the column type is VOID */
-       assert(x != NULL || b->ttype == TYPE_void);
-       if (b->batCount == 0) {
-               /* first value */
-               b->tsorted = b->trevsorted = ATOMlinear(b->ttype);
-               b->tnosorted = b->tnorevsorted = 0;
-               b->tkey = true;
-               b->tnokey[0] = b->tnokey[1] = 0;
-               if (b->ttype == TYPE_void) {
-                       if (x) {
-                               b->tseqbase = * (const oid *) x;
-                       }
-                       b->tnil = is_oid_nil(b->tseqbase);
-                       b->tnonil = !b->tnil;
-               } else {
-                       b->tnil = isnil;
-                       b->tnonil = !isnil;
-                       if (b->ttype == TYPE_oid) {
-                               b->tseqbase = * (const oid *) x;
-                       }
-                       if (!isnil && ATOMlinear(b->ttype)) {
-                               BATsetprop(b, GDK_MAX_VALUE, b->ttype, x);
-                               BATsetprop(b, GDK_MIN_VALUE, b->ttype, x);
-                               BATsetprop(b, GDK_MAX_POS, TYPE_oid, &(oid){0});
-                               BATsetprop(b, GDK_MIN_POS, TYPE_oid, &(oid){0});
-                       }
-               }
-               return;
-       } else if (b->ttype == TYPE_void) {
-               /* not the first value in a VOID column: we keep the
-                * seqbase, and x is not used, so only some properties
-                * are affected */
-               if (!is_oid_nil(b->tseqbase)) {
-                       if (b->trevsorted) {
-                               b->tnorevsorted = BUNlast(b);
-                               b->trevsorted = false;
-                       }
-                       b->tnil = false;
-                       b->tnonil = true;
-               } else {
-                       if (b->tkey) {
-                               b->tnokey[0] = 0;
-                               b->tnokey[1] = BUNlast(b);
-                               b->tkey = false;
-                       }
-                       b->tnil = true;
-                       b->tnonil = false;
-               }
-               return;
-       } else if (ATOMlinear(b->ttype)) {
-               const ValRecord *prop;
-
-               bi = bat_iterator_nolock(b);
-               pos = BUNlast(b);
-               prv = BUNtail(bi, pos - 1);
-               cmp = ATOMcmp(b->ttype, prv, x);
-
-               if (b->tkey &&
-                   (cmp == 0 || /* definitely not KEY */
-                    (b->batCount > 1 && /* can't guarantee KEY if unordered */
-                     ((b->tsorted && cmp > 0) ||
-                      (b->trevsorted && cmp < 0) ||
-                      (!b->tsorted && !b->trevsorted))))) {
-                       b->tkey = false;
-                       if (cmp == 0) {
-                               b->tnokey[0] = pos - 1;
-                               b->tnokey[1] = pos;
-                       }
-               }
-               if (b->tsorted) {
-                       if (cmp > 0) {
-                               /* out of order */
-                               b->tsorted = false;
-                               b->tnosorted = pos;
-                       } else if (cmp < 0 && !isnil) {
-                               /* new largest value */
-                               BATsetprop(b, GDK_MAX_VALUE, b->ttype, x);
-                               BATsetprop(b, GDK_MAX_POS, TYPE_oid, 
&(oid){BATcount(b)});
-                       }
-               } else if (!isnil &&
-                          (prop = BATgetprop(b, GDK_MAX_VALUE)) != NULL &&
-                          ATOMcmp(b->ttype, VALptr(prop), x) < 0) {
-                       BATsetprop(b, GDK_MAX_VALUE, b->ttype, x);
-                       BATsetprop(b, GDK_MAX_POS, TYPE_oid, 
&(oid){BATcount(b)});
-               }
-               if (b->trevsorted) {
-                       if (cmp < 0) {
-                               /* out of order */
-                               b->trevsorted = false;
-                               b->tnorevsorted = pos;
-                               /* if there is a nil in the BAT, it is
-                                * the smallest, but that doesn't
-                                * count for the property, so the new
-                                * value may still be smaller than the
-                                * smallest non-nil so far */
-                               if (!b->tnonil && !isnil &&
-                                   (prop = BATgetprop(b, GDK_MIN_VALUE)) != 
NULL &&
-                                   ATOMcmp(b->ttype, VALptr(prop), x) > 0) {
-                                       BATsetprop(b, GDK_MIN_VALUE, b->ttype, 
x);
-                                       BATsetprop(b, GDK_MIN_POS, TYPE_oid, 
&(oid){BATcount(b)});
-                               }
-                       } else if (cmp > 0 && !isnil) {
-                               /* new smallest value */
-                               BATsetprop(b, GDK_MIN_VALUE, b->ttype, x);
-                               BATsetprop(b, GDK_MIN_POS, TYPE_oid, 
&(oid){BATcount(b)});
-                       }
-               } else if (!isnil &&
-                          (prop = BATgetprop(b, GDK_MIN_VALUE)) != NULL &&
-                          ATOMcmp(b->ttype, VALptr(prop), x) > 0) {
-                       BATsetprop(b, GDK_MIN_VALUE, b->ttype, x);
-                       BATsetprop(b, GDK_MIN_POS, TYPE_oid, 
&(oid){BATcount(b)});
-               }
-               if (BATtdense(b) && (cmp >= 0 || * (const oid *) prv + 1 != * 
(const oid *) x)) {
-                       assert(b->ttype == TYPE_oid);
-                       b->tseqbase = oid_nil;
-               }
-       } else if (BATcount(b) == 1) {
-               /* we'll only check keyness with a single other value */
-               bi = bat_iterator_nolock(b);
-               prv = BUNtail(bi, 0);
-               b->tkey = ATOMcmp(b->ttype, prv, x) != 0;
-       } else {
-               /* no guarantees that we don't have duplicates */
-               b->tkey = false;
-       }
-       if (isnil) {
-               b->tnonil = false;
-               b->tnil = true;
-       }
-}
-
 /* Append an array of values of length count to the bat.  For
  * fixed-sized values, `values' is an array of values, for
  * variable-sized values, `values' is an array of pointers to values.
@@ -1220,15 +1065,107 @@ BUNappendmulti(BAT *b, const void *value
        }
 
        BATrmprop(b, GDK_UNIQUE_ESTIMATE);
-       b->theap->dirty |= count > 0;
+       b->theap->dirty = true;
+       const void *t = b->ttype == TYPE_msk ? &(msk){false} : 
ATOMnilptr(b->ttype);
+       if (b->ttype == TYPE_oid) {
+               /* spend extra effort on oid (possible candidate list) */
+               if (values == NULL || is_oid_nil(((oid *) values)[0])) {
+                       b->tnil = true;
+                       b->tnonil = false;
+                       b->tsorted = false;
+                       b->trevsorted = false;
+                       b->tkey = false;
+                       b->tseqbase = oid_nil;
+               } else {
+                       if (b->batCount == 0) {
+                               b->tsorted = true;
+                               b->trevsorted = true;
+                               b->tkey = true;
+                               b->tseqbase = ((oid *) values)[0];
+                               b->tnil = false;
+                               b->tnonil = true;
+                       } else {
+                               if (!is_oid_nil(b->tseqbase) &&
+                                   b->tseqbase + b->batCount + 1 != ((oid *) 
values)[0])
+                                       b->tseqbase = oid_nil;
+                               if (b->tsorted && ((oid *) 
b->theap->base)[b->batCount - 1] > ((oid *) values)[0]) {
+                                       b->tsorted = false;
+                                       if (b->tnosorted == 0)
+                                               b->tnosorted = b->batCount;
+                               }
+                               if (b->trevsorted && ((oid *) 
b->theap->base)[b->batCount - 1] < ((oid *) values)[0]) {
+                                       b->trevsorted = false;
+                                       if (b->tnorevsorted == 0)
+                                               b->tnorevsorted = b->batCount;
+                               }
+                               if (b->tkey) {
+                                       if (((oid *) 
b->theap->base)[b->batCount - 1] == ((oid *) values)[0]) {
+                                               b->tkey = false;
+                                               if (b->tnokey[1] == 0) {
+                                                       b->tnokey[0] = 
b->batCount - 1;
+                                                       b->tnokey[1] = 
b->batCount;
+                                               }
+                                       } else if (!b->tsorted && 
!b->trevsorted)
+                                               b->tkey = false;
+                               }
+                       }
+                       for (BUN i = 1; i < count; i++) {
+                               if (is_oid_nil(((oid *) values)[i])) {
+                                       b->tnil = true;
+                                       b->tnonil = false;
+                                       b->tsorted = false;
+                                       b->trevsorted = false;
+                                       b->tkey = false;
+                                       b->tseqbase = oid_nil;
+                                       break;
+                               }
+                               if (((oid *) values)[i - 1] == ((oid *) 
values)[i]) {
+                                       b->tkey = false;
+                                       if (b->tnokey[1] == 0) {
+                                               b->tnokey[0] = b->batCount + i 
- 1;
+                                               b->tnokey[1] = b->batCount + i;
+                                       }
+                               } else if (((oid *) values)[i - 1] > ((oid *) 
values)[i]) {
+                                       b->tsorted = false;
+                                       if (b->tnosorted == 0)
+                                               b->tnosorted = b->batCount + i;
+                                       if (!b->trevsorted)
+                                               b->tkey = false;
+                               } else {
+                                       if (((oid *) values)[i - 1] + 1 != 
((oid *) values)[i])
+                                               b->tseqbase = oid_nil;
+                                       b->trevsorted = false;
+                                       if (b->tnorevsorted == 0)
+                                               b->tnorevsorted = b->batCount + 
i;
+                                       if (!b->tsorted)
+                                               b->tkey = false;
+                               }
+                       }
+               }
+       } else if (!ATOMlinear(b->ttype)) {
+               b->tnil = b->tnonil = false;
+               b->tsorted = b->trevsorted = b->tkey = false;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to