lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From busc...@apache.org
Subject svn commit: r555678 - in /lucene/java/trunk: CHANGES.txt src/java/org/apache/lucene/index/SegmentTermPositions.java src/test/org/apache/lucene/index/TestLazyProxSkipping.java
Date Thu, 12 Jul 2007 16:14:55 GMT
Author: buschmi
Date: Thu Jul 12 09:14:54 2007
New Revision: 555678

URL: http://svn.apache.org/viewvc?view=rev&rev=555678
Log:
LUCENE-955: Fixed SegmentTermPositions to work correctly with the first term in the dictionary.

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentTermPositions.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyProxSkipping.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?view=diff&rev=555678&r1=555677&r2=555678
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Thu Jul 12 09:14:54 2007
@@ -20,6 +20,9 @@
  1. LUCENE-933: QueryParser fixed to not produce empty sub 
     BooleanQueries "()" even if the Analyzer proudced no 
     tokens for input. (Doron Cohen)
+
+ 2. LUCENE-955: Fixed SegmentTermPositions to work correctly with the
+    first term in the dictionary. (Michael Busch)
     
 New features
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/SegmentTermPositions.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/SegmentTermPositions.java?view=diff&rev=555678&r1=555677&r2=555678
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/SegmentTermPositions.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/SegmentTermPositions.java Thu Jul 12
09:14:54 2007
@@ -35,7 +35,7 @@
   
   // these variables are being used to remember information
   // for a lazy skip
-  private long lazySkipPointer = 0;
+  private long lazySkipPointer = -1;
   private int lazySkipProxCount = 0;
   
   SegmentTermPositions(SegmentReader p) {
@@ -152,9 +152,9 @@
     // if it was not read yet
     skipPayload();
       
-    if (lazySkipPointer != 0) {
+    if (lazySkipPointer != -1) {
       proxStream.seek(lazySkipPointer);
-      lazySkipPointer = 0;
+      lazySkipPointer = -1;
     }
      
     if (lazySkipProxCount != 0) {

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyProxSkipping.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyProxSkipping.java?view=diff&rev=555678&r1=555677&r2=555678
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyProxSkipping.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyProxSkipping.java Thu Jul 12
09:14:54 2007
@@ -98,13 +98,41 @@
         assertEquals(numHits, hits.length());
         
         // check if the number of calls of seek() does not exceed the number of hits
-        assertEquals(numHits, this.seeksCounter);
+        assertTrue(this.seeksCounter <= numHits + 1);
     }
     
     public void testLazySkipping() throws IOException {
         // test whether only the minimum amount of seeks() are performed
         performTest(5);
         performTest(10);
+    }
+    
+    public void testSeek() throws IOException {
+        Directory directory = new RAMDirectory();
+        IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true);
+        for (int i = 0; i < 10; i++) {
+            Document doc = new Document();
+            doc.add(new Field(this.field, "a b", Field.Store.YES, Field.Index.TOKENIZED));
+            writer.addDocument(doc);
+        }
+        
+        writer.close();
+        IndexReader reader = IndexReader.open(directory);
+        TermPositions tp = reader.termPositions();
+        tp.seek(new Term(this.field, "b"));
+        for (int i = 0; i < 10; i++) {
+            tp.next();
+            assertEquals(tp.doc(), i);
+            assertEquals(tp.nextPosition(), 1);
+        }
+        tp.seek(new Term(this.field, "a"));
+        for (int i = 0; i < 10; i++) {
+            tp.next();
+            assertEquals(tp.doc(), i);
+            assertEquals(tp.nextPosition(), 0);
+        }
+        
+        
     }
     
 



Mime
View raw message