lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r835090 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/search/FieldValueHitQueue.java src/java/org/apache/lucene/search/TopDocsCollector.java src/java/org/apache/lucene/search/TopFieldCollector.java
Date Wed, 11 Nov 2009 21:58:05 GMT
Author: uschindler
Date: Wed Nov 11 21:58:05 2009
New Revision: 835090

URL: http://svn.apache.org/viewvc?rev=835090&view=rev
Log:
LUCENE-2057: TopDocsCollector should have bounded generic <T extends ScoreDoc>

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/search/FieldValueHitQueue.java
    lucene/java/trunk/src/java/org/apache/lucene/search/TopDocsCollector.java
    lucene/java/trunk/src/java/org/apache/lucene/search/TopFieldCollector.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=835090&r1=835089&r2=835090&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Wed Nov 11 21:58:05 2009
@@ -42,8 +42,9 @@
 
 API Changes
 
-* LUCENE-1257, LUCENE-1984, LUCENE-1985, ...: Port to Java 1.5 [not yet finished].
-  (Uwe Schindler, Robert Muir, Karl Wettin, Paul Elschot, Kay Kay)
+* LUCENE-1257, LUCENE-1984, LUCENE-1985, LUCENE-2057,...: Port to Java 1.5
+  [not yet finished].  (Uwe Schindler, Robert Muir, Karl Wettin, Paul Elschot,
+  Kay Kay, Shai Erera)
 
 * LUCENE-1944: Remove (all) deprecated methods/constructors taking
   String/File directory pathes in IndexReader / IndexWriter and others.

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/FieldValueHitQueue.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/FieldValueHitQueue.java?rev=835090&r1=835089&r2=835090&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/FieldValueHitQueue.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/FieldValueHitQueue.java Wed Nov 11
21:58:05 2009
@@ -36,20 +36,17 @@
  */
 public abstract class FieldValueHitQueue extends PriorityQueue<FieldValueHitQueue.Entry>
{
 
-  final static class Entry {
+  final static class Entry extends ScoreDoc {
     int slot;
-    int docID;
-    float score;
 
-    Entry(int slot, int docID, float score) {
+    Entry(int slot, int doc, float score) {
+      super(doc, score);
       this.slot = slot;
-      this.docID = docID;
-      this.score = score;
     }
     
     @Override
     public String toString() {
-      return "slot:" + slot + " docID:" + docID + " score=" + score;
+      return "slot:" + slot + " " + super.toString();
     }
   }
 
@@ -97,7 +94,7 @@
       }
 
       // avoid random sort order that could lead to duplicates (bug #31241):
-      return hitA.docID > hitB.docID;
+      return hitA.doc > hitB.doc;
     }
 
   }
@@ -139,7 +136,7 @@
       }
 
       // avoid random sort order that could lead to duplicates (bug #31241):
-      return hitA.docID > hitB.docID;
+      return hitA.doc > hitB.doc;
     }
     
   }
@@ -214,7 +211,7 @@
       fields[i] = comparators[i].value(entry.slot);
     }
     //if (maxscore > 1.0f) doc.score /= maxscore;   // normalize scores
-    return new FieldDoc(entry.docID, entry.score, fields);
+    return new FieldDoc(entry.doc, entry.score, fields);
   }
 
   /** Returns the SortFields being used by this hit queue. */

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/TopDocsCollector.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/TopDocsCollector.java?rev=835090&r1=835089&r2=835090&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/TopDocsCollector.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/TopDocsCollector.java Wed Nov 11 21:58:05
2009
@@ -28,7 +28,7 @@
  * Extending classes can override {@link #topDocs(int, int)} and
  * {@link #getTotalHits()} in order to provide their own implementation.
  */
-public abstract class TopDocsCollector<T> extends Collector {
+public abstract class TopDocsCollector<T extends ScoreDoc> extends Collector {
 
   // This is used in case topDocs() is called with illegal parameters, or there
   // simply aren't (enough) results.
@@ -55,7 +55,7 @@
    */
   protected void populateResults(ScoreDoc[] results, int howMany) {
     for (int i = howMany - 1; i >= 0; i--) { 
-      results[i] = (ScoreDoc) pq.pop();
+      results[i] = pq.pop();
     }
   }
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/TopFieldCollector.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/TopFieldCollector.java?rev=835090&r1=835089&r2=835090&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/TopFieldCollector.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/TopFieldCollector.java Wed Nov 11
21:58:05 2009
@@ -59,7 +59,7 @@
     
     final void updateBottom(int doc) {
       // bottom.score is already set to Float.NaN in add().
-      bottom.docID = docBase + doc;
+      bottom.doc = docBase + doc;
       bottom = pq.updateTop();
     }
 
@@ -122,7 +122,7 @@
       if (queueFull) {
         // Fastmatch: return if this hit is not competitive
         final int cmp = reverseMul * comparator.compareBottom(doc);
-        if (cmp < 0 || (cmp == 0 && doc + docBase > bottom.docID)) {
+        if (cmp < 0 || (cmp == 0 && doc + docBase > bottom.doc)) {
           return;
         }
         
@@ -164,7 +164,7 @@
     }
     
     final void updateBottom(int doc, float score) {
-      bottom.docID = docBase + doc;
+      bottom.doc = docBase + doc;
       bottom.score = score;
       bottom = pq.updateTop();
     }
@@ -230,7 +230,7 @@
       if (queueFull) {
         // Fastmatch: return if this hit is not competitive
         final int cmp = reverseMul * comparator.compareBottom(doc);
-        if (cmp < 0 || (cmp == 0 && doc + docBase > bottom.docID)) {
+        if (cmp < 0 || (cmp == 0 && doc + docBase > bottom.doc)) {
           return;
         }
         
@@ -280,7 +280,7 @@
     }
     
     final void updateBottom(int doc, float score) {
-      bottom.docID = docBase + doc;
+      bottom.doc = docBase + doc;
       bottom.score = score;
       bottom =  pq.updateTop();
     }
@@ -347,7 +347,7 @@
       if (queueFull) {
         // Fastmatch: return if this hit is not competitive
         final int cmp = reverseMul * comparator.compareBottom(doc);
-        if (cmp < 0 || (cmp == 0 && doc + docBase > bottom.docID)) {
+        if (cmp < 0 || (cmp == 0 && doc + docBase > bottom.doc)) {
           return;
         }
         
@@ -392,7 +392,7 @@
     
     final void updateBottom(int doc) {
       // bottom.score is already set to Float.NaN in add().
-      bottom.docID = docBase + doc;
+      bottom.doc = docBase + doc;
       bottom = pq.updateTop();
     }
 
@@ -488,7 +488,7 @@
             break;
           } else if (i == comparators.length - 1) {
             // This is the equals case.
-            if (doc + docBase > bottom.docID) {
+            if (doc + docBase > bottom.doc) {
               // Definitely not competitive
               return;
             }
@@ -545,7 +545,7 @@
     }
     
     final void updateBottom(int doc, float score) {
-      bottom.docID = docBase + doc;
+      bottom.doc = docBase + doc;
       bottom.score = score;
       bottom =  pq.updateTop();
     }
@@ -640,7 +640,7 @@
             break;
           } else if (i == comparators.length - 1) {
             // This is the equals case.
-            if (doc + docBase > bottom.docID) {
+            if (doc + docBase > bottom.doc) {
               // Definitely not competitive
               return;
             }
@@ -695,7 +695,7 @@
     }
     
     final void updateBottom(int doc, float score) {
-      bottom.docID = docBase + doc;
+      bottom.doc = docBase + doc;
       bottom.score = score;
       bottom = pq.updateTop();
     }
@@ -788,7 +788,7 @@
             break;
           } else if (i == comparators.length - 1) {
             // This is the equals case.
-            if (doc + docBase > bottom.docID) {
+            if (doc + docBase > bottom.doc) {
               // Definitely not competitive
               return;
             }
@@ -972,7 +972,7 @@
     } else {
       for (int i = howMany - 1; i >= 0; i--) {
         Entry entry = pq.pop();
-        results[i] = new FieldDoc(entry.docID, entry.score);
+        results[i] = new FieldDoc(entry.doc, entry.score);
       }
     }
   }



Mime
View raw message