Apache Solr open-source search software
LUCENE-2271: Fix javadocs of TopScoreDocCollector
Uwe Schindler7b9c0f796952
diff --git a/CHANGES.txt b/CHANGES.txtindex 5b206dac349..fa243acbd31 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -612,10 +612,10 @@ Changes in backwards compatibility policycode to implement this method. If you already extendIndexSearcher, no further changes are needed to use Collector.- Finally, the values Float.NaN, Float.NEGATIVE_INFINITY and- Float.POSITIVE_INFINITY are not valid scores. Lucene uses these- values internally in certain places, so if you have hits with such- scores, it will cause problems. (Shai Erera via Mike McCandless)+ Finally, the values Float.NaN and Float.NEGATIVE_INFINITY are not+ valid scores. Lucene uses these values internally in certain+ places, so if you have hits with such scores, it will cause+ problems. (Shai Erera via Mike McCandless)* LUCENE-1687: All methods and parsers from the interface ExtendedFieldCachehave been moved into FieldCache. ExtendedFieldCache is now deprecated and@@ -693,7 +693,7 @@ Changes in runtime behavior* LUCENE-1575: As of 2.9, the core collectors as well asIndexSearcher's search methods that return top N results, no- longer filter out zero scoring documents. If you rely on this+ longer filter documents with scores <= 0.0. If you rely on thisfunctionality you can use PositiveScoresOnlyCollector like this:<code>diff --git a/src/java/org/apache/lucene/search/TopScoreDocCollector.java b/src/java/org/apache/lucene/search/TopScoreDocCollector.javaindex 196a8af0c75..68b65ea02b5 100644--- a/src/java/org/apache/lucene/search/TopScoreDocCollector.java+++ b/src/java/org/apache/lucene/search/TopScoreDocCollector.java@@ -29,10 +29,10 @@ import org.apache.lucene.index.IndexReader;* instance of this collector you should know in advance whether documents are* going to be collected in doc Id order or not.*- * <p><b>NOTE</b>: The values Float.Nan,- * Float.NEGATIVE_INFINITY and Float.POSITIVE_INFINITY are- * not valid scores. This collector will not properly- * collect hits with such scores.+ * <p><b>NOTE</b>: The values {@link Float#NaN} and+ * {Float#NEGATIVE_INFINITY} are not valid scores. This+ * collector will not properly collect hits with such+ * scores.*/public abstract class TopScoreDocCollector extends TopDocsCollector<ScoreDoc> {@@ -45,6 +45,11 @@ public abstract class TopScoreDocCollector extends TopDocsCollector<ScoreDoc> {@Overridepublic void collect(int doc) throws IOException {float score = scorer.score();++ // This collector cannot handle these scores:+ assert score != Float.NEGATIVE_INFINITY;+ assert !Float.isNaN(score);+totalHits++;if (score <= pqTop.score) {// Since docs are returned in-order (i.e., increasing doc Id), a document@@ -72,6 +77,10 @@ public abstract class TopScoreDocCollector extends TopDocsCollector<ScoreDoc> {@Overridepublic void collect(int doc) throws IOException {float score = scorer.score();++ // This collector cannot handle NaN+ assert !Float.isNaN(score);+totalHits++;doc += docBase;if (score < pqTop.score || (score == pqTop.score && doc > pqTop.doc)) {