lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dor...@apache.org
Subject svn commit: r691824 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/search/TopDocCollector.java src/java/org/apache/lucene/search/TopFieldDocCollector.java
Date Wed, 03 Sep 2008 23:18:51 GMT
Author: doronc
Date: Wed Sep  3 16:18:51 2008
New Revision: 691824

URL: http://svn.apache.org/viewvc?rev=691824&view=rev
Log:
LUCENE-1356: Allow easy extensions of TopDocCollector.

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/search/TopDocCollector.java
    lucene/java/trunk/src/java/org/apache/lucene/search/TopFieldDocCollector.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=691824&r1=691823&r2=691824&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Wed Sep  3 16:18:51 2008
@@ -140,6 +140,10 @@
 
 22. LUCENE-1371: Added convenience method TopDocs Searcher.search(Query query, int n).
     (Mike McCandless)
+    
+23. LUCENE-1356: Allow easy extensions of TopDocCollector by turning
+    constructor and fields from package to protected. (Shai Erera
+    via Doron Cohen) 
 
 Bug fixes
     

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/TopDocCollector.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/TopDocCollector.java?rev=691824&r1=691823&r2=691824&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/TopDocCollector.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/TopDocCollector.java Wed Sep  3 16:18:51
2008
@@ -30,21 +30,34 @@
 public class TopDocCollector extends HitCollector {
 
   private ScoreDoc reusableSD;
-
-  int totalHits;
-  PriorityQueue hq;
+  
+  /** The total number of hits the collector encountered. */
+  protected int totalHits;
+  
+  /** The priority queue which holds the top-scoring documents. */
+  protected PriorityQueue hq;
     
   /** Construct to collect a given number of hits.
    * @param numHits the maximum number of hits to collect
    */
   public TopDocCollector(int numHits) {
-    this(numHits, new HitQueue(numHits));
+    this(new HitQueue(numHits));
   }
 
+  /** @deprecated use TopDocCollector(hq) instead. numHits is not used by this
+   * constructor. It will be removed in a future release.
+   */
   TopDocCollector(int numHits, PriorityQueue hq) {
     this.hq = hq;
   }
 
+  /** Constructor to collect the top-scoring documents by using the given PQ.
+   * @hq the PQ to use by this instance.
+   */
+  protected TopDocCollector(PriorityQueue hq) {
+    this.hq = hq;
+  }
+
   // javadoc inherited
   public void collect(int doc, float score) {
     if (score > 0.0f) {

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/TopFieldDocCollector.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/TopFieldDocCollector.java?rev=691824&r1=691823&r2=691824&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/TopFieldDocCollector.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/TopFieldDocCollector.java Wed Sep
 3 16:18:51 2008
@@ -40,7 +40,7 @@
    */
   public TopFieldDocCollector(IndexReader reader, Sort sort, int numHits)
     throws IOException {
-    super(numHits, new FieldSortedHitQueue(reader, sort.fields, numHits));
+    super(new FieldSortedHitQueue(reader, sort.fields, numHits));
   }
 
   // javadoc inherited



Mime
View raw message