lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r802095 - in /lucene/java/trunk/contrib: analyzers/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
Date Fri, 07 Aug 2009 17:19:53 GMT
Author: uschindler
Date: Fri Aug  7 17:19:53 2009
New Revision: 802095

URL: http://svn.apache.org/viewvc?rev=802095&view=rev
Log:
LUCENE-1607: Change some more String.intern() in contrib

Modified:
    lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java
    lucene/java/trunk/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java

Modified: lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java?rev=802095&r1=802094&r2=802095&view=diff
==============================================================================
--- lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java
(original)
+++ lucene/java/trunk/contrib/analyzers/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java
Fri Aug  7 17:19:53 2009
@@ -22,6 +22,7 @@
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.StopFilter;
+import org.apache.lucene.util.StringHelper;
 
 import java.io.IOException;
 import java.io.Reader;
@@ -137,7 +138,7 @@
    */
   public int addStopWords(IndexReader reader, String fieldName, int maxDocFreq) throws IOException
{
     HashSet stopWords = new HashSet();
-    String internedFieldName = fieldName.intern();
+    String internedFieldName = StringHelper.intern(fieldName);
     TermEnum te = reader.terms(new Term(fieldName));
     Term term = te.term();
     while (term != null) {

Modified: lucene/java/trunk/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java?rev=802095&r1=802094&r2=802095&view=diff
==============================================================================
--- lucene/java/trunk/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
(original)
+++ lucene/java/trunk/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
Fri Aug  7 17:19:53 2009
@@ -323,24 +323,6 @@
    * @see Field#setBoost(float)
    */
   public void addField(String fieldName, TokenStream stream, float boost) {
-    /*
-     * Note that this method signature avoids having a user call new
-     * o.a.l.d.Field(...) which would be much too expensive due to the
-     * String.intern() usage of that class.
-     * 
-     * More often than not, String.intern() leads to serious performance
-     * degradations rather than improvements! If you're curious why, check
-     * out the JDK's native code, see how it oscillates multiple times back
-     * and forth between Java code and native code on each intern() call,
-     * only to end up using a plain vanilla java.util.HashMap on the Java
-     * heap for it's interned strings! String.equals() has a small cost
-     * compared to String.intern(), trust me. Application level interning
-     * (e.g. a HashMap per Directory/Index) typically leads to better
-     * solutions than frequent hidden low-level calls to String.intern().
-     * 
-     * Perhaps with some luck, Lucene's Field.java (and Term.java) and
-     * cousins could be fixed to not use String.intern(). Sigh :-(
-     */
     try {
       if (fieldName == null)
         throw new IllegalArgumentException("fieldName must not be null");



Mime
View raw message