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 { public class Hit implements java.io.Serializable {
private float score;
private int id;
private Document doc = null; private Document doc = null;
private boolean resolved = false; private boolean resolved = false;
@ -63,8 +61,7 @@ public class Hit implements java.io.Serializable {
* @see Hits#score(int) * @see Hits#score(int)
*/ */
public float getScore() throws IOException { public float getScore() throws IOException {
if (!resolved) fetchTheHit(); return hits.score(hitNumber);
return score;
} }
/** /**
@ -73,14 +70,11 @@ public class Hit implements java.io.Serializable {
* @see Hits#id(int) * @see Hits#id(int)
*/ */
public int getId() throws IOException { public int getId() throws IOException {
if (!resolved) fetchTheHit(); return hits.id(hitNumber);
return id;
} }
private void fetchTheHit() throws IOException { private void fetchTheHit() throws IOException {
doc = hits.doc(hitNumber); doc = hits.doc(hitNumber);
score = hits.score(hitNumber);
id = hits.id(hitNumber);
resolved = true; resolved = true;
} }