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 mi...@apache.org on 2008/03/11 23:53:56 UTC

svn commit: r636139 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/document/Field.java src/java/org/apache/lucene/index/FieldsReader.java

Author: mikemccand
Date: Tue Mar 11 15:53:50 2008
New Revision: 636139

URL: http://svn.apache.org/viewvc?rev=636139&view=rev
Log:
LUCENE-1217: use Field.isBinary instead of 'instanceof'

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/document/Field.java
    lucene/java/trunk/src/java/org/apache/lucene/index/FieldsReader.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=636139&r1=636138&r2=636139&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Tue Mar 11 15:53:50 2008
@@ -133,6 +133,10 @@
     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

Modified: lucene/java/trunk/src/java/org/apache/lucene/document/Field.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/document/Field.java?rev=636139&r1=636138&r2=636139&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/document/Field.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/document/Field.java Tue Mar 11 15:53:50 2008
@@ -148,7 +148,7 @@
   /** 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(), 

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/FieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/FieldsReader.java?rev=636139&r1=636138&r2=636139&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/FieldsReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/FieldsReader.java Tue Mar 11 15:53:50 2008
@@ -416,7 +416,7 @@
       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 @@
           } 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,