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 dn...@apache.org on 2005/06/07 23:46:51 UTC

svn commit: r189448 - /lucene/java/trunk/src/java/org/apache/lucene/search/Hit.java

Author: dnaber
Date: Tue Jun  7 14:46:50 2005
New Revision: 189448

URL: http://svn.apache.org/viewcvs?rev=189448&view=rev
Log:
if only score or id is accessed, don't load the document (as that causes
a disk access)

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/search/Hit.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/Hit.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/Hit.java?rev=189448&r1=189447&r2=189448&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/Hit.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/Hit.java Tue Jun  7 14:46:50 2005
@@ -28,8 +28,6 @@
  */
 public class Hit implements java.io.Serializable {
 
-  private float score;
-  private int id;
   private Document doc = null;
 
   private boolean resolved = false;
@@ -63,8 +61,7 @@
    * @see Hits#score(int)
    */
   public float getScore() throws IOException {
-    if (!resolved) fetchTheHit();
-    return score;
+    return hits.score(hitNumber);
   }
 
   /**
@@ -73,14 +70,11 @@
    * @see Hits#id(int)
    */
   public int getId() throws IOException {
-    if (!resolved) fetchTheHit();
-    return id;
+    return hits.id(hitNumber);
   }
 
   private void fetchTheHit() throws IOException {
     doc = hits.doc(hitNumber);
-    score = hits.score(hitNumber);
-    id = hits.id(hitNumber);
     resolved = true;
   }