Changeset: 04d29fa48dd0 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=04d29fa48dd0
Modified Files:
gdk/gdk_atoms.h
gdk/gdk_calc.c
gdk/gdk_calc_compare.h
Branch: Feb2013
Log Message:
fixed bug in BATcalc default type case with candidates.
Incase of candidates the pointers were not avanced (if the candidate
check failed)
diffs (94 lines):
diff --git a/gdk/gdk_atoms.h b/gdk/gdk_atoms.h
--- a/gdk/gdk_atoms.h
+++ b/gdk/gdk_atoms.h
@@ -29,7 +29,7 @@
* code in one CPP macro we use the following #defines for comparing
* atoms:
*/
-#define simple_CMP(x,y,tpe) (simple_LT(x,y,tpe)?-1:simple_GT(x,y,tpe))
+#define simple_CMP(x,y,tpe) (simple_GT(x,y,tpe) - simple_LT(x,y,tpe))
#define simple_EQ(x,y,tpe) ((*(const tpe*) (x)) == (*(const tpe*) (y)))
#define simple_NE(x,y,tpe,nl) ((*(const tpe*)(y)) != nl && (*(const tpe*)
(x)) != (*(const tpe*) (y)))
#define simple_LT(x,y,tpe) ((*(const tpe*) (x)) < (*(const tpe*) (y)))
diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -8401,7 +8401,7 @@ BATcalcbetween_intern(const void *src, i
{
BAT *bn;
BUN nils = 0;
- BUN i, j, k, l;
+ BUN i, j, k, l, soff = 0, loff = 0, hoff = 0;
bit *dst;
const void *nil;
int (*atomcmp)(const void *, const void *);
@@ -8453,12 +8453,13 @@ BATcalcbetween_intern(const void *src, i
k = start * incr3,
l = start;
l < end;
- i += incr1, j += incr2, k += incr3, l++) {
+ i += incr1, j += incr2, k += incr3, l++,
+ soff+=wd1, loff+= wd2, hoff+= wd3 ) {
const void *p1, *p2, *p3;
CHECKCAND(dst, l, seqbase, bit_nil);
- p1 = hp1 ? (const void *) (hp1 + VarHeapVal(src, i,
wd1)) : src;
- p2 = hp2 ? (const void *) (hp2 + VarHeapVal(lo, j,
wd2)) : lo;
- p3 = hp3 ? (const void *) (hp3 + VarHeapVal(hi, k,
wd3)) : hi;
+ p1 = hp1 ? (const void *) (hp1 + VarHeapVal(src, i,
wd1)) : (const void *) ((const char *) src + soff);
+ p2 = hp2 ? (const void *) (hp2 + VarHeapVal(lo, j,
wd2)) : (const void *) ((const char *) lo + loff);
+ p3 = hp3 ? (const void *) (hp3 + VarHeapVal(hi, k,
wd3)) : (const void *) ((const char *) hi + hoff);
if (p1 == NULL || p2 == NULL || p3 == NULL ||
(*atomcmp)(p1, nil) == 0 ||
(*atomcmp)(p2, nil) == 0 ||
@@ -8469,12 +8470,6 @@ BATcalcbetween_intern(const void *src, i
dst[l] = (bit) ((*atomcmp)(p1, p2) >= 0 &&
(*atomcmp)(p1, p3) <= 0);
}
- if (hp1 == NULL && incr1)
- src = (const void *) ((const char *) src + wd1);
- if (hp2 == NULL && incr2)
- lo = (const void *) ((const char *) lo + wd2);
- if (hp3 == NULL && incr3)
- hi = (const void *) ((const char *) hi + wd3);
}
break;
}
diff --git a/gdk/gdk_calc_compare.h b/gdk/gdk_calc_compare.h
--- a/gdk/gdk_calc_compare.h
+++ b/gdk/gdk_calc_compare.h
@@ -26,7 +26,7 @@ op_typeswitchloop(const void *lft, int t
const oid *candend, oid candoff, int nonil, const char *func)
{
BUN nils = 0;
- BUN i, j, k;
+ BUN i, j, k, loff = 0, roff = 0;
const void *nil;
int (*atomcmp)(const void *, const void *);
@@ -433,11 +433,12 @@ op_typeswitchloop(const void *lft, int t
nil = ATOMnilptr(tp1);
CANDLOOP(dst, k, TPE_nil, 0, start);
for (i = start * incr1, j = start * incr2, k = start;
- k < end; i += incr1, j += incr2, k++) {
+ k < end; i += incr1, j += incr2, k++,
+ loff+= wd1, roff+= wd2) {
const void *p1, *p2;
CHECKCAND(dst, k, candoff, TPE_nil);
- p1 = hp1 ? (const void *) (hp1 + VarHeapVal(lft, i,
wd1)) : lft;
- p2 = hp2 ? (const void *) (hp2 + VarHeapVal(rgt, i,
wd2)) : rgt;
+ p1 = hp1 ? (const void *) (hp1 + VarHeapVal(lft, i,
wd1)) : (const void *) ((const char *) lft + loff);
+ p2 = hp2 ? (const void *) (hp2 + VarHeapVal(rgt, j,
wd2)) : (const void *) ((const char *) rgt + roff);
if (p1 == NULL || p2 == NULL ||
(*atomcmp)(p1, nil) == 0 ||
(*atomcmp)(p2, nil) == 0) {
@@ -447,10 +448,6 @@ op_typeswitchloop(const void *lft, int t
int x = (*atomcmp)(p1, p2);
dst[k] = OP(x, 0);
}
- if (hp1 == NULL && incr1)
- lft = (const void *) ((const char *) lft + wd1);
- if (hp2 == NULL && incr2)
- rgt = (const void *) ((const char *) rgt + wd2);
}
CANDLOOP(dst, k, TPE_nil, end, cnt);
break;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list