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:
Yonik Seeley 2007-09-22 15:33:42 +00:00
parent 4674b5f446
commit d78f61db76
2 changed files with 8 additions and 0 deletions

View File

@ -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) {

View File

@ -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() {