lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r928133 - in /lucene/dev/trunk/solr: CHANGES.txt src/java/org/apache/solr/analysis/KeepWordFilter.java src/java/org/apache/solr/analysis/KeepWordFilterFactory.java src/test/org/apache/solr/analysis/TestKeepWordFilter.java
Date Sat, 27 Mar 2010 03:44:06 GMT
Author: yonik
Date: Sat Mar 27 03:44:06 2010
New Revision: 928133

URL: http://svn.apache.org/viewvc?rev=928133&view=rev
Log:
SOLR-1850: don't copy word set for each KeepWordFilter instance

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/src/java/org/apache/solr/analysis/KeepWordFilter.java
    lucene/dev/trunk/solr/src/java/org/apache/solr/analysis/KeepWordFilterFactory.java
    lucene/dev/trunk/solr/src/test/org/apache/solr/analysis/TestKeepWordFilter.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=928133&r1=928132&r2=928133&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Sat Mar 27 03:44:06 2010
@@ -235,6 +235,9 @@ Bug Fixes
 * SOLR-1797: fix ConcurrentModificationException and potential memory
   leaks in ResourceLoader. (yonik)
 
+* SOLR-1850: change KeepWordFilter so a new word set is not created for
+  each instance (John Wang via yonik)
+
 Other Changes
 ----------------------
 

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/analysis/KeepWordFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/analysis/KeepWordFilter.java?rev=928133&r1=928132&r2=928133&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/analysis/KeepWordFilter.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/analysis/KeepWordFilter.java Sat Mar 27
03:44:06 2010
@@ -39,8 +39,14 @@ public final class KeepWordFilter extend
   private final TermAttribute termAtt;
 
   public KeepWordFilter(TokenStream in, Set<String> words, boolean ignoreCase ) {
+    this(in, new CharArraySet(words, ignoreCase));
+  }
+
+  /** The words set passed to this constructor will be directly used by this filter
+   * and should not be modified, */
+  public KeepWordFilter(TokenStream in, CharArraySet words) {
     super(in);
-    this.words = new CharArraySet(words, ignoreCase);
+    this.words = words;
     this.termAtt = (TermAttribute)addAttribute(TermAttribute.class);
   }
 

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/analysis/KeepWordFilterFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/analysis/KeepWordFilterFactory.java?rev=928133&r1=928132&r2=928133&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/analysis/KeepWordFilterFactory.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/analysis/KeepWordFilterFactory.java Sat
Mar 27 03:44:06 2010
@@ -72,10 +72,13 @@ public class KeepWordFilterFactory exten
 
   public void setIgnoreCase(boolean ignoreCase) {
     this.ignoreCase = ignoreCase;
+    if (words != null) {
+      words = new CharArraySet(words, ignoreCase);
+    }
   }
 
   public KeepWordFilter create(TokenStream input) {
-    return new KeepWordFilter(input, (Set)words, ignoreCase);
+    return new KeepWordFilter(input, words);
   }
 
   public CharArraySet getWords() {

Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/analysis/TestKeepWordFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/analysis/TestKeepWordFilter.java?rev=928133&r1=928132&r2=928133&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/analysis/TestKeepWordFilter.java (original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/analysis/TestKeepWordFilter.java Sat Mar
27 03:44:06 2010
@@ -66,10 +66,12 @@ public class TestKeepWordFilter extends 
     assertTokenStreamContents(stream, new String[] { "aaa", "BBB" });
     
     // Now force case
+    factory = new KeepWordFilterFactory();
     args = new HashMap<String, String>();
     args.put( "ignoreCase", "false" );
     factory.init( args );
     factory.inform( loader );
+    factory.setWords( words );    
     assertFalse(factory.isIgnoreCase());
     stream = factory.create(new WhitespaceTokenizer(new StringReader(input)));
     assertTokenStreamContents(stream, new String[] { "aaa" });



Mime
View raw message