lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r764596 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/document/Field.java src/java/org/apache/lucene/index/FieldInfos.java src/java/org/apache/lucene/index/FieldsReader.java
Date Mon, 13 Apr 2009 20:07:28 GMT
Author: mikemccand
Date: Mon Apr 13 20:07:28 2009
New Revision: 764596

URL: http://svn.apache.org/viewvc?rev=764596&view=rev
Log:
LUCENE-1600: don't over-intern String field names

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/FieldInfos.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=764596&r1=764595&r2=764596&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Mon Apr 13 20:07:28 2009
@@ -164,6 +164,9 @@
     without a collator equal to one with a collator.
     (Mark Platvoet via Mark Miller) 
 
+11. LUCENE-1600: Don't call String.intern unnecessarily in some cases
+    when loading documents from the index.  (P Eger via Mike
+    McCandless)
 
 New features
 

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=764596&r1=764595&r2=764596&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 Mon Apr 13 20:07:28 2009
@@ -295,6 +295,28 @@
    * </ul> 
    */ 
   public Field(String name, String value, Store store, Index index, TermVector termVector)
{
+	  this(name, true, value, store, index, termVector);
+  }
+  
+  /**
+   * Create a field by specifying its name, value and how it will
+   * be saved in the index.
+   * 
+   * @param name The name of the field
+   * @param internName Whether to .intern() name or not
+   * @param value The string to process
+   * @param store Whether <code>value</code> should be stored in the index
+   * @param index Whether the field should be indexed, and if so, if it should
+   *  be tokenized before indexing 
+   * @param termVector Whether term vector should be stored
+   * @throws NullPointerException if name or value is <code>null</code>
+   * @throws IllegalArgumentException in any of the following situations:
+   * <ul> 
+   *  <li>the field is neither stored nor indexed</li> 
+   *  <li>the field is not indexed but termVector is <code>TermVector.YES</code></li>
+   * </ul> 
+   */ 
+  public Field(String name, boolean internName, String value, Store store, Index index, TermVector
termVector) {
     if (name == null)
       throw new NullPointerException("name cannot be null");
     if (value == null)
@@ -308,7 +330,11 @@
       throw new IllegalArgumentException("cannot store term vector information "
          + "for a field that is not indexed");
           
-    this.name = name.intern();        // field names are interned
+    if (internName) // field names are optionally interned
+      name = name.intern();        
+    
+    this.name = name; 
+    
     this.fieldsData = value;
 
     if (store == Store.YES){

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/FieldInfos.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/FieldInfos.java?rev=764596&r1=764595&r2=764596&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/FieldInfos.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/FieldInfos.java Mon Apr 13 20:07:28
2009
@@ -214,9 +214,9 @@
   private FieldInfo addInternal(String name, boolean isIndexed,
                                 boolean storeTermVector, boolean storePositionWithTermVector,

                                 boolean storeOffsetWithTermVector, boolean omitNorms, boolean
storePayloads, boolean omitTermFreqAndPositions) {
-    FieldInfo fi =
-      new FieldInfo(name, isIndexed, byNumber.size(), storeTermVector, storePositionWithTermVector,
-              storeOffsetWithTermVector, omitNorms, storePayloads, omitTermFreqAndPositions);
+    name = name.intern();
+    FieldInfo fi = new FieldInfo(name, isIndexed, byNumber.size(), storeTermVector, storePositionWithTermVector,
+                                 storeOffsetWithTermVector, omitNorms, storePayloads, omitTermFreqAndPositions);
     byNumber.add(fi);
     byName.put(name, fi);
     return fi;

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=764596&r1=764595&r2=764596&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 Mon Apr 13 20:07:28
2009
@@ -380,6 +380,7 @@
         final byte[] b = new byte[toRead];
         fieldsStream.readBytes(b, 0, b.length);
         f = new Field(fi.name,      // field name
+                false,
                 new String(uncompress(b), "UTF-8"), // uncompress the value and add as string
                 store,
                 index,
@@ -388,6 +389,7 @@
         f.setOmitNorms(fi.omitNorms);
       } else {
         f = new Field(fi.name,     // name
+      		false,
                 fieldsStream.readString(), // read value
                 store,
                 index,



Mime
View raw message