lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r609780 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/index/SegmentTermEnum.java src/test/org/apache/lucene/index/TestSegmentTermEnum.java
Date Mon, 07 Jan 2008 21:15:49 GMT
Author: mikemccand
Date: Mon Jan  7 13:15:48 2008
New Revision: 609780

URL: http://svn.apache.org/viewvc?rev=609780&view=rev
Log:
LUCENE-508: make sure SegmentTermEnum.prev() is accurate (= last term) after next() returns
false

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentTermEnum.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentTermEnum.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=609780&r1=609779&r2=609780&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Mon Jan  7 13:15:48 2008
@@ -213,7 +213,11 @@
     
 28. LUCENE-749: ChainedFilter behavior fixed when logic of 
     first filter is ANDNOT.  (Antonio Bruno via Doron Cohen)
-    
+
+29. LUCENE-508: Make sure SegmentTermEnum.prev() is accurate (= last
+    term) after next() returns false.  (Steven Tamm via Mike
+    McCandless)
+
     
 New features
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/SegmentTermEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/SegmentTermEnum.java?rev=609780&r1=609779&r2=609780&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/SegmentTermEnum.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/SegmentTermEnum.java Mon Jan  7 13:15:48
2008
@@ -114,6 +114,7 @@
   /** Increments the enumeration to the next element.  True if one exists.*/
   public final boolean next() throws IOException {
     if (position++ >= size - 1) {
+      prevBuffer.set(termBuffer);
       termBuffer.reset();
       return false;
     }

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentTermEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentTermEnum.java?rev=609780&r1=609779&r2=609780&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentTermEnum.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentTermEnum.java Mon Jan  7
13:15:48 2008
@@ -30,6 +30,7 @@
 import org.apache.lucene.index.TermEnum;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.store.MockRAMDirectory;
 
 /**
  * @author goller
@@ -64,6 +65,23 @@
 
     // verify document frequency of terms in an optimized index
     verifyDocFreq();
+  }
+
+  public void testPrevTermAtEnd() throws IOException
+  {
+    Directory dir = new MockRAMDirectory();
+    IndexWriter writer  = new IndexWriter(dir, new WhitespaceAnalyzer(), true);
+    addDoc(writer, "aaa bbb");
+    writer.close();
+    IndexReader reader = IndexReader.open(dir);
+    SegmentTermEnum termEnum = (SegmentTermEnum) reader.terms();
+    assertTrue(termEnum.next());
+    assertEquals("aaa", termEnum.term().text());
+    assertTrue(termEnum.next());
+    assertEquals("aaa", termEnum.prev().text());
+    assertEquals("bbb", termEnum.term().text());
+    assertFalse(termEnum.next());
+    assertEquals("bbb", termEnum.prev().text());
   }
 
   private void verifyDocFreq()



Mime
View raw message