LUCENE-1217: use Field.isBinary instead of 'instanceof'

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@636139 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2008-03-11 22:53:50 +00:00
parent 9dc489edb1
commit a6258c76fd
3 changed files with 8 additions and 3 deletions

View File

@ -133,6 +133,10 @@ Optimizations
SegmentTermEnum is null for every call of scanTo().
(Christian Kohlschuetter via Michael Busch)
4. LUCENE-1217: Internal to Field.java, use isBinary instead of
runtime type checking for possible speedup of binaryValue().
(Eks Dev via Mike McCandless)
Documentation
Build

View File

@ -148,7 +148,7 @@ public final class Field extends AbstractField implements Fieldable, Serializabl
/** The value of the field in Binary, or null. If null, the Reader value,
* String value, or TokenStream value is used. Exactly one of stringValue(),
* readerValue(), binaryValue(), and tokenStreamValue() must be set. */
public byte[] binaryValue() { return fieldsData instanceof byte[] ? (byte[])fieldsData : null; }
public byte[] binaryValue() { return isBinary ? (byte[])fieldsData : null; }
/** The value of the field as a TokesStream, or null. If null, the Reader value,
* String value, or binary value is used. Exactly one of stringValue(),

View File

@ -416,7 +416,7 @@ final class FieldsReader {
if (fieldsData == null) {
final byte[] b = new byte[toRead];
IndexInput localFieldsStream = getFieldStream();
//Throw this IO Exception since IndexREader.document does so anyway, so probably not that big of a change for people
//Throw this IO Exception since IndexReader.document does so anyway, so probably not that big of a change for people
//since they are already handling this exception when getting the document
try {
localFieldsStream.seek(pointer);
@ -426,11 +426,12 @@ final class FieldsReader {
} else {
fieldsData = b;
}
isBinary = true;
} catch (IOException e) {
throw new FieldReaderException(e);
}
}
return fieldsData instanceof byte[] ? (byte[]) fieldsData : null;
return isBinary ? (byte[]) fieldsData : null;
}
/** The value of the field as a Reader, or null. If null, the String value,