Changeset: 7a900432b70a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7a900432b70a
Modified Files:
gdk/gdk_batop.mx
Branch: Mar2011
Log Message:
More anti-select fixes.
- antiselect of nil-nil range (i.e. upper and lower bound both
specified as nil) should return everything outside the (-inf,inf)
interval (i.e. nothing), but also not nil. In other words: nothing.
- antiselect of nil value (i.e. lower bound is nil, upper bound is not
specified (NULL pointer)) means give me everything except nil
values, in other words, it is the same as a normal select of the
(-inf,inf) range.
diffs (61 lines):
diff --git a/gdk/gdk_batop.mx b/gdk/gdk_batop.mx
--- a/gdk/gdk_batop.mx
+++ b/gdk/gdk_batop.mx
@@ -1045,6 +1045,10 @@
Examine type, and values for lower- and higher-bound.
@c
batcnt = BATcount(b);
+ /* preliminarily determine result types */
+ ht = BAThtype(b);
+ tt = tail ? BATttype(b) : TYPE_void;
+
t = b->ttype;
nil = ATOMnilptr(t);
lnil = ATOMcmp(t, tl, nil) == 0;
@@ -1056,11 +1060,12 @@
th = tl;
hval = 1; /* equi-select */
} else {
- hval = ATOMcmp(t, th, nil);
+ hval = ATOMcmp(t, th, nil) != 0;
}
if (nequi) {
- equi = 0;
- if (!lval || !hval) { /* swap sub-ranges */
+ if (!lval != !hval) {
+ /* one of the end points is nil and the other
+ * isn't: swap sub-ranges */
ptr tv;
bit ti;
ti = li;
@@ -1070,13 +1075,25 @@
tl = th;
th = tv;
nequi = 0;
- }
+ equi = 0;
+ } else if (!lval && !hval) {
+ /* antiselect for nil-nil range: all non-nil
+ * values are in range, so we need to return
+ * all but, but we also don't want to return
+ * nils, so instead we return nothing. */
+ return BATnew(ht, tt, 10);
+ } else if (equi && lnil) {
+ /* antiselect for nil value: turn into range
+ * select for nil-nil range (i.e. everything
+ * but nil) */
+ equi = 0;
+ nequi = 0;
+ lval = 0;
+ hval = 0;
+ } else
+ equi = 0;
}
- /* preliminarily determine result types */
- ht = BAThtype(b);
- tt = tail ? BATttype(b) : TYPE_void;
-
if (hval && ((ATOMcmp(t, tl, th) > 0) || (equi && !(li && hi)))) {
/* empty range */
ALGODEBUG THRprintf(GDKout, "#BAT_select_(b=%s): empty
range;\n", BATgetId(b));
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list