lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r908475 - in /lucene/java/branches/flex_1458/src/java/org/apache/lucene: index/TermsEnum.java search/MultiTermQuery.java
Date Wed, 10 Feb 2010 12:50:47 GMT
Author: uschindler
Date: Wed Feb 10 12:50:47 2010
New Revision: 908475

URL: http://svn.apache.org/viewvc?rev=908475&view=rev
Log:
add some javadocs wording about the possibility to modify the EmptyEnum's attributes

Modified:
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermsEnum.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiTermQuery.java

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermsEnum.java?rev=908475&r1=908474&r2=908475&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermsEnum.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/TermsEnum.java Wed Feb
10 12:50:47 2010
@@ -114,7 +114,12 @@
   public abstract BytesRef.Comparator getComparator() throws IOException;
 
   /** An empty TermsEnum for quickly returning an empty instance e.g.
-   * in {@link org.apache.lucene.search.MultiTermQuery} */
+   * in {@link org.apache.lucene.search.MultiTermQuery}
+   * <p><em>Please note:</em> This enum should be unmodifiable,
+   * but it is currently possible to add Attributes to it.
+   * This should not be a problem, as the enum is always empty and
+   * the existence of unused Attributes does not matter.
+   */
   public static final TermsEnum EMPTY = new TermsEnum() {    
     @Override
     public SeekStatus seek(BytesRef term) { return SeekStatus.END; }
@@ -147,5 +152,10 @@
       
     @Override
     public BytesRef next() { return null; }
+    
+    @Override // make it synchronized here, to prevent double lazy init
+    public synchronized AttributeSource attributes() {
+      return super.attributes();
+    }
   };
 }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiTermQuery.java?rev=908475&r1=908474&r2=908475&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiTermQuery.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiTermQuery.java Wed
Feb 10 12:50:47 2010
@@ -176,10 +176,12 @@
     protected final int collectTerms(IndexReader reader, MultiTermQuery query, TermCollector
collector) throws IOException {
       final TermsEnum termsEnum = query.getTermsEnum(reader);
       if (termsEnum != null) {
-        final BoostAttribute boostAtt =
-          termsEnum.attributes().addAttribute(BoostAttribute.class);
         if (query.field == null)
           throw new NullPointerException("If you implement getTermsEnum(), you must specify
a non-null field in the constructor of MultiTermQuery.");
+        if (termsEnum == TermsEnum.EMPTY)
+          return 0;
+        final BoostAttribute boostAtt =
+          termsEnum.attributes().addAttribute(BoostAttribute.class);
         collector.boostAtt = boostAtt;
         int count = 0;
         BytesRef term;



Mime
View raw message