lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r824149 - in /lucene/java/branches/lucene_2_9: ./ src/java/org/apache/lucene/analysis/ src/java/org/apache/lucene/search/ src/test/org/apache/lucene/analysis/ src/test/org/apache/lucene/search/
Date Sun, 11 Oct 2009 20:57:15 GMT
Author: uschindler
Date: Sun Oct 11 20:57:15 2009
New Revision: 824149

URL: http://svn.apache.org/viewvc?rev=824149&view=rev
Log:
Merge some changes also to 2.9. Add a new test here for backwards layer.

Modified:
    lucene/java/branches/lucene_2_9/   (props changed)
    lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/analysis/TokenStream.java
    lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/search/NumericRangeQuery.java
    lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/analysis/TestTokenStreamBWComp.java
    lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
    lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java

Propchange: lucene/java/branches/lucene_2_9/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Oct 11 20:57:15 2009
@@ -1 +1,2 @@
 /lucene/java/branches/lucene_2_4:748824
+/lucene/java/trunk:824125

Modified: lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/analysis/TokenStream.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/analysis/TokenStream.java?rev=824149&r1=824148&r2=824149&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/analysis/TokenStream.java (original)
+++ lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/analysis/TokenStream.java Sun
Oct 11 20:57:15 2009
@@ -287,6 +287,11 @@
    * the next token. Implementing classes must implement this method and update
    * the appropriate {@link AttributeImpl}s with the attributes of the next
    * token.
+   * <P>
+   * The producer must make no assumptions about the attributes after the method
+   * has been returned: the caller may arbitrarily change it. If the producer
+   * needs to preserve the state for subsequent calls, it can use
+   * {@link #captureState} to create a copy of the current attribute state.
    * <p>
    * This method is called for every token of a document, so an efficient
    * implementation is crucial for good performance. To avoid calls to

Modified: lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/search/NumericRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/search/NumericRangeQuery.java?rev=824149&r1=824148&r2=824149&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/search/NumericRangeQuery.java
(original)
+++ lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/search/NumericRangeQuery.java
Sun Oct 11 20:57:15 2009
@@ -191,6 +191,11 @@
         // should never happen
         throw new IllegalArgumentException("valSize must be 32 or 64");
     }
+    
+    // shortcut if upper bound == lower bound
+    if (min != null && min.equals(max)) {
+      setRewriteMethod(CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE);
+    }
   }
   
   /**

Modified: lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/analysis/TestTokenStreamBWComp.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/analysis/TestTokenStreamBWComp.java?rev=824149&r1=824148&r2=824149&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/analysis/TestTokenStreamBWComp.java
(original)
+++ lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/analysis/TestTokenStreamBWComp.java
Sun Oct 11 20:57:15 2009
@@ -22,6 +22,8 @@
 
 import org.apache.lucene.index.Payload;
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.Attribute;
+import org.apache.lucene.util.AttributeImpl;
 import org.apache.lucene.analysis.tokenattributes.*;
 
 /** This class tests some special cases of backwards compatibility when using the new TokenStream
API with old analyzers */
@@ -241,6 +243,15 @@
     }   
   }
   
+  public interface SenselessAttribute extends Attribute {}
+  
+  public static final class SenselessAttributeImpl extends AttributeImpl implements SenselessAttribute
{
+    public void copyTo(AttributeImpl target) {}
+    public void clear() {}
+    public boolean equals(Object o) { return (o instanceof SenselessAttributeImpl); }
+    public int hashCode() { return 0; }
+  }
+  
   // test if tokenization fails, if only the new API is allowed and an old TokenStream is
in the chain
   public void testOnlyNewAPI() throws IOException {
     TokenStream.setOnlyUseNewAPI(true);
@@ -277,6 +288,8 @@
         stream.addAttribute(PositionIncrementAttribute.class) instanceof PositionIncrementAttributeImpl);
       assertTrue("TypeAttribute is not implemented by TypeAttributeImpl",
         stream.addAttribute(TypeAttribute.class) instanceof TypeAttributeImpl);
+      assertTrue("SenselessAttribute is not implemented by SenselessAttributeImpl",
+        stream.addAttribute(SenselessAttribute.class) instanceof SenselessAttributeImpl);
         
       // try to call old API, this should fail
       try {
@@ -314,6 +327,9 @@
         stream.addAttribute(PositionIncrementAttribute.class) instanceof TokenWrapper);
       assertTrue("TypeAttribute is not implemented by TokenWrapper",
         stream.addAttribute(TypeAttribute.class) instanceof TokenWrapper);
+      // This one is not implemented by TokenWrapper:
+      assertTrue("SenselessAttribute is not implemented by SenselessAttributeImpl",
+        stream.addAttribute(SenselessAttribute.class) instanceof SenselessAttributeImpl);
       
     } finally {
       TokenStream.setOnlyUseNewAPI(false);

Modified: lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java?rev=824149&r1=824148&r2=824149&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
(original)
+++ lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
Sun Oct 11 20:57:15 2009
@@ -159,6 +159,15 @@
       DocIdSet.EMPTY_DOCIDSET, f.getDocIdSet(searcher.getIndexReader()));
   }
   
+  public void testOneMatchQuery() throws Exception {
+    NumericRangeQuery q = NumericRangeQuery.newIntRange("ascfield8", 8, new Integer(1000),
new Integer(1000), true, true);
+    assertSame(MultiTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE, q.getRewriteMethod());
+    TopDocs topDocs = searcher.search(q, noDocs);
+    ScoreDoc[] sd = topDocs.scoreDocs;
+    assertNotNull(sd);
+    assertEquals("Score doc count", 1, sd.length );
+  }
+  
   private void testLeftOpenRange(int precisionStep) throws Exception {
     String field="field"+precisionStep;
     int count=3000;

Modified: lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java?rev=824149&r1=824148&r2=824149&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
(original)
+++ lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
Sun Oct 11 20:57:15 2009
@@ -167,6 +167,15 @@
       DocIdSet.EMPTY_DOCIDSET, f.getDocIdSet(searcher.getIndexReader()));
   }
   
+  public void testOneMatchQuery() throws Exception {
+    NumericRangeQuery q = NumericRangeQuery.newLongRange("ascfield8", 8, new Long(1000L),
new Long(1000L), true, true);
+    assertSame(MultiTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE, q.getRewriteMethod());
+    TopDocs topDocs = searcher.search(q, noDocs);
+    ScoreDoc[] sd = topDocs.scoreDocs;
+    assertNotNull(sd);
+    assertEquals("Score doc count", 1, sd.length );
+  }
+  
   private void testLeftOpenRange(int precisionStep) throws Exception {
     String field="field"+precisionStep;
     int count=3000;



Mime
View raw message