Re: [Monetdb-developers] [Monetdb-checkins] MonetDB4/src/modules/plain bat_arith.mx, MonetDB_4-22, 1.4.2.2, 1.4.2.3
my below fixes in
MonetDB4/src/modules/plain/bat_arith.mx
would need to be propagated / applied to
MonetDB5/src/modules/kernel/batcalc.mx
too, but a simple diff|patch does not work, and I haven't found time to do it by hand, yet, sorry ...
Stefan
On Sun, Feb 10, 2008 at 10:46:53PM +0000, Stefan Manegold wrote:
Update of /cvsroot/monetdb/MonetDB4/src/modules/plain In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13856
Modified Files: Tag: MonetDB_4-22 bat_arith.mx Log Message:
fixed bug [ 1890131 ] PF: property error: incorrectly marked sorted! http://sourceforge.net/tracker/index.php?func=detail&aid=1890131&gro...
fixed sortedness propagation for "const [op] BAT" & "BAT [op] const", in particular three cases:
- substracting a BAT from a constant yields a result with the input's sort order reversed
- dividing a BAT by a negative constant yields a result with the input's sort order reversed
- for modulo (%) (also on) float & double we cannot predict any result order
Index: bat_arith.mx
RCS file: /cvsroot/monetdb/MonetDB4/src/modules/plain/bat_arith.mx,v retrieving revision 1.4.2.2 retrieving revision 1.4.2.3 diff -u -d -r1.4.2.2 -r1.4.2.3 --- bat_arith.mx 8 Feb 2008 15:02:14 -0000 1.4.2.2 +++ bat_arith.mx 10 Feb 2008 22:46:51 -0000 1.4.2.3 @@ -57,42 +57,42 @@ .END bat_arith;
@= operations -@:@1_operation(bte,+,add,,0,2)@ -@:@1_operation(bte,-,sub,,0,2)@ -@:@1_operation(bte,*,mul,1,0,3)@ -@:@1_operation(bte,/,div,1,1,1)@ +@:@1_operation(bte,+,add,,0,(1|2))@ +@:@1_operation(bte,-,sub,,0,(1|8))@ +@:@1_operation(bte,*,mul,1,0,(16|32))@ +@:@1_operation(bte,/,div,1,1,16)@ @:@1_operation(bte,%,mod,1,1,0)@ -@:@1_operation(sht,+,add,,0,2)@ -@:@1_operation(sht,-,sub,,0,2)@ -@:@1_operation(sht,*,mul,1,0,3)@ -@:@1_operation(sht,/,div,1,1,1)@ +@:@1_operation(sht,+,add,,0,(1|2))@ +@:@1_operation(sht,-,sub,,0,(1|8))@ +@:@1_operation(sht,*,mul,1,0,(16|32))@ +@:@1_operation(sht,/,div,1,1,16)@ @:@1_operation(sht,%,mod,1,1,0)@ -@:@1_operation(int,+,add,,0,2)@ -@:@1_operation(int,-,sub,,0,2)@ -@:@1_operation(int,*,mul,1,0,3)@ -@:@1_operation(int,/,div,1,1,1)@ +@:@1_operation(int,+,add,,0,(1|2))@ +@:@1_operation(int,-,sub,,0,(1|8))@ +@:@1_operation(int,*,mul,1,0,(16|32))@ +@:@1_operation(int,/,div,1,1,16)@ @:@1_operation(int,%,mod,1,1,0)@ -@:@1_operation(wrd,+,add,,0,2)@ -@:@1_operation(wrd,-,sub,,0,2)@ -@:@1_operation(wrd,*,mul,1,0,3)@ -@:@1_operation(wrd,/,div,1,1,1)@ +@:@1_operation(wrd,+,add,,0,(1|2))@ +@:@1_operation(wrd,-,sub,,0,(1|8))@ +@:@1_operation(wrd,*,mul,1,0,(16|32))@ +@:@1_operation(wrd,/,div,1,1,16)@ @:@1_operation(wrd,%,mod,1,1,0)@ -@:@1_operation(lng,+,add,,0,2)@ -@:@1_operation(lng,-,sub,,0,2)@ -@:@1_operation(lng,*,mul,1,0,3)@ -@:@1_operation(lng,/,div,1,1,1)@ +@:@1_operation(lng,+,add,,0,(1|2))@ +@:@1_operation(lng,-,sub,,0,(1|8))@ +@:@1_operation(lng,*,mul,1,0,(16|32))@ +@:@1_operation(lng,/,div,1,1,16)@ @:@1_operation(lng,%,mod,1,1,0)@ -@:@1_operation(flt,+,add,,0,2)@ -@:@1_operation(flt,-,sub,,0,2)@ -@:@1_operation(flt,*,mul,1,0,3)@ -@:@1_operation(flt,/,div,1,1,1)@ -@:@1_operation(dbl,+,add,,0,2)@ -@:@1_operation(dbl,-,sub,,0,2)@ -@:@1_operation(dbl,*,mul,1,0,3)@ -@:@1_operation(dbl,/,div,1,1,1)@ +@:@1_operation(flt,+,add,,0,(1|2))@ +@:@1_operation(flt,-,sub,,0,(1|8))@ +@:@1_operation(flt,*,mul,1,0,(16|32))@ +@:@1_operation(flt,/,div,1,1,16)@ +@:@1_operation(dbl,+,add,,0,(1|2))@ +@:@1_operation(dbl,-,sub,,0,(1|8))@ +@:@1_operation(dbl,*,mul,1,0,(16|32))@ +@:@1_operation(dbl,/,div,1,1,16)@ @:@1_redefine_OP()@ -@:@1_operation(flt,%,mod,1,1,1,%)@ -@:@1_operation(dbl,%,mod,1,1,1,%)@ +@:@1_operation(flt,%,mod,1,1,0,%)@ +@:@1_operation(dbl,%,mod,1,1,0,%)@
@* Implementation @c @@ -108,9 +108,13 @@ @3: add, sub, mul, div, mod basic arithmetic operator name @4: not used @5: 0 / 1 disable/enable division by zero check
- @6: 0 / 1 / 2 disable/enable sorting propagation
1 propagate on bat,const
2 propagate also on const,bat
- @6: (bit pattern) disable/enable sorting propagation
1 propagate as-is on bat,const
2 propagate as-is on const,bat
4 propagate reverted on bat,const (not required/used!)
8 propagate reverted on const,bat
16 propagate as-is / reverted on bat,const if const >=0 / <0
32 propagate as-is / reverted on const,bat if const >=0 / <0
*/ @= c_operation int @@ -201,7 +205,6 @@ if (bn == NULL) return GDK_FAIL; BATseqbase(bn,b->hseqbase);
- bn->tsorted = 0; bq = (@1*)Tloc(b,BUNlast(b)); bp = (@1*)Tloc(b,BUNfirst(b)); s = bnp = (@1*)Tloc(bn,BUNlast(bn));
@@ -225,13 +228,19 @@ BATsetcount(bn, bnp-s); if (!bn->batDirty) bn->batDirty = TRUE;
- if (@6 == 2)
- if (@6 & 2) { bn->tsorted = BATtordered(b);
- if (@6 == 3) {
if (*v > 0)
} else
if (@6 & 8) {
bn->tsorted = REVERT_SORTED(BATtordered(b));
} else
if (@6 & 32) {
if (*v >= 0) bn->tsorted = BATtordered(b);
else bn->tsorted = REVERT_SORTED(BATtordered(b));
} else {
bn->tsorted = 0;
}
*ret = bn;
@@ -264,15 +273,20 @@ } if (!b->batDirty) b->batDirty = TRUE;
- if (@6 == 2)
- if (@6 & 2) { b->tsorted = BATtordered(b);
- if (@6 == 3) {
if (*v > 0)
- } else
- if (@6 & 8) {
b->tsorted = REVERT_SORTED(BATtordered(b));
- } else
- if (@6 & 32) {
else b->tsorted = REVERT_SORTED(BATtordered(b));if (*v >= 0) b->tsorted = BATtordered(b);
- } else
} else { b->tsorted = 0;
}
BBPfix(b->batCacheid); *ret = b;
@@ -294,7 +308,6 @@ if( bn == NULL) return GDK_FAIL; BATseqbase(bn,b->hseqbase);
- bn->tsorted = 0; bq = (@1*)Tloc(b,BUNlast(b)); bp = (@1*)Tloc(b,BUNfirst(b)); s = bnp = (@1*)Tloc(bn,BUNlast(bn));
@@ -317,14 +330,21 @@ } BATsetcount(bn, bnp-s); if (!bn->batDirty) bn->batDirty = TRUE;
- if (@6 == 2)
- if (@6 & 1) { bn->tsorted = BATtordered(b);
- if (@6 == 3) {
if (*v > 0)
- } else
- if (@6 & 4) {
bn->tsorted = REVERT_SORTED(BATtordered(b));
- } else
- if (@6 & 16) {
else bn->tsorted = REVERT_SORTED(BATtordered(b));if (*v >= 0) bn->tsorted = BATtordered(b);
- }
} else {
bn->tsorted = 0;
}
*ret = bn; return GDK_SUCCEED;
@@ -356,15 +376,21 @@ } } if (!b->batDirty) b->batDirty = TRUE;
- if (@6 == 2)
- if (@6 & 1) { b->tsorted = BATtordered(b);
- if (@6 == 3) {
if (*v > 0)
- } else
- if (@6 & 4) {
b->tsorted = REVERT_SORTED(BATtordered(b));
- } else
- if (@6 & 16) {
else b->tsorted = REVERT_SORTED(BATtordered(b));if (*v >= 0) b->tsorted = BATtordered(b);
- } else
} else { b->tsorted = 0;
}
BBPfix(b->batCacheid); *ret = b;
participants (1)
-
Stefan Manegold