mirror of https://github.com/apache/lucene.git
don't factor in +-Inf,NaN in scale function
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@578456 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4674b5f446
commit
d78f61db76
|
@ -66,6 +66,11 @@ public class ScaleFloatFunction extends ValueSource {
|
||||||
|
|
||||||
for (int i=0; i<maxDoc; i++) {
|
for (int i=0; i<maxDoc; i++) {
|
||||||
float val = vals.floatVal(i);
|
float val = vals.floatVal(i);
|
||||||
|
if ((Float.floatToRawIntBits(val) & (0xff<<23)) == 0xff<<23) {
|
||||||
|
// if the exponent in the float is all ones, then this is +Inf, -Inf or NaN
|
||||||
|
// which don't make sense to factor into the scale function
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (val < minVal) {
|
if (val < minVal) {
|
||||||
minVal = val;
|
minVal = val;
|
||||||
} else if (val > maxVal) {
|
} else if (val > maxVal) {
|
||||||
|
|
|
@ -128,6 +128,9 @@ public class TestFunctionQuery extends AbstractSolrTestCase {
|
||||||
singleTest(field,"scale(\0,-1,1)",-4,-1, 100,1, 0,-0.9230769f);
|
singleTest(field,"scale(\0,-1,1)",-4,-1, 100,1, 0,-0.9230769f);
|
||||||
singleTest(field,"scale(\0,-10,1000)",-4,-10, 100,1000, 0,28.846153f);
|
singleTest(field,"scale(\0,-10,1000)",-4,-10, 100,1000, 0,28.846153f);
|
||||||
|
|
||||||
|
// test that infinity doesn't mess up scale function
|
||||||
|
singleTest(field,"scale(log(\0),-1000,1000)",100,1000);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFunctions() {
|
public void testFunctions() {
|
||||||
|
|
Loading…
Reference in New Issue