You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by yo...@apache.org on 2010/07/21 20:48:30 UTC

svn commit: r966354 - in /lucene/dev/trunk/lucene/src: java/org/apache/lucene/search/TopDocsCollector.java test/org/apache/lucene/search/JustCompileSearch.java

Author: yonik
Date: Wed Jul 21 18:48:30 2010
New Revision: 966354

URL: http://svn.apache.org/viewvc?rev=966354&view=rev
Log:
LUCENE-2542: remove final from some TopDocsCollector methods

Modified:
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/TopDocsCollector.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/JustCompileSearch.java

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/TopDocsCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/TopDocsCollector.java?rev=966354&r1=966353&r2=966354&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/TopDocsCollector.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/TopDocsCollector.java Wed Jul 21 18:48:30 2010
@@ -25,8 +25,11 @@ import org.apache.lucene.util.PriorityQu
  * collector allows easy extension by providing a single constructor which
  * accepts a {@link PriorityQueue} as well as protected members for that
  * priority queue and a counter of the number of total hits.<br>
- * Extending classes can override {@link #topDocs(int, int)} and
- * {@link #getTotalHits()} in order to provide their own implementation.
+ * Extending classes can override any of the methods to provide their own
+ * implementation, as well as avoid the use of the priority queue entirely by
+ * passing null to {@link #TopDocsCollector(PriorityQueue)}. In that case
+ * however, you might want to consider overriding all methods, in order to avoid
+ * a NullPointerException.
  */
 public abstract class TopDocsCollector<T extends ScoreDoc> extends Collector {
 
@@ -50,7 +53,7 @@ public abstract class TopDocsCollector<T
   }
   
   /**
-   * Populates the results array with the ScoreDoc instaces. This can be
+   * Populates the results array with the ScoreDoc instances. This can be
    * overridden in case a different ScoreDoc type should be returned.
    */
   protected void populateResults(ScoreDoc[] results, int howMany) {
@@ -75,7 +78,7 @@ public abstract class TopDocsCollector<T
   }
   
   /** Returns the top docs that were collected by this collector. */
-  public final TopDocs topDocs() {
+  public TopDocs topDocs() {
     // In case pq was populated with sentinel values, there might be less
     // results than pq.size(). Therefore return all results until either
     // pq.size() or totalHits.
@@ -94,7 +97,7 @@ public abstract class TopDocsCollector<T
    * with the returned {@link TopDocs} object, which will contain all the
    * results this search execution collected.
    */
-  public final TopDocs topDocs(int start) {
+  public TopDocs topDocs(int start) {
     // In case pq was populated with sentinel values, there might be less
     // results than pq.size(). Therefore return all results until either
     // pq.size() or totalHits.
@@ -115,7 +118,7 @@ public abstract class TopDocsCollector<T
    * returned {@link TopDocs} object, which will contain all the results this
    * search execution collected.
    */
-  public final TopDocs topDocs(int start, int howMany) {
+  public TopDocs topDocs(int start, int howMany) {
     
     // In case pq was populated with sentinel values, there might be less
     // results than pq.size(). Therefore return all results until either

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/JustCompileSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/JustCompileSearch.java?rev=966354&r1=966353&r2=966354&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/JustCompileSearch.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/JustCompileSearch.java Wed Jul 21 18:48:30 2010
@@ -427,6 +427,21 @@ final class JustCompileSearch {
       throw new UnsupportedOperationException(UNSUPPORTED_MSG);
     }
 
+    @Override
+    public TopDocs topDocs() {
+        throw new UnsupportedOperationException( UNSUPPORTED_MSG );
+    }
+
+    @Override
+    public TopDocs topDocs( int start ) {
+        throw new UnsupportedOperationException( UNSUPPORTED_MSG );
+    }
+
+    @Override
+    public TopDocs topDocs( int start, int end ) {
+        throw new UnsupportedOperationException( UNSUPPORTED_MSG );
+    }
+    
   }
 
   static final class JustCompileWeight extends Weight {