lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1514054 - in /lucene/dev/branches/branch_4x: ./ lucene/ lucene/core/ lucene/core/src/test/org/apache/lucene/index/ lucene/core/src/test/org/apache/lucene/search/ lucene/test-framework/ lucene/test-framework/src/java/org/apache/lucene/index...
Date Wed, 14 Aug 2013 21:26:35 GMT
Author: rmuir
Date: Wed Aug 14 21:26:35 2013
New Revision: 1514054

URL: http://svn.apache.org/r1514054
Log:
LUCENE-5176: remove _TestUtil.keepFullyDeletedSegments

Added:
    lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/AllDeletedFilterReader.java
      - copied unchanged from r1514052, lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/AllDeletedFilterReader.java
Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/lucene/   (props changed)
    lucene/dev/branches/branch_4x/lucene/core/   (props changed)
    lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
    lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestMultiFields.java
    lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java
    lucene/dev/branches/branch_4x/lucene/test-framework/   (props changed)
    lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/search/QueryUtils.java
    lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java?rev=1514054&r1=1514053&r2=1514054&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
Wed Aug 14 21:26:35 2013
@@ -490,7 +490,8 @@ public class TestIndexWriterOnDiskFull e
             setReaderPooling(true).
             setMergePolicy(newLogMergePolicy(2))
     );
-    _TestUtil.keepFullyDeletedSegments(w);
+    // we can do this because we add/delete/add (and dont merge to "nothing")
+    w.setKeepFullyDeletedSegments(true);
 
     Document doc = new Document();
 

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestMultiFields.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestMultiFields.java?rev=1514054&r1=1514053&r2=1514054&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestMultiFields.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestMultiFields.java
Wed Aug 14 21:26:35 2013
@@ -37,7 +37,8 @@ public class TestMultiFields extends Luc
       Directory dir = newDirectory();
 
       IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new
MockAnalyzer(random())).setMergePolicy(NoMergePolicy.COMPOUND_FILES));
-      _TestUtil.keepFullyDeletedSegments(w);
+      // we can do this because we use NoMergePolicy (and dont merge to "nothing")
+      w.setKeepFullyDeletedSegments(true);
 
       Map<BytesRef,List<Integer>> docs = new HashMap<BytesRef,List<Integer>>();
       Set<Integer> deleted = new HashSet<Integer>();

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java?rev=1514054&r1=1514053&r2=1514054&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java
Wed Aug 14 21:26:35 2013
@@ -173,7 +173,6 @@ public class TestCachingWrapperFilter ex
             // asserts below requires no unexpected merges:
             setMergePolicy(newLogMergePolicy(10))
     );
-    _TestUtil.keepFullyDeletedSegments(writer.w);
 
     // NOTE: cannot use writer.getReader because RIW (on
     // flipping a coin) may give us a newly opened reader,

Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/search/QueryUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/search/QueryUtils.java?rev=1514054&r1=1514053&r2=1514054&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/search/QueryUtils.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/search/QueryUtils.java
Wed Aug 14 21:26:35 2013
@@ -25,6 +25,7 @@ import junit.framework.Assert;
 
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
+import org.apache.lucene.index.AllDeletedFilterReader;
 import org.apache.lucene.index.AtomicReader;
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.index.IndexReader;
@@ -38,7 +39,6 @@ import org.apache.lucene.store.MockDirec
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
 
 import static org.apache.lucene.util.LuceneTestCase.TEST_VERSION_CURRENT;
 
@@ -193,7 +193,7 @@ public class QueryUtils {
   static final IndexReader[] emptyReaders = new IndexReader[8];
   static {
     try {
-      emptyReaders[0] = makeEmptyIndex(new Random(0), 0);
+      emptyReaders[0] = new MultiReader();
       emptyReaders[4] = makeEmptyIndex(new Random(0), 4);
       emptyReaders[5] = makeEmptyIndex(new Random(0), 5);
       emptyReaders[7] = makeEmptyIndex(new Random(0), 7);
@@ -202,31 +202,18 @@ public class QueryUtils {
     }
   }
 
-  private static DirectoryReader makeEmptyIndex(Random random, final int numDeletedDocs)

-    throws IOException {
+  private static IndexReader makeEmptyIndex(Random random, final int numDocs) throws IOException
{
+    assert numDocs > 0;
     Directory d = new MockDirectoryWrapper(random, new RAMDirectory());
-      IndexWriter w = new IndexWriter(d, new IndexWriterConfig(
-        TEST_VERSION_CURRENT, new MockAnalyzer(random)));
-      for (int i = 0; i < numDeletedDocs; i++) {
-        w.addDocument(new Document());
-      }
-      w.commit();
-      w.deleteDocuments( new MatchAllDocsQuery() );
-      _TestUtil.keepFullyDeletedSegments(w);
-      w.commit();
-
-      if (0 < numDeletedDocs)
-        Assert.assertTrue("writer has no deletions", w.hasDeletions());
-
-      Assert.assertEquals("writer is missing some deleted docs", 
-                          numDeletedDocs, w.maxDoc());
-      Assert.assertEquals("writer has non-deleted docs", 
-                          0, w.numDocs());
-      w.close();
-      DirectoryReader r = DirectoryReader.open(d);
-      Assert.assertEquals("reader has wrong number of deleted docs", 
-                          numDeletedDocs, r.numDeletedDocs());
-      return r;
+    IndexWriter w = new IndexWriter(d, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)));
+    for (int i = 0; i < numDocs; i++) {
+      w.addDocument(new Document());
+    }
+    w.forceMerge(1);
+    w.commit();
+    w.close();
+    DirectoryReader reader = DirectoryReader.open(d);
+    return new AllDeletedFilterReader(LuceneTestCase.getOnlySegmentReader(reader));
   }
 
   /** alternate scorer skipTo(),skipTo(),next(),next(),skipTo(),skipTo(), etc

Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java?rev=1514054&r1=1514053&r2=1514054&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java
Wed Aug 14 21:26:35 2013
@@ -25,7 +25,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.PrintStream;
-import java.lang.reflect.Method;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.nio.CharBuffer;
@@ -778,19 +777,6 @@ public class _TestUtil {
     });
     Assert.assertEquals("Reflection does not produce same map", reflectedValues, map);
   }
-
-  public static void keepFullyDeletedSegments(IndexWriter w) {
-    try {
-      // Carefully invoke what is a package-private (test
-      // only, internal) method on IndexWriter:
-      Method m = IndexWriter.class.getDeclaredMethod("setKeepFullyDeletedSegments", boolean.class);
-      m.setAccessible(true);
-      m.invoke(w, Boolean.TRUE);
-    } catch (Exception e) {
-      // Should not happen?
-      throw new RuntimeException(e);
-    }
-  }
   
   /** 
    * insecure, fast version of File.createTempFile



Mime
View raw message