Changeset: e67ebe4ca53a for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/e67ebe4ca53a Branch: ordered-set-aggregates Log Message:
merged with default diffs (197 lines): diff --git a/clients/mapilib/msettings.c b/clients/mapilib/msettings.c --- a/clients/mapilib/msettings.c +++ b/clients/mapilib/msettings.c @@ -477,7 +477,6 @@ msetting_set_string(msettings *mp, mparm mp->lang_is_mal = true; else if (strstr(value, "sql") == value) mp->lang_is_sql = true; - else if (strcmp(value, "`")) break; default: break; diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -804,6 +804,7 @@ typedef struct BAT { MT_Lock theaplock; /* lock protecting heap reference changes */ MT_RWLock thashlock; /* lock specifically for hash management */ MT_Lock batIdxLock; /* lock to manipulate other indexes/properties */ + MT_Sema imprsema; /* semaphore to synchronize imprints creation */ Heap *oldtail; /* old tail heap, to be destroyed after commit */ } BAT; diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c --- a/gdk/gdk_align.c +++ b/gdk/gdk_align.c @@ -209,6 +209,7 @@ VIEWcreate(oid seq, BAT *b, BUN l, BUN h MT_lock_destroy(&bn->theaplock); MT_lock_destroy(&bn->batIdxLock); MT_rwlock_destroy(&bn->thashlock); + MT_sema_destroy(&bn->imprsema); GDKfree(bn); return NULL; } diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -144,6 +144,8 @@ BATcreatedesc(oid hseq, int tt, bool hea MT_lock_init(&bn->batIdxLock, name); snprintf(name, sizeof(name), "hashlock%d", bn->batCacheid); /* fits */ MT_rwlock_init(&bn->thashlock, name); + snprintf(name, sizeof(name), "imprsema%d", bn->batCacheid); /* fits */ + MT_sema_init(&bn->imprsema, 1, name); return bn; } @@ -715,6 +717,7 @@ BATdestroy(BAT *b) MT_lock_destroy(&b->theaplock); MT_lock_destroy(&b->batIdxLock); MT_rwlock_destroy(&b->thashlock); + MT_sema_destroy(&b->imprsema); if (b->theap) { GDKfree(b->theap); } diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -831,6 +831,8 @@ BBPreadEntries(FILE *fp, unsigned bbpver MT_lock_init(&bn->batIdxLock, name); snprintf(name, sizeof(name), "hashlock%d", bn->batCacheid); /* fits */ MT_rwlock_init(&bn->thashlock, name); + snprintf(name, sizeof(name), "imprsema%d", bn->batCacheid); /* fits */ + MT_sema_init(&bn->imprsema, 1, name); ATOMIC_INIT(&bn->theap->refs, 1); if (snprintf(BBP_bak(b.batCacheid), sizeof(BBP_bak(b.batCacheid)), "tmp_%o", (unsigned) b.batCacheid) >= (int) sizeof(BBP_bak(b.batCacheid))) { diff --git a/gdk/gdk_imprints.c b/gdk/gdk_imprints.c --- a/gdk/gdk_imprints.c +++ b/gdk/gdk_imprints.c @@ -492,6 +492,23 @@ BATimprints(BAT *b) size_t pages; MT_lock_unset(&b->batIdxLock); + /* in case there are multiple threads that all want to + * create imprints on slices of the same bat, we use a + * semaphore so that one thread can pass and do the work + * while the other threads wait until the first one is + * done; so when a subsequent thread passes, first check + * whether the work has already been done */ + MT_sema_down(&b->imprsema); + MT_lock_set(&b->batIdxLock); + if (b->timprints != NULL) { + bat_iterator_end(&bi); + if (unfix) + BBPunfix(unfix); + MT_sema_up(&b->imprsema); + MT_lock_unset(&b->batIdxLock); + return GDK_SUCCEED; + } + MT_lock_unset(&b->batIdxLock); MT_thread_setalgorithm("create imprints"); if (s2) @@ -511,6 +528,7 @@ BATimprints(BAT *b) bat_iterator_end(&bi); if (unfix) BBPunfix(unfix); + MT_sema_up(&b->imprsema); return GDK_FAIL; } strconcat_len(imprints->imprints.filename, @@ -528,6 +546,7 @@ BATimprints(BAT *b) bat_iterator_end(&bi); if (unfix) BBPunfix(unfix); + MT_sema_up(&b->imprsema); return GDK_FAIL; } s2 = BATunique(b, s1); @@ -537,6 +556,7 @@ BATimprints(BAT *b) bat_iterator_end(&bi); if (unfix) BBPunfix(unfix); + MT_sema_up(&b->imprsema); return GDK_FAIL; } s3 = BATproject(s2, b); @@ -547,6 +567,7 @@ BATimprints(BAT *b) bat_iterator_end(&bi); if (unfix) BBPunfix(unfix); + MT_sema_up(&b->imprsema); return GDK_FAIL; } s3->tkey = true; /* we know is unique on tail now */ @@ -558,6 +579,7 @@ BATimprints(BAT *b) bat_iterator_end(&bi); if (unfix) BBPunfix(unfix); + MT_sema_up(&b->imprsema); return GDK_FAIL; } /* s4 now is ordered and unique on tail */ @@ -598,12 +620,15 @@ BATimprints(BAT *b) BBPunfix(s3->batCacheid); BBPunfix(s4->batCacheid); if (b->timprints != NULL) { + assert(0); if (unfix) BBPunfix(unfix); + MT_sema_up(&b->imprsema); return GDK_SUCCEED; /* we were beaten to it */ } if (unfix) BBPunfix(unfix); + MT_sema_up(&b->imprsema); return GDK_FAIL; } imprints->bins = imprints->imprints.base + IMPRINTS_HEADER_SIZE * SIZEOF_SIZE_T; @@ -676,6 +701,7 @@ BATimprints(BAT *b) TRC_DEBUG(ACCELERATOR, "failed imprints construction: bat %s changed, " LLFMT " usec\n", BATgetId(b), GDKusec() - t0); if (unfix) BBPunfix(unfix); + MT_sema_up(&b->imprsema); return GDK_FAIL; } ATOMIC_INIT(&imprints->imprints.refs, 1); @@ -693,6 +719,7 @@ BATimprints(BAT *b) MT_THR_DETACHED, name) < 0) BBPunfix(b->batCacheid); } + MT_sema_up(&b->imprsema); } TRC_DEBUG(ACCELERATOR, "%s: imprints construction " LLFMT " usec\n", diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c --- a/gdk/gdk_select.c +++ b/gdk/gdk_select.c @@ -2326,7 +2326,6 @@ BATselect(BAT *b, BAT *s, const void *tl */ Imprints *imprints = NULL; if (!equi && - /* DISABLES CODE */ (0) && imprintable(bi.type) && (!bi.transient || (pb != NULL && !pbi.transient)) && @@ -2690,8 +2689,7 @@ rangejoin(BAT *r1, BAT *r2, BAT *l, BAT TIMEOUT_CHECK(qry_ctx, GOTO_LABEL_TIMEOUT_HANDLER(bailout, qry_ctx)); cnt = BATcount(r1); assert(r2 == NULL || BATcount(r1) == BATcount(r2)); - } else if (/* DISABLES CODE */ (0) && - !anti && !symmetric && + } else if (!anti && !symmetric && imprintable(li.type) && (BATcount(rl) > 2 || !li.transient || diff --git a/sql/test/BugTracker-2016/Tests/storagemodel.test b/sql/test/BugTracker-2016/Tests/storagemodel.test --- a/sql/test/BugTracker-2016/Tests/storagemodel.test +++ b/sql/test/BugTracker-2016/Tests/storagemodel.test @@ -173,7 +173,7 @@ smallint writable 2 0 -0 +1 statement ok call sys.storagemodelinit() _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org