lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1671808 - in /lucene/dev/trunk/lucene/memory/src: java/org/apache/lucene/index/memory/MemoryIndex.java test/org/apache/lucene/index/memory/TestMemoryIndex.java
Date Tue, 07 Apr 2015 11:21:29 GMT
Author: rmuir
Date: Tue Apr  7 11:21:29 2015
New Revision: 1671808

URL: http://svn.apache.org/r1671808
Log:
LUCENE-6402: MemoryIndex should pass TestUtil.checkReader

Modified:
    lucene/dev/trunk/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
    lucene/dev/trunk/lucene/memory/src/test/org/apache/lucene/index/memory/TestMemoryIndex.java

Modified: lucene/dev/trunk/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java?rev=1671808&r1=1671807&r2=1671808&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
(original)
+++ lucene/dev/trunk/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
Tue Apr  7 11:21:29 2015
@@ -441,7 +441,7 @@ public class MemoryIndex {
         sliceArray = info.sliceArray;
         sumTotalTermFreq = info.sumTotalTermFreq;
       } else {
-        fieldInfo = new FieldInfo(fieldName, fields.size(), false, false, this.storePayloads,
+        fieldInfo = new FieldInfo(fieldName, fields.size(), true, false, this.storePayloads,
             this.storeOffsets
                 ? IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS : IndexOptions.DOCS_AND_FREQS_AND_POSITIONS,
             DocValuesType.NONE, -1, Collections.emptyMap());

Modified: lucene/dev/trunk/lucene/memory/src/test/org/apache/lucene/index/memory/TestMemoryIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/memory/src/test/org/apache/lucene/index/memory/TestMemoryIndex.java?rev=1671808&r1=1671807&r2=1671808&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/memory/src/test/org/apache/lucene/index/memory/TestMemoryIndex.java
(original)
+++ lucene/dev/trunk/lucene/memory/src/test/org/apache/lucene/index/memory/TestMemoryIndex.java
Tue Apr  7 11:21:29 2015
@@ -19,7 +19,9 @@ package org.apache.lucene.index.memory;
 
 import java.io.IOException;
 
+import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.analysis.MockPayloadAnalyzer;
 import org.apache.lucene.index.FieldInvertState;
 import org.apache.lucene.index.LeafReader;
 import org.apache.lucene.index.Term;
@@ -30,6 +32,7 @@ import org.apache.lucene.search.TermQuer
 import org.apache.lucene.search.similarities.BM25Similarity;
 import org.apache.lucene.search.similarities.DefaultSimilarity;
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -99,6 +102,35 @@ public class TestMemoryIndex extends Luc
     TermsEnum terms = reader.fields().terms("field").iterator(null);
     terms.seekExact(0);
     assertEquals("be", terms.term().utf8ToString());
+    TestUtil.checkReader(reader);
+  }
+  
+  public void testReaderConsistency() throws IOException {
+    Analyzer analyzer = new MockPayloadAnalyzer();
+    
+    // defaults
+    MemoryIndex mi = new MemoryIndex();
+    mi.addField("field", "some terms be here", analyzer);
+    TestUtil.checkReader(mi.createSearcher().getIndexReader());
+    
+    // all combinations of offsets/payloads options
+    mi = new MemoryIndex(true, true);
+    mi.addField("field", "some terms be here", analyzer);
+    TestUtil.checkReader(mi.createSearcher().getIndexReader());
+    
+    mi = new MemoryIndex(true, false);
+    mi.addField("field", "some terms be here", analyzer);
+    TestUtil.checkReader(mi.createSearcher().getIndexReader());
+    
+    mi = new MemoryIndex(false, true);
+    mi.addField("field", "some terms be here", analyzer);
+    TestUtil.checkReader(mi.createSearcher().getIndexReader());
+    
+    mi = new MemoryIndex(false, false);
+    mi.addField("field", "some terms be here", analyzer);
+    TestUtil.checkReader(mi.createSearcher().getIndexReader());
+    
+    analyzer.close();
   }
 
   @Test
@@ -121,7 +153,7 @@ public class TestMemoryIndex extends Luc
     float n2 = reader.getNormValues("f1").get(0);
 
     assertTrue(n1 != n2);
-
+    TestUtil.checkReader(reader);
   }
 
 



Mime
View raw message