mirror of https://github.com/apache/lucene.git
optimize NaN and -Inf check
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@782657 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9382159d10
commit
2e5960f5e6
|
@ -122,9 +122,10 @@ public class BoostedQuery extends Query {
|
|||
public float score() throws IOException {
|
||||
float score = qWeight * scorer.score() * vals.floatVal(scorer.doc());
|
||||
|
||||
// current Lucene sorting priority queues can't handle NaN (score!=score is true for NaN) and -Infinity
|
||||
if (score != score || score==Float.NEGATIVE_INFINITY) return -Float.MAX_VALUE;
|
||||
return score;
|
||||
// Current Lucene priority queues can't handle NaN and -Infinity, so
|
||||
// map to -Float.MAX_VALUE. This conditional handles both -infinity
|
||||
// and NaN since comparisons with NaN are always false.
|
||||
return score>Float.NEGATIVE_INFINITY ? score : -Float.MAX_VALUE;
|
||||
}
|
||||
|
||||
public boolean skipTo(int target) throws IOException {
|
||||
|
|
|
@ -133,9 +133,10 @@ public class FunctionQuery extends Query {
|
|||
public float score() throws IOException {
|
||||
float score = qWeight * vals.floatVal(doc);
|
||||
|
||||
// current Lucene sorting priority queues can't handle NaN (score!=score is true for NaN) and -Infinity
|
||||
if (score != score || score==Float.NEGATIVE_INFINITY) return -Float.MAX_VALUE;
|
||||
return score;
|
||||
// Current Lucene priority queues can't handle NaN and -Infinity, so
|
||||
// map to -Float.MAX_VALUE. This conditional handles both -infinity
|
||||
// and NaN since comparisons with NaN are always false.
|
||||
return score>Float.NEGATIVE_INFINITY ? score : -Float.MAX_VALUE;
|
||||
}
|
||||
|
||||
public boolean skipTo(int target) throws IOException {
|
||||
|
|
Loading…
Reference in New Issue