Changeset: 6455a3437ec6 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6455a3437ec6
Modified Files:
        gdk/ChangeLog.Feb2013
        gdk/gdk_calc_private.h
        gdk/gdk_select.c
Branch: Feb2013
Log Message:

Catch the case where the candidate list doesn't overlap with the base bat.


diffs (49 lines):

diff --git a/gdk/ChangeLog.Feb2013 b/gdk/ChangeLog.Feb2013
--- a/gdk/ChangeLog.Feb2013
+++ b/gdk/ChangeLog.Feb2013
@@ -1,3 +1,7 @@
 # ChangeLog file for MonetDB
 # This file is updated with Maddlog
 
+* Mon Apr  8 2013 Sjoerd Mullender <[email protected]>
+- Fixed a bug in case the candidate list is dense and completely
+  outside the range of the bat being worked upon.
+
diff --git a/gdk/gdk_calc_private.h b/gdk/gdk_calc_private.h
--- a/gdk/gdk_calc_private.h
+++ b/gdk/gdk_calc_private.h
@@ -60,12 +60,17 @@ typedef unsigned __int64 ulng;
                                        start = *cand;                  \
                                        end = candend[-1] + 1;          \
                                }                                       \
-                               if (start < (b)->H->seq)                \
+                               assert(start <= end);                   \
+                               if (start <= (b)->H->seq)               \
                                        start = 0;                      \
+                               else if (start >= (b)->H->seq + cnt)    \
+                                       start = cnt;                    \
                                else                                    \
                                        start -= (b)->H->seq;           \
-                               if (end > (b)->H->seq + cnt)            \
+                               if (end >= (b)->H->seq + cnt)           \
                                        end = cnt;                      \
+                               else if (end <= (b)->H->seq)            \
+                                       end = 0;                        \
                                else                                    \
                                        end -= (b)->H->seq;             \
                        }                                               \
diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -803,7 +803,10 @@ BATsubselect(BAT *b, BAT *s, const void 
                return NULL;
        }
 
-       if (b->U->count == 0 || (s && s->U->count == 0)) {
+       if (b->U->count == 0 || (s && s->U->count == 0) ||
+           (BATtdense(s) &&
+            (s->tseqbase >= b->hseqbase + BATcount(b) ||
+             s->tseqbase + BATcount(s) <= b->hseqbase))) {
                /* trivially empty result */
                ALGODEBUG fprintf(stderr, "#BATsubselect(b=%s#" BUNFMT
                                  ",s=%s,anti=%d): trivially empty\n",
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to