Changeset: 61a399ae48e8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/61a399ae48e8
Modified Files:
gdk/gdk_join.c
gdk/gdk_unique.c
Branch: analyze-fix
Log Message:
Hold lock a little longer and cache sort check calls
diffs (73 lines):
diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -3053,6 +3053,7 @@ count_unique(BAT *b, BAT *s, BUN *cnt1,
int (*cmp)(const void *, const void *);
const char *algomsg = "";
lng t0 = 0;
+ bool ordered, ordered_rev;
TRC_DEBUG_IF(ALGO) t0 = GDKusec();
canditer_init(&ci, b, s);
@@ -3065,16 +3066,18 @@ count_unique(BAT *b, BAT *s, BUN *cnt1,
return;
}
- if ((BATordered(b) && BATordered_rev(b)) ||
+ bi = bat_iterator(b);
+ ordered = BATordered(b);
+ ordered_rev = BATordered_rev(b);
+ if ((ordered && ordered_rev) ||
(b->ttype == TYPE_void && is_oid_nil(b->tseqbase))) {
/* trivial: all values are the same */
+ bat_iterator_end(&bi);
*cnt1 = *cnt2 = 1;
return;
}
assert(b->ttype != TYPE_void);
-
- bi = bat_iterator(b);
bvals = bi.base;
if (b->tvarsized && b->ttype)
bvars = bi.vh->base;
@@ -3084,7 +3087,7 @@ count_unique(BAT *b, BAT *s, BUN *cnt1,
*cnt1 = *cnt2 = 0;
- if (BATordered(b) || BATordered_rev(b)) {
+ if (ordered || ordered_rev) {
const void *prev = NULL;
algomsg = "sorted";
for (i = 0; i < ci.ncand; i++) {
diff --git a/gdk/gdk_unique.c b/gdk/gdk_unique.c
--- a/gdk/gdk_unique.c
+++ b/gdk/gdk_unique.c
@@ -39,6 +39,7 @@ BATunique(BAT *b, BAT *s)
struct canditer ci;
const char *algomsg = "";
lng t0 = 0;
+ bool ordered, ordered_rev;
lng timeoffset = 0;
QryCtx *qry_ctx = MT_thread_get_qry_ctx();
@@ -64,7 +65,9 @@ BATunique(BAT *b, BAT *s)
}
BATiter bi = bat_iterator(b);
- if ((BATordered(b) && BATordered_rev(b)) ||
+ ordered = BATordered(b);
+ ordered_rev = BATordered_rev(b);
+ if ((ordered && ordered_rev) ||
(b->ttype == TYPE_void && is_oid_nil(b->tseqbase))) {
/* trivial: all values are the same */
bat_iterator_end(&bi);
@@ -157,7 +160,7 @@ BATunique(BAT *b, BAT *s)
}
TIMEOUT_CHECK(timeoffset,
GOTO_LABEL_TIMEOUT_HANDLER(bunins_failed));
- } else if (BATordered(b) || BATordered_rev(b)) {
+ } else if (ordered || ordered_rev) {
const void *prev = NULL;
algomsg = "unique: sorted";
TIMEOUT_LOOP_IDX(i, cnt, timeoffset) {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list