Changeset: e08b1857aa87 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e08b1857aa87
Modified Files:
        clients/Tests/exports.stable.out
        gdk/gdk.h
        gdk/gdk_private.h
        monetdb5/optimizer/opt_pipes.c
        sql/test/emptydb/Tests/check.stable.out
        sql/test/emptydb/Tests/check.stable.out.32bit
        sql/test/emptydb/Tests/check.stable.out.int128
Branch: string_imprints
Log Message:

Merge with default


diffs (truncated from 8929 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
@@ -233,6 +233,7 @@ gdk_return BUNreplacemulti(BAT *b, const
 gdk_return BUNreplacemultiincr(BAT *b, oid position, const void *values, BUN 
count, bool force) __attribute__((__warn_unused_result__));
 BAT *COLcopy(BAT *b, int tt, bool writable, role_t role);
 BAT *COLnew(oid hseq, int tltype, BUN capacity, role_t role) 
__attribute__((__warn_unused_result__));
+BAT *COLnew2(oid hseq, int tt, BUN cap, role_t role, uint16_t width) 
__attribute__((__warn_unused_result__));
 size_t GDK_mem_maxsize;
 size_t GDK_vm_maxsize;
 gdk_return GDKanalytical_correlation(BAT *r, BAT *p, BAT *o, BAT *b1, BAT *b2, 
BAT *s, BAT *e, int tpe, int frame_type);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1063,6 +1063,8 @@ gdk_export void HEAP_free(Heap *heap, va
  */
 gdk_export BAT *COLnew(oid hseq, int tltype, BUN capacity, role_t role)
        __attribute__((__warn_unused_result__));
+gdk_export BAT *COLnew2(oid hseq, int tt, BUN cap, role_t role, uint16_t width)
+       __attribute__((__warn_unused_result__));
 gdk_export BAT *BATdense(oid hseq, oid tseq, BUN cnt)
        __attribute__((__warn_unused_result__));
 gdk_export gdk_return BATextend(BAT *b, BUN newcap)
diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c
--- a/gdk/gdk_align.c
+++ b/gdk/gdk_align.c
@@ -255,7 +255,7 @@ BATmaterialize(BAT *b)
        b->tunique_est = is_oid_nil(t) ? 1.0 : (double) b->batCount;
        MT_lock_unset(&b->theaplock);
        b->ttype = TYPE_oid;
-       BATsetdims(b);
+       BATsetdims(b, 0);
        b->batDirtydesc = true;
        BATsetcount(b, b->batCount);
 
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -171,9 +171,9 @@ ATOMelmshift(int sz)
 
 
 void
-BATsetdims(BAT *b)
+BATsetdims(BAT *b, uint16_t width)
 {
-       b->twidth = b->ttype == TYPE_str ? 1 : ATOMsize(b->ttype);
+       b->twidth = b->ttype == TYPE_str ? width > 0 ? width : 1 : 
ATOMsize(b->ttype);
        b->tshift = ATOMelmshift(b->twidth);
        assert_shift_width(b->tshift, b->twidth);
        b->tvarsized = b->ttype == TYPE_void || BATatoms[b->ttype].atomPut != 
NULL;
@@ -204,6 +204,7 @@ settailname(Heap *restrict tail, const c
 {
        if (tt == TYPE_str) {
                switch (width) {
+               case 0:
                case 1:
                        strconcat_len(tail->filename,
                                      sizeof(tail->filename), physnme,
@@ -241,7 +242,7 @@ settailname(Heap *restrict tail, const c
  * filenames.
  */
 BAT *
-COLnew_intern(oid hseq, int tt, BUN cap, role_t role, uint16_t width)
+COLnew2(oid hseq, int tt, BUN cap, role_t role, uint16_t width)
 {
        BAT *bn;
 
@@ -268,20 +269,11 @@ COLnew_intern(oid hseq, int tt, BUN cap,
        if (bn == NULL)
                return NULL;
 
-       BATsetdims(bn);
+       BATsetdims(bn, width);
        bn->batCapacity = cap;
 
        if (ATOMstorage(tt) == TYPE_msk)
                cap /= 8;       /* 8 values per byte */
-       else if (tt == TYPE_str) {
-               if (width != 0) {
-                       /* power of two and not too large */
-                       assert((width & (width - 1)) == 0);
-                       assert(width <= sizeof(var_t));
-                       bn->twidth = width;
-               }
-               settailname(bn->theap, BBP_physical(bn->batCacheid), tt, 
bn->twidth);
-       }
 
        /* alloc the main heaps */
        if (tt && HEAPalloc(bn->theap, cap, bn->twidth, ATOMsize(bn->ttype)) != 
GDK_SUCCEED) {
@@ -313,7 +305,7 @@ COLnew_intern(oid hseq, int tt, BUN cap,
 BAT *
 COLnew(oid hseq, int tt, BUN cap, role_t role)
 {
-       return COLnew_intern(hseq, tt, cap, role, 0);
+       return COLnew2(hseq, tt, cap, role, 0);
 }
 
 BAT *
@@ -835,16 +827,15 @@ COLcopy(BAT *b, int tt, bool writable, r
                                slowcopy = true;
                }
 
-               bn = COLnew_intern(b->hseqbase, tt, bi.count, role, bi.width);
+               bn = COLnew2(b->hseqbase, tt, bi.count, role, bi.width);
                if (bn == NULL) {
                        bat_iterator_end(&bi);
                        return NULL;
                }
                if (bn->tvheap != NULL && bn->tvheap->base == NULL) {
                        /* this combination can happen since the last
-                        * argument of COLnew_intern not being zero
-                        * triggers a skip in the allocation of the
-                        * tvheap */
+                        * argument of COLnew2 not being zero triggers a
+                        * skip in the allocation of the tvheap */
                        if (ATOMheap(bn->ttype, bn->tvheap, bn->batCapacity) != 
GDK_SUCCEED) {
                                bat_iterator_end(&bi);
                                BBPreclaim(bn);
@@ -2787,4 +2778,3 @@ BATassertProps(BAT *b)
        }
        MT_lock_unset(&b->theaplock);
 }
-
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -87,7 +87,7 @@ void BATrmprop_nolock(BAT *b, enum prop_
        __attribute__((__visibility__("hidden")));
 gdk_return BATsave_locked(BAT *bd, BATiter *bi, BUN size)
        __attribute__((__visibility__("hidden")));
-void BATsetdims(BAT *b)
+void BATsetdims(BAT *b, uint16_t width)
        __attribute__((__visibility__("hidden")));
 ValPtr BATsetprop(BAT *b, enum prop_t idx, int type, const void *v)
        __attribute__((__visibility__("hidden")));
@@ -129,9 +129,6 @@ BUN binsearch_flt(const oid *restrict in
        __attribute__((__visibility__("hidden")));
 BUN binsearch_dbl(const oid *restrict indir, oid offset, const dbl *restrict 
vals, BUN lo, BUN hi, dbl v, int ordering, int last)
        __attribute__((__visibility__("hidden")));
-BAT *COLnew_intern(oid hseq, int tt, BUN cap, role_t role, uint16_t width)
-       __attribute__((__warn_unused_result__))
-       __attribute__((__visibility__("hidden")));
 Heap *createOIDXheap(BAT *b, bool stable)
        __attribute__((__visibility__("hidden")));
 void doHASHdestroy(BAT *b, Hash *hs)
diff --git a/gdk/gdk_project.c b/gdk/gdk_project.c
--- a/gdk/gdk_project.c
+++ b/gdk/gdk_project.c
@@ -710,7 +710,7 @@ BATproject2(BAT *restrict l, BAT *restri
                r1i = bat_iterator(r1);
                r2i = bat_iterator(r2);
        }
-       bn = COLnew_intern(l->hseqbase, ATOMtype(r1->ttype), lcount, TRANSIENT, 
stringtrick ? r1i.width : 0);
+       bn = COLnew2(l->hseqbase, ATOMtype(r1->ttype), lcount, TRANSIENT, 
stringtrick ? r1i.width : 0);
        if (bn == NULL) {
                goto doreturn;
        }
@@ -776,7 +776,7 @@ BATproject2(BAT *restrict l, BAT *restri
        /* handle string trick */
        if (stringtrick) {
                assert(r1i.vh);
-               if (r1->batRestricted == BAT_READ) {
+               if (r1->batRestricted == BAT_READ || VIEWvtparent(r1)) {
                        /* really share string heap */
                        assert(r1i.vh->parentid > 0);
                        BBPshare(r1i.vh->parentid);
@@ -965,7 +965,7 @@ BATprojectchain(BAT **bats)
        bi = bat_iterator(b);
        if (nonil && ATOMstorage(tpe) == TYPE_str && b->batRestricted == 
BAT_READ) {
                stringtrick = true;
-               bn = COLnew_intern(ba[0].hlo, tpe, ba[0].cnt, TRANSIENT, 
bi.width);
+               bn = COLnew2(ba[0].hlo, tpe, ba[0].cnt, TRANSIENT, bi.width);
                if (bn && bn->tvheap) {
                        /* no need to remove any files since they were
                         * never created for this bat */
diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c
--- a/monetdb5/mal/mal_profiler.c
+++ b/monetdb5/mal/mal_profiler.c
@@ -60,18 +60,17 @@ static struct rusage prevUsage;
 #define LOGLEN 8192
 
 // The heart beat events should be sent to all outstanding channels.
-static void logjsonInternal(char *logbuffer)
+static void logjsonInternal(char *logbuffer, bool flush)
 {
        size_t len;
        len = strlen(logbuffer);
 
-       MT_lock_set(&mal_profileLock);
        if (maleventstream) {
        // upon request the log record is sent over the profile stream
                (void) mnstr_write(maleventstream, logbuffer, 1, len);
-               (void) mnstr_flush(maleventstream, MNSTR_FLUSH_DATA);
+               if (flush)
+                       (void) mnstr_flush(maleventstream, MNSTR_FLUSH_DATA);
        }
-       MT_lock_unset(&mal_profileLock);
 }
 
 /*
@@ -141,7 +140,7 @@ logadd(struct logbuf *logbuf, const char
                        /* includes first time when logbuffer == NULL and 
logcap = 0 */
                        char *alloc_buff;
                        if (logbuf->loglen > 0)
-                               logjsonInternal(logbuf->logbuffer);
+                               logjsonInternal(logbuf->logbuffer, false);
                        logbuf->logcap = (size_t) tmp_len + (size_t) tmp_len/2;
                        if (logbuf->logcap < LOGLEN)
                                logbuf->logcap = LOGLEN;
@@ -156,7 +155,7 @@ logadd(struct logbuf *logbuf, const char
                        logbuf->logbuffer = alloc_buff;
                        lognew(logbuf);
                } else {
-                       logjsonInternal(logbuf->logbuffer);
+                       logjsonInternal(logbuf->logbuffer, false);
                        lognew(logbuf);
                }
        }
@@ -474,11 +473,13 @@ static void
 renderProfilerEvent(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, 
int start)
 {
        str ev;
+       MT_lock_set(&mal_profileLock);
        ev = prepareProfilerEvent(cntxt, mb, stk, pci, start);
        if( ev ){
-               logjsonInternal(ev);
+               logjsonInternal(ev, true);
                free(ev);
        }
+       MT_lock_unset(&mal_profileLock);
 }
 
 /* the OS details on cpu load are read from /proc/stat
@@ -614,7 +615,7 @@ profilerHeartbeatEvent(char *alter)
                                "}\n",                  // end marker
                                alter, cpuload))
                return;
-       logjsonInternal(logbuf.logbuffer);
+       logjsonInternal(logbuf.logbuffer, true);
        logdel(&logbuf);
 }
 
@@ -647,16 +648,19 @@ openProfilerStream(Client cntxt)
        getrusage(RUSAGE_SELF, &infoUsage);
        prevUsage = infoUsage;
 #endif
+       MT_lock_set(&mal_profileLock);
        if (myname == 0){
                myname = putName("profiler");
-               logjsonInternal(monet_characteristics);
+               logjsonInternal(monet_characteristics, true);
        }
        if(maleventstream){
                /* The DBA can always grab the stream, others have to wait */
-               if (cntxt->user == MAL_ADMIN)
+               if (cntxt->user == MAL_ADMIN) {
                        closeProfilerStream(cntxt);
-               else
+               } else {
+                       MT_lock_unset(&mal_profileLock);
                        throw(MAL,"profiler.start","Profiler already running, 
stream not available");
+               }
        }
        malProfileMode = -1;
        maleventstream = cntxt->fdout;
@@ -670,7 +674,6 @@ openProfilerStream(Client cntxt)
 
        MT_sleep_ms(200);
 
-       MT_lock_set(&mal_profileLock);
        for(j = 0; j <THREADS; j++){
                Client c = 0; MalBlkPtr m=0; MalStkPtr s = 0; InstrPtr p = 0;
                c = workingset[j].cntxt;
@@ -718,8 +721,8 @@ startProfiler(Client cntxt)
                myname = putName("profiler");
        }
        malProfileMode = 1;
+       logjsonInternal(monet_characteristics, true);
        MT_lock_unset(&mal_profileLock);
-       logjsonInternal(monet_characteristics);
        // reset the trace table
        clearTrace(cntxt);
 
diff --git a/monetdb5/modules/mal/remote.c b/monetdb5/modules/mal/remote.c
--- a/monetdb5/modules/mal/remote.c
+++ b/monetdb5/modules/mal/remote.c
@@ -726,17 +726,10 @@ RMTinternalcopyfrom(BAT **ret, char *hdr
                hdr++;
        }
 
-       b = COLnew(0, bb.Ttype, bb.size, TRANSIENT);
+       b = COLnew2(bb.Hseqbase, bb.Ttype, bb.size, TRANSIENT, bb.size > 0 ? 
(uint16_t) (bb.tailsize / bb.size) : 0);
        if (b == NULL)
                throw(MAL, "remote.get", SQLSTATE(HY013) MAL_MALLOC_FAIL);
 
-       /* for strings, the width may not match, fix it to match what we
-        * retrieved */
-       if (bb.Ttype == TYPE_str && bb.size) {
-               b->twidth = (unsigned short) (bb.tailsize / bb.size);
-               b->tshift = ATOMelmshift(Tsize(b));
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to