Changeset: 4107d19c5fa0 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4107d19c5fa0
Modified Files:
        gdk/gdk_select.c
Branch: default
Log Message:

Some fixes for subselect with candidates.


diffs (62 lines):

diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -161,18 +161,13 @@ BAT_hashselect(BAT *b, BAT *s, BAT *bn, 
                            "#BATsubselect(b=%s#"BUNFMT",s=%s,anti=%d): " \
                            "scanselect %s\n", BATgetId(b), BATcount(b), \
                            s ? BATgetId(s) : "NULL", anti, #TEST);     \
-               BATloop(s, p, q) {                                      \
-                       o = * (oid *) BUNtloc(si, p);                   \
-                       if (o == oid_nil ||                             \
-                           o < seqbase ||                              \
-                           o - seqbase >= b->U->count) {               \
-                               /* XXX return an error? */              \
-                               continue;                               \
-                       }                                               \
-                       p = (BUN) (o - off);                            \
-                       v = BUNtail(bi, p);                             \
+               while (p < q) {                                         \
+                       o = *candlist++;                                \
+                       r = (BUN) (o - off);                            \
+                       v = BUNtail(bi, r);                             \
                        if (TEST)                                       \
                                bunfastins(bn, NULL, &o);               \
+                       p++;                                            \
                }                                                       \
        } while (0)
 
@@ -199,7 +194,7 @@ BAT_scanselect(BAT *b, BAT *s, BAT *bn, 
        BATiter bi = bat_iterator(b);
        int (*cmp)(const void *, const void *);
        BUN p, q;
-       oid o, seqbase, off;
+       oid o, off;
        const void *nil, *v;
        int c;
 
@@ -216,14 +211,22 @@ BAT_scanselect(BAT *b, BAT *s, BAT *bn, 
        assert(!lval || !hval || (*cmp)(tl, th) <= 0);
 
        nil = b->T->nonil ? NULL : ATOMnilptr(b->ttype);
-       seqbase = b->hseqbase;
-       off = seqbase - BUNfirst(b);
+       off = b->hseqbase - BUNfirst(b);
 
        if (s) {
-               BATiter si = bat_iterator(s);
+               const oid *candlist;
+               BUN r;
 
                assert(s->tsorted);
                assert(s->tkey);
+               /* setup candscanloop loop vars to only iterate over
+                * part of s that has values that are in range of b */
+               o = b->hseqbase + BATcount(b);
+               q = SORTfndfirst(s, &o);
+               p = SORTfndfirst(s, &b->hseqbase);
+               /* should we return an error if p > BUNfirst(s) || q <
+                * BUNlast(s) (i.e. s not fully used)? */
+               candlist = (const oid *) Tloc(s, p);
                if (equi) {
                        assert(li && hi);
                        assert(!anti);
_______________________________________________
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to