lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r883076 - in /lucene/java/branches/lucene_3_0: ./ contrib/ contrib/highlighter/src/test/ src/java/org/apache/lucene/analysis/ src/java/org/apache/lucene/search/ src/java/org/apache/lucene/util/ src/test/org/apache/lucene/analysis/ src/test/...
Date Sun, 22 Nov 2009 13:27:28 GMT
Author: uschindler
Date: Sun Nov 22 13:27:27 2009
New Revision: 883076

URL: http://svn.apache.org/viewvc?rev=883076&view=rev
Log:
merge to 3.0

Modified:
    lucene/java/branches/lucene_3_0/   (props changed)
    lucene/java/branches/lucene_3_0/CHANGES.txt   (contents, props changed)
    lucene/java/branches/lucene_3_0/contrib/   (props changed)
    lucene/java/branches/lucene_3_0/contrib/CHANGES.txt   (props changed)
    lucene/java/branches/lucene_3_0/contrib/highlighter/src/test/   (props changed)
    lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/analysis/package.html
    lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/search/NumericRangeQuery.java
    lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/util/AttributeSource.java
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestDateTools.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestNumberTools.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
  (props changed)
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
    lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/util/TestAttributeSource.java

Propchange: lucene/java/branches/lucene_3_0/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 22 13:27:27 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4:748824
 /lucene/java/branches/lucene_2_9:817269-818600,825998,829134,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests:818601-821336
-/lucene/java/trunk:881213,881315,881466,881819,882374
+/lucene/java/trunk:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075

Modified: lucene/java/branches/lucene_3_0/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/CHANGES.txt?rev=883076&r1=883075&r2=883076&view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/CHANGES.txt (original)
+++ lucene/java/branches/lucene_3_0/CHANGES.txt Sun Nov 22 13:27:27 2009
@@ -160,6 +160,9 @@
 * LUCENE-2013: SpanRegexQuery does not work with QueryScorer.
   (Benjamin Keil via Mark Miller)
 
+* LUCENE-2088: addAttribute() should only accept interfaces that
+  extend Attribute. (Shai Erera, Uwe Schindler)
+
 New features
 
 * LUCENE-1933: Provide a convenience AttributeFactory that creates a
@@ -181,6 +184,9 @@
 * LUCENE-2006: Optimization of FieldDocSortedHitQueue to always
   use Comparable<?> interface.  (Uwe Schindler, Mark Miller)
 
+* LUCENE-2087: Remove recursion in NumericRangeTermEnum.
+  (Uwe Schindler)
+
 Build
 
 * LUCENE-486: Remove test->demo dependencies. (Michael Busch)

Propchange: lucene/java/branches/lucene_3_0/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 22 13:27:27 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/CHANGES.txt:748824
 /lucene/java/branches/lucene_2_9/CHANGES.txt:817269-818600,825998,829134,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/CHANGES.txt:818601-821336
-/lucene/java/trunk/CHANGES.txt:881213,881315,881466,882374,882464
+/lucene/java/trunk/CHANGES.txt:881213,881315,881466,882374,882464,882807,882888,882977,883074-883075

Propchange: lucene/java/branches/lucene_3_0/contrib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 22 13:27:27 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/contrib:748824
 /lucene/java/branches/lucene_2_9/contrib:817269-818600,825998,829134,829816,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib:818601-821336
-/lucene/java/trunk/contrib:881213,881315,881466,881819,882374
+/lucene/java/trunk/contrib:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075

Propchange: lucene/java/branches/lucene_3_0/contrib/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 22 13:27:27 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/contrib/CHANGES.txt:748824
 /lucene/java/branches/lucene_2_9/contrib/CHANGES.txt:817269-818600,825998,826775,829134,829816,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib/CHANGES.txt:818601-821336
-/lucene/java/trunk/contrib/CHANGES.txt:881213,881315,881466,881819,882374
+/lucene/java/trunk/contrib/CHANGES.txt:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075

Propchange: lucene/java/branches/lucene_3_0/contrib/highlighter/src/test/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 22 13:27:27 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/contrib/highlighter/src/test:748824
 /lucene/java/branches/lucene_2_9/contrib/highlighter/src/test:817269-818600,825998,826775,829134,829816,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib/highlighter/src/test:818601-821336
-/lucene/java/trunk/contrib/highlighter/src/test:881213,881315,881466,881819,882374
+/lucene/java/trunk/contrib/highlighter/src/test:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075

Modified: lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/analysis/package.html
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/analysis/package.html?rev=883076&r1=883075&r2=883076&view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/analysis/package.html (original)
+++ lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/analysis/package.html Sun Nov
22 13:27:27 2009
@@ -140,7 +140,6 @@
       TokenStream ts = analyzer.tokenStream("myfield",new StringReader("some text goes here"));
       while (ts.incrementToken()) {
         System.out.println("token: "+ts));
-        t = ts.next();
       }
   </PRE>
 </p>

Propchange: lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 22 13:27:27 2009
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:748824
 /lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:817269-818600,825998,829134,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:818601-821336
-/lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:881213,881315,881466,881984,882374
+/lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:881213,881315,881466,881984,882374,882807,882888,882977,883074-883075

Modified: lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/search/NumericRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/search/NumericRangeQuery.java?rev=883076&r1=883075&r2=883076&view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/search/NumericRangeQuery.java
(original)
+++ lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/search/NumericRangeQuery.java
Sun Nov 22 13:27:27 2009
@@ -27,6 +27,7 @@
 import org.apache.lucene.util.StringHelper;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermEnum;
 
 /**
  * <p>A {@link Query} that matches numeric values within a
@@ -389,6 +390,7 @@
 
     private final IndexReader reader;
     private final LinkedList<String> rangeBounds = new LinkedList<String>();
+    private final Term termTemplate = new Term(field);
     private String currentUpperBound = null;
 
     NumericRangeTermEnum(final IndexReader reader) throws IOException {
@@ -482,10 +484,15 @@
     /** this is a dummy, it is not used by this class. */
     @Override
     protected boolean endEnum() {
-      assert false; // should never be called
-      return (currentTerm != null);
+      throw new UnsupportedOperationException("not implemented");
     }
 
+    /** this is a dummy, it is not used by this class. */
+    @Override
+    protected void setEnum(TermEnum tenum) {
+      throw new UnsupportedOperationException("not implemented");
+    }
+    
     /**
      * Compares if current upper bound is reached,
      * this also updates the term count for statistics.
@@ -504,29 +511,38 @@
       // if a current term exists, the actual enum is initialized:
       // try change to next term, if no such term exists, fall-through
       if (currentTerm != null) {
-        assert actualEnum!=null;
+        assert actualEnum != null;
         if (actualEnum.next()) {
           currentTerm = actualEnum.term();
-          if (termCompare(currentTerm)) return true;
+          if (termCompare(currentTerm))
+            return true;
         }
       }
+      
       // if all above fails, we go forward to the next enum,
       // if one is available
       currentTerm = null;
-      if (rangeBounds.size() < 2) return false;
-      // close the current enum and read next bounds
-      if (actualEnum != null) {
-        actualEnum.close();
-        actualEnum = null;
+      while (rangeBounds.size() >= 2) {
+        assert rangeBounds.size() % 2 == 0;
+        // close the current enum and read next bounds
+        if (actualEnum != null) {
+          actualEnum.close();
+          actualEnum = null;
+        }
+        final String lowerBound = rangeBounds.removeFirst();
+        this.currentUpperBound = rangeBounds.removeFirst();
+        // create a new enum
+        actualEnum = reader.terms(termTemplate.createTerm(lowerBound));
+        currentTerm = actualEnum.term();
+        if (currentTerm != null && termCompare(currentTerm))
+          return true;
+        // clear the current term for next iteration
+        currentTerm = null;
       }
-      final String lowerBound = rangeBounds.removeFirst();
-      this.currentUpperBound = rangeBounds.removeFirst();
-      // this call recursively uses next(), if no valid term in
-      // next enum found.
-      // if this behavior is changed/modified in the superclass,
-      // this enum will not work anymore!
-      setEnum(reader.terms(new Term(field, lowerBound)));
-      return (currentTerm != null);
+      
+      // no more sub-range enums available
+      assert rangeBounds.size() == 0 && currentTerm == null;
+      return false;
     }
 
     /** Closes the enumeration to further activity, freeing resources.  */

Modified: lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/util/AttributeSource.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/util/AttributeSource.java?rev=883076&r1=883075&r2=883076&view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/util/AttributeSource.java (original)
+++ lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/util/AttributeSource.java Sun
Nov 22 13:27:27 2009
@@ -224,6 +224,12 @@
   public <A extends Attribute> A addAttribute(Class<A> attClass) {
     AttributeImpl attImpl = attributes.get(attClass);
     if (attImpl == null) {
+      if (!(attClass.isInterface() && Attribute.class.isAssignableFrom(attClass)))
{
+        throw new IllegalArgumentException(
+          "addAttribute() only accepts an interface that extends Attribute, but " +
+          attClass.getName() + " does not fulfil this contract."
+        );
+      }
       addAttributeImpl(attImpl = this.factory.createAttributeInstance(attClass));
     }
     return attClass.cast(attImpl);

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 22 13:27:27 2009
@@ -1,3 +1,3 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:825998,829134,829881,831036
-/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:881213,881315,881466,881819,882374
+/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestDateTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 22 13:27:27 2009
@@ -1,3 +1,3 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestDateTools.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestDateTools.java:825998,829134,829881,831036
-/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java:881213,881315,881466,881819,882374
+/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestNumberTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 22 13:27:27 2009
@@ -1,3 +1,3 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestNumberTools.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestNumberTools.java:825998,829134,829881,831036
-/lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java:881213,881315,881466,881819,882374
+/lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075

Propchange: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 22 13:27:27 2009
@@ -1,3 +1,3 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:825998,829134,829881,831036
-/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:881213,881315,881466,881819,882374
+/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075

Modified: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java?rev=883076&r1=883075&r2=883076&view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
(original)
+++ lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
Sun Nov 22 13:27:27 2009
@@ -25,6 +25,7 @@
 import org.apache.lucene.document.NumericField;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriter.MaxFieldLength;
+import org.apache.lucene.index.Term;
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.NumericUtils;
@@ -437,4 +438,37 @@
     assertFalse(q2.equals(q1));
   }
   
+  private void testEnum(int lower, int upper) throws Exception {
+    NumericRangeQuery<Integer> q = NumericRangeQuery.newIntRange("field4", 4, lower,
upper, true, true);
+    FilteredTermEnum termEnum = q.getEnum(searcher.getIndexReader());
+    try {
+      int count = 0;
+      do {
+        final Term t = termEnum.term();
+        if (t != null) {
+          final int val = NumericUtils.prefixCodedToInt(t.text());
+          assertTrue("value not in bounds", val >= lower && val <= upper);
+          count++;
+        } else break;
+      } while (termEnum.next());
+      assertFalse(termEnum.next());
+      System.out.println("TermEnum on 'field4' for range [" + lower + "," + upper + "] contained
" + count + " terms.");
+    } finally {
+      termEnum.close();
+    }
+  }
+  
+  public void testEnum() throws Exception {
+    int count=3000;
+    int lower=(distance*3/2)+startOffset, upper=lower + count*distance + (distance/3);
+    // test enum with values
+    testEnum(lower, upper);
+    // test empty enum
+    testEnum(upper, lower);
+    // test empty enum outside of bounds
+    lower = distance*noDocs+startOffset;
+    upper = 2 * lower;
+    testEnum(lower, upper);
+  }
+  
 }

Modified: lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/util/TestAttributeSource.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/util/TestAttributeSource.java?rev=883076&r1=883075&r2=883076&view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/util/TestAttributeSource.java
(original)
+++ lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/util/TestAttributeSource.java
Sun Nov 22 13:27:27 2009
@@ -141,4 +141,18 @@
     assertTrue("TypeAttribute is not implemented by TypeAttributeImpl",
       src.addAttribute(TypeAttribute.class) instanceof TypeAttributeImpl);
   }
+  
+  public void testInvalidArguments() throws Exception {
+    try {
+      AttributeSource src = new AttributeSource();
+      src.addAttribute(Token.class);
+      fail("Should throw IllegalArgumentException");
+    } catch (IllegalArgumentException iae) {}
+    
+    try {
+      AttributeSource src = new AttributeSource(Token.TOKEN_ATTRIBUTE_FACTORY);
+      src.addAttribute(Token.class);
+      fail("Should throw IllegalArgumentException");
+    } catch (IllegalArgumentException iae) {}
+  }
 }



Mime
View raw message