lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r792918 - in /lucene/java/trunk/src: java/org/apache/lucene/index/ test/org/apache/lucene/index/
Date Fri, 10 Jul 2009 12:31:17 GMT
Author: mikemccand
Date: Fri Jul 10 12:31:17 2009
New Revision: 792918

URL: http://svn.apache.org/viewvc?rev=792918&view=rev
Log:
LUCENE-1739: when computing FieldInfos.hasProx(), disregard un-indexed fields

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/index/FieldInfos.java
    lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java
    lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
    lucene/java/trunk/src/test/org/apache/lucene/index/index.24.cfs.zip
    lucene/java/trunk/src/test/org/apache/lucene/index/index.24.nocfs.zip

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/FieldInfos.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/FieldInfos.java?rev=792918&r1=792917&r2=792918&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/FieldInfos.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/FieldInfos.java Fri Jul 10 12:31:17
2009
@@ -122,9 +122,12 @@
   /** Returns true if any fields do not omitTermFreqAndPositions */
   boolean hasProx() {
     final int numFields = byNumber.size();
-    for(int i=0;i<numFields;i++)
-      if (!fieldInfo(i).omitTermFreqAndPositions)
+    for(int i=0;i<numFields;i++) {
+      final FieldInfo fi = fieldInfo(i);
+      if (fi.isIndexed && !fi.omitTermFreqAndPositions) {
         return true;
+      }
+    }
     return false;
   }
   

Modified: lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java?rev=792918&r1=792917&r2=792918&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/SegmentReader.java Fri Jul 10 12:31:17
2009
@@ -443,11 +443,7 @@
         instance.openDocStores();
       }
 
-      boolean anyProx = false;
-      final int numFields = instance.fieldInfos.size();
-      for(int i=0;!anyProx && i<numFields;i++)
-        if (!instance.fieldInfos.fieldInfo(i).omitTermFreqAndPositions)
-          anyProx = true;
+      boolean anyProx = instance.fieldInfos.hasProx();
 
       instance.tis = new TermInfosReader(cfsDir, instance.segment, instance.fieldInfos, readBufferSize);
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java?rev=792918&r1=792917&r2=792918&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java Fri
Jul 10 12:31:17 2009
@@ -209,22 +209,24 @@
             !oldName.startsWith("20.") &&
             !oldName.startsWith("21.") &&
             !oldName.startsWith("22.")) {
-          // Test on indices >= 2.3
-          assertEquals(5, fields.size());
-          Field f = (Field) d.getField("id");
-          assertEquals(""+i, f.stringValue());
 
-          f = (Field) d.getField("utf8");
-          assertEquals("Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd", f.stringValue());
+          if (d.getField("content3") == null) {
+            assertEquals(5, fields.size());
+            Field f = (Field) d.getField("id");
+            assertEquals(""+i, f.stringValue());
 
-          f = (Field) d.getField("autf8");
-          assertEquals("Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd", f.stringValue());
+            f = (Field) d.getField("utf8");
+            assertEquals("Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd",
f.stringValue());
+
+            f = (Field) d.getField("autf8");
+            assertEquals("Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd",
f.stringValue());
         
-          f = (Field) d.getField("content2");
-          assertEquals("here is more content with aaa aaa aaa", f.stringValue());
+            f = (Field) d.getField("content2");
+            assertEquals("here is more content with aaa aaa aaa", f.stringValue());
 
-          f = (Field) d.getField("fie\u2C77ld");
-          assertEquals("field with non-ascii name", f.stringValue());
+            f = (Field) d.getField("fie\u2C77ld");
+            assertEquals("field with non-ascii name", f.stringValue());
+          }
         }       
       } else
         // Only ID 7 is deleted
@@ -257,10 +259,16 @@
     dir.close();
   }
 
+  private int compare(String name, String v) {
+    int v0 = Integer.parseInt(name.substring(0, 2));
+    int v1 = Integer.parseInt(v);
+    return v0 - v1;
+  }
+
   /* Open pre-lockless index, add docs, do a delete &
    * setNorm, and search */
   public void changeIndexWithAdds(String dirName, boolean autoCommit) throws IOException
{
-
+    String origDirName = dirName;
     dirName = fullDir(dirName);
 
     Directory dir = FSDirectory.open(new File(dirName));
@@ -274,7 +282,13 @@
     }
 
     // make sure writer sees right total -- writer seems not to know about deletes in .del?
-    assertEquals("wrong doc count", 45, writer.docCount());
+    final int expected;
+    if (compare(origDirName, "24") < 0) {
+      expected = 45;
+    } else {
+      expected = 46;
+    }
+    assertEquals("wrong doc count", expected, writer.docCount());
     writer.close();
 
     // make sure searching sees right # hits
@@ -386,6 +400,13 @@
     assertEquals("wrong doc count", 35, writer.docCount());
     writer.close();
 
+    // open fresh writer so we get no prx file in the added segment
+    writer = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+    writer.setUseCompoundFile(doCFS);
+    writer.setMaxBufferedDocs(10);
+    addNoProxDoc(writer);
+    writer.close();
+
     // Delete one doc so we get a .del file:
     IndexReader reader = IndexReader.open(dir);
     Term searchTerm = new Term("id", "7");
@@ -492,6 +513,17 @@
     writer.addDocument(doc);
   }
 
+  private void addNoProxDoc(IndexWriter writer) throws IOException {
+    Document doc = new Document();
+    Field f = new Field("content3", "aaa", Field.Store.YES, Field.Index.ANALYZED);
+    f.setOmitTf(true);
+    doc.add(f);
+    f = new Field("content4", "aaa", Field.Store.YES, Field.Index.NO);
+    f.setOmitTf(true);
+    doc.add(f);
+    writer.addDocument(doc);
+  }
+
   private void rmDir(String dir) throws IOException {
     File fileDir = new File(fullDir(dir));
     if (fileDir.exists()) {

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/index.24.cfs.zip
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/index.24.cfs.zip?rev=792918&r1=792917&r2=792918&view=diff
==============================================================================
Binary files - no diff available.

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/index.24.nocfs.zip
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/index.24.nocfs.zip?rev=792918&r1=792917&r2=792918&view=diff
==============================================================================
Binary files - no diff available.



Mime
View raw message