You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by us...@apache.org on 2010/02/21 22:25:22 UTC
svn commit: r912407 - in /lucene/java/trunk: CHANGES.txt
src/java/org/apache/lucene/search/TopScoreDocCollector.java
Author: uschindler
Date: Sun Feb 21 21:25:21 2010
New Revision: 912407
URL: http://svn.apache.org/viewvc?rev=912407&view=rev
Log:
LUCENE-2271: Fix javadocs of TopScoreDocCollector
Modified:
lucene/java/trunk/CHANGES.txt
lucene/java/trunk/src/java/org/apache/lucene/search/TopScoreDocCollector.java
Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=912407&r1=912406&r2=912407&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Sun Feb 21 21:25:21 2010
@@ -612,10 +612,10 @@
code to implement this method. If you already extend
IndexSearcher, 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 ExtendedFieldCache
have been moved into FieldCache. ExtendedFieldCache is now deprecated and
@@ -693,7 +693,7 @@
* LUCENE-1575: As of 2.9, the core collectors as well as
IndexSearcher'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 this
functionality you can use PositiveScoresOnlyCollector like this:
<code>
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/TopScoreDocCollector.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/TopScoreDocCollector.java?rev=912407&r1=912406&r2=912407&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/TopScoreDocCollector.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/TopScoreDocCollector.java Sun Feb 21 21:25:21 2010
@@ -29,10 +29,10 @@
* 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 @@
@Override
public 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 @@
@Override
public 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)) {