Changeset: 6d7798fa3a69 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6d7798fa3a69
Modified Files:
        gdk/gdk_join.c
        gdk/gdk_unique.c
Branch: analyze-fix
Log Message:

Backed out changeset 61a399ae48e8

Holding the bat iterator earlier doesn't fix the race condition


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
@@ -3060,7 +3060,6 @@ 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);
@@ -3073,18 +3072,16 @@ count_unique(BAT *b, BAT *s, BUN *cnt1, 
                return;
        }
 
-       bi = bat_iterator(b);
-       ordered = BATordered(b);
-       ordered_rev = BATordered_rev(b);
-       if ((ordered && ordered_rev) ||
+       if ((BATordered(b) && BATordered_rev(b)) ||
            (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;
@@ -3094,7 +3091,7 @@ count_unique(BAT *b, BAT *s, BUN *cnt1, 
 
        *cnt1 = *cnt2 = 0;
 
-       if (ordered || ordered_rev) {
+       if (BATordered(b) || BATordered_rev(b)) {
                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,7 +39,6 @@ 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();
@@ -65,9 +64,7 @@ BATunique(BAT *b, BAT *s)
        }
 
        BATiter bi = bat_iterator(b);
-       ordered = BATordered(b);
-       ordered_rev = BATordered_rev(b);
-       if ((ordered && ordered_rev) ||
+       if ((BATordered(b) && BATordered_rev(b)) ||
                (b->ttype == TYPE_void && is_oid_nil(b->tseqbase))) {
                /* trivial: all values are the same */
                bat_iterator_end(&bi);
@@ -160,7 +157,7 @@ BATunique(BAT *b, BAT *s)
                }
                TIMEOUT_CHECK(timeoffset,
                              GOTO_LABEL_TIMEOUT_HANDLER(bunins_failed));
-       } else if (ordered || ordered_rev) {
+       } else if (BATordered(b) || BATordered_rev(b)) {
                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

Reply via email to