Changeset: 3b4cd640f024 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/3b4cd640f024 Modified Files: gdk/gdk.h gdk/gdk_hash.c gdk/gdk_join.c gdk/gdk_select.c Branch: qcancel Log Message:
merge default diffs (truncated from 1655 to 300 lines): diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -11,9 +11,9 @@ assignees: '' A clear and concise description of what the bug is. **To Reproduce** -Create a setting with minimal input for an external user to demonstrate him the buggy behavior. -This includes the relevant part of the database schema description. -Performance trace of the roque query (using the TRACE command) +Create a setting with minimal input for an external user to demonstrate the buggy behavior. +This includes the relevant part of the database schema description. +Performance trace of the rogue query (using the TRACE command) **Expected behavior** A clear and concise description of what you expected to happen. diff --git a/MonetDB.spec b/MonetDB.spec --- a/MonetDB.spec +++ b/MonetDB.spec @@ -302,8 +302,8 @@ This package contains the files needed t Summary: MonetDB ODBC driver Group: Applications/Databases Requires: %{name}-client%{?_isa} = %{version}-%{release} -Requires(post): unixODBC -Requires(postun): unixODBC +Requires(post): %{_bindir}/odbcinst +Requires(postun): %{_bindir}/odbcinst %description client-odbc MonetDB is a database management system that is developed from a 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 @@ -226,6 +226,7 @@ gdk_return BUNdelete(BAT *b, oid o) __at BUN BUNfnd(BAT *b, const void *right); gdk_return BUNreplace(BAT *b, oid left, const void *right, bool force) __attribute__((__warn_unused_result__)); gdk_return BUNreplacemulti(BAT *b, const oid *positions, const void *values, BUN count, bool force) __attribute__((__warn_unused_result__)); +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__)); size_t GDK_mem_maxsize; diff --git a/gdk/ChangeLog b/gdk/ChangeLog --- a/gdk/ChangeLog +++ b/gdk/ChangeLog @@ -2,8 +2,10 @@ # This file is updated with Maddlog * Mon Mar 29 2021 Sjoerd Mullender <sjo...@acm.org> +- Implemented function BUNreplacemultiincr to replace multiple values + in a BAT in one go, starting at a given position. - Implemented new function BUNreplacemulti to replace multiple values - in a BAT in one go. + in a BAT in one go, at the given positions. - Removed function BUNinplace, just use BUNreplace, and check whether the BAT argument is of type TYPE_void before calling if you don't want to materialize. diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -772,7 +772,7 @@ typedef struct BAT { COLrec T; /* column info */ MT_Lock theaplock; /* lock protecting heap reference changes */ - MT_Lock batIdxLock; /* lock to manipulate indexes */ + MT_RWLock batIdxLock; /* lock to manipulate indexes */ } BAT; typedef struct BATiter { @@ -961,6 +961,8 @@ gdk_export gdk_return BUNreplace(BAT *b, __attribute__((__warn_unused_result__)); gdk_export gdk_return BUNreplacemulti(BAT *b, const oid *positions, const void *values, BUN count, bool force) __attribute__((__warn_unused_result__)); +gdk_export gdk_return BUNreplacemultiincr(BAT *b, oid position, const void *values, BUN count, bool force) + __attribute__((__warn_unused_result__)); gdk_export gdk_return BUNdelete(BAT *b, oid o) __attribute__((__warn_unused_result__)); diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c --- a/gdk/gdk_align.c +++ b/gdk/gdk_align.c @@ -142,7 +142,7 @@ VIEWcreate(oid seq, BAT *b) } HEAPdecref(bn->theap, false); MT_lock_destroy(&bn->theaplock); - MT_lock_destroy(&bn->batIdxLock); + MT_rwlock_destroy(&bn->batIdxLock); 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 @@ -142,7 +142,7 @@ BATcreatedesc(oid hseq, int tt, bool hea snprintf(name, sizeof(name), "heaplock%d", bn->batCacheid); /* fits */ MT_lock_init(&bn->theaplock, name); snprintf(name, sizeof(name), "BATlock%d", bn->batCacheid); /* fits */ - MT_lock_init(&bn->batIdxLock, name); + MT_rwlock_init(&bn->batIdxLock, name); bn->batDirtydesc = true; return bn; bailout: @@ -247,7 +247,7 @@ COLnew(oid hseq, int tt, BUN cap, role_t if (bn->tvheap) HEAPdecref(bn->tvheap, true); MT_lock_destroy(&bn->theaplock); - MT_lock_destroy(&bn->batIdxLock); + MT_rwlock_destroy(&bn->batIdxLock); GDKfree(bn); return NULL; } @@ -631,7 +631,7 @@ BATdestroy(BAT *b) GDKfree(b->tvheap); PROPdestroy(b); MT_lock_destroy(&b->theaplock); - MT_lock_destroy(&b->batIdxLock); + MT_rwlock_destroy(&b->batIdxLock); GDKfree(b->theap); GDKfree(b); } @@ -1326,7 +1326,7 @@ BUNdelete(BAT *b, oid o) * be saved explicitly. */ static gdk_return -BUNinplacemulti(BAT *b, const oid *positions, const void *values, BUN count, bool force) +BUNinplacemulti(BAT *b, const oid *positions, const void *values, BUN count, bool force, bool autoincr) { BUN last = BUNlast(b) - 1; BATiter bi = bat_iterator(b); @@ -1341,7 +1341,7 @@ BUNinplacemulti(BAT *b, const oid *posit return GDK_FAIL; } for (BUN i = 0; i < count; i++) { - BUN p = positions[i] - b->hseqbase; + BUN p = autoincr ? positions[0] - b->hseqbase + i : positions[i] - b->hseqbase; const void *t = b->ttype && b->tvarsized ? ((const void **) values)[i] : (const void *) ((const char *) values + i * Tsize(b)); @@ -1549,8 +1549,7 @@ BUNinplacemulti(BAT *b, const oid *posit return GDK_SUCCEED; } -/* very much like void_inplace, except this materializes a void tail - * column if necessarry */ +/* Replace multiple values given by their positions with the given values. */ gdk_return BUNreplacemulti(BAT *b, const oid *positions, const void *values, BUN count, bool force) { @@ -1559,7 +1558,20 @@ BUNreplacemulti(BAT *b, const oid *posit if (b->ttype == TYPE_void && BATmaterialize(b) != GDK_SUCCEED) return GDK_FAIL; - return BUNinplacemulti(b, positions, values, count, force); + return BUNinplacemulti(b, positions, values, count, force, false); +} + +/* Replace multiple values starting from a given position with the given + * values. */ +gdk_return +BUNreplacemultiincr(BAT *b, oid position, const void *values, BUN count, bool force) +{ + BATcheck(b, GDK_FAIL); + + if (b->ttype == TYPE_void && BATmaterialize(b) != GDK_SUCCEED) + return GDK_FAIL; + + return BUNinplacemulti(b, &position, values, count, force, true); } gdk_return @@ -1580,7 +1592,7 @@ void_inplace(BAT *b, oid id, const void } if (b->ttype == TYPE_void) return GDK_SUCCEED; - return BUNinplacemulti(b, &id, b->ttype && b->tvarsized ? (const void *) &val : (const void *) val, 1, force); + return BUNinplacemulti(b, &id, b->ttype && b->tvarsized ? (const void *) &val : (const void *) val, 1, force, false); } /* diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -1835,12 +1835,12 @@ BATordered(BAT *b) if (b->tnosorted > 0 || !ATOMlinear(b->ttype)) return false; - /* In order that multiple threads don't scan the same BAT at - * the same time (happens a lot with mitosis/mergetable), we - * use a lock. We reuse the hash lock for this, not because - * this scanning interferes with hashes, but because it's - * there, and not so likely to be used at the same time. */ - MT_lock_set(&b->batIdxLock); + /* In order that multiple threads don't scan the same BAT at the + * same time (happens a lot with mitosis/mergetable), we use a + * lock. We reuse the theaplock lock for this, not because this + * scanning interferes with heap reference counting, but because + * it's there, and not so likely to be used at the same time. */ + MT_lock_set(&b->theaplock); if (!b->tsorted && b->tnosorted == 0) { b->batDirtydesc = true; switch (ATOMbasetype(b->ttype)) { @@ -1907,7 +1907,7 @@ BATordered(BAT *b) } } doreturn: - MT_lock_unset(&b->batIdxLock); + MT_lock_unset(&b->theaplock); return b->tsorted; } @@ -1953,7 +1953,7 @@ BATordered_rev(BAT *b) return is_oid_nil(b->tseqbase); if (BATtdense(b) || b->tnorevsorted > 0) return false; - MT_lock_set(&b->batIdxLock); + MT_lock_set(&b->theaplock); if (!b->trevsorted && b->tnorevsorted == 0) { b->batDirtydesc = true; switch (ATOMbasetype(b->ttype)) { @@ -1997,7 +1997,7 @@ BATordered_rev(BAT *b) TRC_DEBUG(ALGO, "Fixed revsorted for " ALGOBATFMT " (" LLFMT " usec)\n", ALGOBATPAR(b), GDKusec() - t0); } doreturn: - MT_lock_unset(&b->batIdxLock); + MT_lock_unset(&b->theaplock); return b->trevsorted; } @@ -2204,7 +2204,7 @@ BATsort(BAT **sorted, BAT **order, BAT * mkorderidx = (g == NULL && !reverse && !nilslast && pb != NULL && (order || !pb->batTransient)); if (g == NULL && !reverse && !nilslast && pb != NULL && !BATcheckorderidx(pb)) { - MT_lock_set(&pb->batIdxLock); + MT_rwlock_wrlock(&pb->batIdxLock); if (pb->torderidx == NULL) { /* no index created while waiting for lock */ if (mkorderidx) /* keep lock when going to create */ @@ -2214,7 +2214,7 @@ BATsort(BAT **sorted, BAT **order, BAT * mkorderidx = false; } if (!orderidxlock) - MT_lock_unset(&pb->batIdxLock); + MT_rwlock_wrunlock(&pb->batIdxLock); } else { mkorderidx = false; } @@ -2441,7 +2441,7 @@ BATsort(BAT **sorted, BAT **order, BAT * GDKfree(m); } if (orderidxlock) - MT_lock_unset(&pb->batIdxLock); + MT_rwlock_wrunlock(&pb->batIdxLock); goto error; } bn->tsorted = !reverse && !nilslast; @@ -2464,7 +2464,7 @@ BATsort(BAT **sorted, BAT **order, BAT * } } if (orderidxlock) - MT_lock_unset(&pb->batIdxLock); + MT_rwlock_wrunlock(&pb->batIdxLock); bn->theap->dirty = true; bn->tnosorted = 0; bn->tnorevsorted = 0; @@ -2723,7 +2723,7 @@ BATgetprop(BAT *b, enum prop_t idx) { PROPrec *p; - MT_lock_set(&b->batIdxLock); + MT_rwlock_wrlock(&b->batIdxLock); p = BATgetprop_nolock(b, idx); if (p == NULL) { /* if looking for the min/max value, we may be able to @@ -2747,7 +2747,7 @@ BATgetprop(BAT *b, enum prop_t idx) break; } } - MT_lock_unset(&b->batIdxLock); + MT_rwlock_wrunlock(&b->batIdxLock); return p; } @@ -2755,18 +2755,18 @@ PROPrec * BATsetprop(BAT *b, enum prop_t idx, int type, const void *v) { PROPrec *p; - MT_lock_set(&b->batIdxLock); + MT_rwlock_wrlock(&b->batIdxLock); p = BATsetprop_nolock(b, idx, type, v); - MT_lock_unset(&b->batIdxLock); + MT_rwlock_wrunlock(&b->batIdxLock); return p; } void BATrmprop(BAT *b, enum prop_t idx) { - MT_lock_set(&b->batIdxLock); + MT_rwlock_wrlock(&b->batIdxLock); BATrmprop_nolock(b, idx); - MT_lock_unset(&b->batIdxLock); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list