if only score or id is accessed, don't load the document (as that causes

a disk access)

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@189448 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Daniel Naber 2005-06-07 21:46:50 +00:00
parent 47180b6983
commit 748b2419e9
1 changed files with 2 additions and 8 deletions

View File

@ -28,8 +28,6 @@ import org.apache.lucene.document.Document;
*/
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 @@ public class Hit implements java.io.Serializable {
* @see Hits#score(int)
*/
public float getScore() throws IOException {
if (!resolved) fetchTheHit();
return score;
return hits.score(hitNumber);
}
/**
@ -73,14 +70,11 @@ public class Hit implements java.io.Serializable {
* @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;
}