From b8c02f6267f3f520713b1ceaee7828dcf5ef4260 Mon Sep 17 00:00:00 2001 From: Shai Erera Date: Wed, 30 Apr 2014 18:13:04 +0000 Subject: [PATCH] LUCENE-5633: replace NoMergePolicy.COMPOUND/NO_COMPOUND by NoMergePolicy.INSTANCE git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1591432 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/CHANGES.txt | 3 ++ .../byTask/tasks/CreateIndexTask.java | 5 +-- .../apache/lucene/index/NoMergePolicy.java | 36 ++++++------------- .../apache/lucene/index/TestAddIndexes.java | 6 ++-- .../index/TestBackwardsCompatibility.java | 4 +-- .../index/TestBinaryDocValuesUpdates.java | 10 +++--- .../index/TestConsistentFieldNumbers.java | 24 +++++-------- .../lucene/index/TestDeletionPolicy.java | 2 +- .../lucene/index/TestIndexFileDeleter.java | 2 +- .../apache/lucene/index/TestIndexWriter.java | 10 ++++-- .../lucene/index/TestIndexWriterDelete.java | 7 ++-- .../index/TestIndexWriterExceptions.java | 6 ++-- .../index/TestIndexWriterMergePolicy.java | 2 +- .../lucene/index/TestIndexWriterMerging.java | 7 ++-- .../lucene/index/TestIndexWriterReader.java | 14 ++------ .../apache/lucene/index/TestMultiFields.java | 2 +- .../lucene/index/TestNoMergePolicy.java | 9 +---- .../index/TestNumericDocValuesUpdates.java | 10 +++--- .../index/TestParallelCompositeReader.java | 6 ++-- .../index/TestParallelReaderEmptyIndex.java | 2 +- .../index/TestSizeBoundedForceMerge.java | 2 +- .../TestControlledRealTimeReopenThread.java | 5 ++- .../taxonomy/TestTaxonomyFacetCounts.java | 2 +- .../taxonomy/TestTaxonomyFacetCounts2.java | 2 +- .../grouping/GroupFacetCollectorTest.java | 2 +- .../lucene/search/join/TestBlockJoin.java | 4 +-- .../search/join/TestBlockJoinSorting.java | 2 +- .../index/TestMultiPassIndexSplitter.java | 4 +-- .../lucene/index/TestPKIndexSplitter.java | 4 +-- .../index/BaseStoredFieldsFormatTestCase.java | 2 +- 30 files changed, 80 insertions(+), 116 deletions(-) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index b9f737ac212..b520b71238a 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -114,6 +114,9 @@ API Changes deprecated and will be removed in Lucene 5.0. (Uwe Schindler, Robert Muir) +* LUCENE-5633: Change NoMergePolicy to a singleton with no distinction between + compound and non-compound types. (Shai Erera) + Optimizations * LUCENE-5603: hunspell stemmer more efficiently strips prefixes diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.java index 8ff264a723a..ce746be2781 100644 --- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.java +++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.java @@ -138,8 +138,9 @@ public class CreateIndexTask extends PerfTask { final String mergePolicy = config.get("merge.policy", "org.apache.lucene.index.LogByteSizeMergePolicy"); boolean isCompound = config.get("compound", true); + iwConf.setUseCompoundFile(isCompound); if (mergePolicy.equals(NoMergePolicy.class.getName())) { - iwConf.setMergePolicy(isCompound ? NoMergePolicy.COMPOUND_FILES : NoMergePolicy.NO_COMPOUND_FILES); + iwConf.setMergePolicy(NoMergePolicy.INSTANCE); } else { try { iwConf.setMergePolicy(Class.forName(mergePolicy).asSubclass(MergePolicy.class).newInstance()); @@ -147,7 +148,7 @@ public class CreateIndexTask extends PerfTask { throw new RuntimeException("unable to instantiate class '" + mergePolicy + "' as merge policy", e); } iwConf.getMergePolicy().setNoCFSRatio(isCompound ? 1.0 : 0.0); - if(iwConf.getMergePolicy() instanceof LogMergePolicy) { + if (iwConf.getMergePolicy() instanceof LogMergePolicy) { LogMergePolicy logMergePolicy = (LogMergePolicy) iwConf.getMergePolicy(); logMergePolicy.setMergeFactor(config.get("merge.factor",OpenIndexTask.DEFAULT_MERGE_PFACTOR)); } diff --git a/lucene/core/src/java/org/apache/lucene/index/NoMergePolicy.java b/lucene/core/src/java/org/apache/lucene/index/NoMergePolicy.java index 6fec6912a41..15565afaa72 100644 --- a/lucene/core/src/java/org/apache/lucene/index/NoMergePolicy.java +++ b/lucene/core/src/java/org/apache/lucene/index/NoMergePolicy.java @@ -22,34 +22,16 @@ import java.util.Map; /** - * A {@link MergePolicy} which never returns merges to execute (hence it's - * name). It is also a singleton and can be accessed through - * {@link NoMergePolicy#NO_COMPOUND_FILES} if you want to indicate the index - * does not use compound files, or through {@link NoMergePolicy#COMPOUND_FILES} - * otherwise. Use it if you want to prevent an {@link IndexWriter} from ever - * executing merges, without going through the hassle of tweaking a merge - * policy's settings to achieve that, such as changing its merge factor. + * A {@link MergePolicy} which never returns merges to execute. Use it if you + * want to prevent segment merges. */ public final class NoMergePolicy extends MergePolicy { - /** - * A singleton {@link NoMergePolicy} which indicates the index does not use - * compound files. - */ - public static final MergePolicy NO_COMPOUND_FILES = new NoMergePolicy(false); + /** Singleton instance. */ + public static final MergePolicy INSTANCE = new NoMergePolicy(); - /** - * A singleton {@link NoMergePolicy} which indicates the index uses compound - * files. - */ - public static final MergePolicy COMPOUND_FILES = new NoMergePolicy(true); - - private final boolean useCompoundFile; - - private NoMergePolicy(boolean useCompoundFile) { - super(useCompoundFile ? 1.0 : 0.0, 0); - // prevent instantiation - this.useCompoundFile = useCompoundFile; + private NoMergePolicy() { + super(); } @Override @@ -66,14 +48,16 @@ public final class NoMergePolicy extends MergePolicy { public MergeSpecification findForcedDeletesMerges(SegmentInfos segmentInfos) { return null; } @Override - public boolean useCompoundFile(SegmentInfos segments, SegmentCommitInfo newSegment) { return useCompoundFile; } + public boolean useCompoundFile(SegmentInfos segments, SegmentCommitInfo newSegment) { + return newSegment.info.getUseCompoundFile(); + } @Override public void setIndexWriter(IndexWriter writer) {} @Override protected long size(SegmentCommitInfo info) throws IOException { - return Long.MAX_VALUE; + return Long.MAX_VALUE; } @Override diff --git a/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java b/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java index 2145ee1347a..32a5058f9b5 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java @@ -417,7 +417,7 @@ public class TestAddIndexes extends LuceneTestCase { setUpDirs(dir, aux, true); IndexWriterConfig dontMergeConfig = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())) - .setMergePolicy(NoMergePolicy.COMPOUND_FILES); + .setMergePolicy(NoMergePolicy.INSTANCE); IndexWriter writer = new IndexWriter(aux, dontMergeConfig); for (int i = 0; i < 20; i++) { writer.deleteDocuments(new Term("id", "" + i)); @@ -469,7 +469,7 @@ public class TestAddIndexes extends LuceneTestCase { writer.shutdown(); IndexWriterConfig dontMergeConfig = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())) - .setMergePolicy(NoMergePolicy.COMPOUND_FILES); + .setMergePolicy(NoMergePolicy.INSTANCE); writer = new IndexWriter(aux, dontMergeConfig); for (int i = 0; i < 27; i++) { writer.deleteDocuments(new Term("id", "" + i)); @@ -480,7 +480,7 @@ public class TestAddIndexes extends LuceneTestCase { reader.close(); dontMergeConfig = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())) - .setMergePolicy(NoMergePolicy.COMPOUND_FILES); + .setMergePolicy(NoMergePolicy.INSTANCE); writer = new IndexWriter(aux2, dontMergeConfig); for (int i = 0; i < 8; i++) { writer.deleteDocuments(new Term("id", "" + i)); diff --git a/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java b/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java index 409652597aa..0059b6d7f3c 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java @@ -629,9 +629,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase { addNoProxDoc(writer); writer.shutdown(); - writer = new IndexWriter(dir, - conf.setMergePolicy(doCFS ? NoMergePolicy.COMPOUND_FILES : NoMergePolicy.NO_COMPOUND_FILES) - ); + writer = new IndexWriter(dir, conf.setMergePolicy(NoMergePolicy.INSTANCE)); Term searchTerm = new Term("id", "7"); writer.deleteDocuments(searchTerm); writer.shutdown(); diff --git a/lucene/core/src/test/org/apache/lucene/index/TestBinaryDocValuesUpdates.java b/lucene/core/src/test/org/apache/lucene/index/TestBinaryDocValuesUpdates.java index e6dadb2ac08..b81348c64be 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestBinaryDocValuesUpdates.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestBinaryDocValuesUpdates.java @@ -148,7 +148,7 @@ public class TestBinaryDocValuesUpdates extends LuceneTestCase { Directory dir = newDirectory(); IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())); conf.setMaxBufferedDocs(2); // generate few segments - conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES); // prevent merges for this test + conf.setMergePolicy(NoMergePolicy.INSTANCE); // prevent merges for this test IndexWriter writer = new IndexWriter(dir, conf); int numDocs = 10; long[] expectedValues = new long[numDocs]; @@ -235,7 +235,7 @@ public class TestBinaryDocValuesUpdates extends LuceneTestCase { Directory dir = newDirectory(); IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())); conf.setMaxBufferedDocs(10); // control segment flushing - conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES); // prevent merges for this test + conf.setMergePolicy(NoMergePolicy.INSTANCE); // prevent merges for this test IndexWriter writer = new IndexWriter(dir, conf); for (int i = 0; i < 6; i++) { @@ -851,7 +851,7 @@ public class TestBinaryDocValuesUpdates extends LuceneTestCase { // prevent merges, otherwise by the time updates are applied // (writer.shutdown()), the segments might have merged and that update becomes // legit. - conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES); + conf.setMergePolicy(NoMergePolicy.INSTANCE); IndexWriter writer = new IndexWriter(dir, conf); // first segment with BDV @@ -906,7 +906,7 @@ public class TestBinaryDocValuesUpdates extends LuceneTestCase { // prevent merges, otherwise by the time updates are applied // (writer.shutdown()), the segments might have merged and that update becomes // legit. - conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES); + conf.setMergePolicy(NoMergePolicy.INSTANCE); IndexWriter writer = new IndexWriter(dir, conf); // first segment with BDV @@ -1172,7 +1172,7 @@ public class TestBinaryDocValuesUpdates extends LuceneTestCase { public void testChangeCodec() throws Exception { Directory dir = newDirectory(); IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())); - conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES); // disable merges to simplify test assertions. + conf.setMergePolicy(NoMergePolicy.INSTANCE); // disable merges to simplify test assertions. conf.setCodec(new Lucene46Codec() { @Override public DocValuesFormat getDocValuesFormatForField(String field) { diff --git a/lucene/core/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java b/lucene/core/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java index e92fa7ef566..c196171b4f8 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java @@ -37,7 +37,7 @@ public class TestConsistentFieldNumbers extends LuceneTestCase { public void testSameFieldNumbersAcrossSegments() throws Exception { for (int i = 0; i < 2; i++) { Directory dir = newDirectory(); - IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.COMPOUND_FILES)); + IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.INSTANCE)); Document d1 = new Document(); d1.add(new StringField("f1", "first field", Field.Store.YES)); @@ -46,7 +46,7 @@ public class TestConsistentFieldNumbers extends LuceneTestCase { if (i == 1) { writer.shutdown(); - writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.COMPOUND_FILES)); + writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.INSTANCE)); } else { writer.commit(); } @@ -100,7 +100,7 @@ public class TestConsistentFieldNumbers extends LuceneTestCase { public void testAddIndexes() throws Exception { Directory dir1 = newDirectory(); Directory dir2 = newDirectory(); - IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.COMPOUND_FILES)); + IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.INSTANCE)); Document d1 = new Document(); d1.add(new TextField("f1", "first field", Field.Store.YES)); @@ -108,7 +108,7 @@ public class TestConsistentFieldNumbers extends LuceneTestCase { writer.addDocument(d1); writer.shutdown(); - writer = new IndexWriter(dir2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.COMPOUND_FILES)); + writer = new IndexWriter(dir2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.INSTANCE)); Document d2 = new Document(); FieldType customType2 = new FieldType(TextField.TYPE_STORED); @@ -121,7 +121,7 @@ public class TestConsistentFieldNumbers extends LuceneTestCase { writer.shutdown(); - writer = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.COMPOUND_FILES)); + writer = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.INSTANCE)); writer.addIndexes(dir2); writer.shutdown(); @@ -151,7 +151,7 @@ public class TestConsistentFieldNumbers extends LuceneTestCase { { IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy( - NoMergePolicy.NO_COMPOUND_FILES)); + NoMergePolicy.INSTANCE)); Document d = new Document(); d.add(new TextField("f1", "d1 first field", Field.Store.YES)); d.add(new TextField("f2", "d1 second field", Field.Store.YES)); @@ -168,9 +168,7 @@ public class TestConsistentFieldNumbers extends LuceneTestCase { { IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( - TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy( - random().nextBoolean() ? NoMergePolicy.NO_COMPOUND_FILES - : NoMergePolicy.COMPOUND_FILES)); + TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.INSTANCE)); Document d = new Document(); d.add(new TextField("f1", "d2 first field", Field.Store.YES)); d.add(new StoredField("f3", new byte[] { 1, 2, 3 })); @@ -190,9 +188,7 @@ public class TestConsistentFieldNumbers extends LuceneTestCase { { IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( - TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy( - random().nextBoolean() ? NoMergePolicy.NO_COMPOUND_FILES - : NoMergePolicy.COMPOUND_FILES)); + TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.INSTANCE)); Document d = new Document(); d.add(new TextField("f1", "d3 first field", Field.Store.YES)); d.add(new TextField("f2", "d3 second field", Field.Store.YES)); @@ -217,9 +213,7 @@ public class TestConsistentFieldNumbers extends LuceneTestCase { { IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( - TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy( - random().nextBoolean() ? NoMergePolicy.NO_COMPOUND_FILES - : NoMergePolicy.COMPOUND_FILES)); + TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.INSTANCE)); writer.deleteDocuments(new Term("f1", "d1")); // nuke the first segment entirely so that the segment with gaps is // loaded first! diff --git a/lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java b/lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java index 368e8963ee5..4e10c14b691 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java @@ -652,7 +652,7 @@ public class TestDeletionPolicy extends LuceneTestCase { writer.shutdown(); conf = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())) .setIndexDeletionPolicy(policy) - .setMergePolicy(NoMergePolicy.COMPOUND_FILES); + .setMergePolicy(NoMergePolicy.INSTANCE); writer = new IndexWriter(dir, conf); policy = (KeepLastNDeletionPolicy) writer.getConfig().getIndexDeletionPolicy(); writer.deleteDocuments(new Term("id", "" + (i*(N+1)+3))); diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java index c2fdf8ee0a3..74d4bf60abf 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java @@ -72,7 +72,7 @@ public class TestIndexFileDeleter extends LuceneTestCase { writer = new IndexWriter( dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())). - setMergePolicy(NoMergePolicy.NO_COMPOUND_FILES).setUseCompoundFile(true) + setMergePolicy(NoMergePolicy.INSTANCE).setUseCompoundFile(true) ); Term searchTerm = new Term("id", "7"); writer.deleteDocuments(searchTerm); diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java index a6f55c4258a..962661c6e5f 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java @@ -21,7 +21,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.io.StringReader; -import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -32,7 +31,12 @@ import java.util.Random; import java.util.Set; import java.util.concurrent.CountDownLatch; -import org.apache.lucene.analysis.*; +import org.apache.lucene.analysis.Analyzer; +import org.apache.lucene.analysis.MockAnalyzer; +import org.apache.lucene.analysis.MockTokenFilter; +import org.apache.lucene.analysis.MockTokenizer; +import org.apache.lucene.analysis.TokenStream; +import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute; import org.apache.lucene.codecs.Codec; @@ -112,7 +116,7 @@ public class TestIndexWriter extends LuceneTestCase { writer.shutdown(); // delete 40 documents - writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.NO_COMPOUND_FILES)); + writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.INSTANCE)); for (i = 0; i < 40; i++) { writer.deleteDocuments(new Term("id", ""+i)); } diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterDelete.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterDelete.java index 36f231c0ffd..829d26823e0 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterDelete.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterDelete.java @@ -20,7 +20,6 @@ package org.apache.lucene.index; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -1025,7 +1024,7 @@ public class TestIndexWriterDelete extends LuceneTestCase { // note: tiny rambuffer used, as with a 1MB buffer the test is too slow (flush @ 128,999) IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())) - .setRAMBufferSizeMB(0.1f).setMaxBufferedDocs(1000).setMergePolicy(NoMergePolicy.NO_COMPOUND_FILES).setReaderPooling(false)); + .setRAMBufferSizeMB(0.1f).setMaxBufferedDocs(1000).setMergePolicy(NoMergePolicy.INSTANCE).setReaderPooling(false)); int count = 0; while(true) { Document doc = new Document(); @@ -1071,7 +1070,7 @@ public class TestIndexWriterDelete extends LuceneTestCase { final int flushAtDelCount = atLeast(1020); IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())). - setMaxBufferedDeleteTerms(flushAtDelCount).setMaxBufferedDocs(1000).setRAMBufferSizeMB(IndexWriterConfig.DISABLE_AUTO_FLUSH).setMergePolicy(NoMergePolicy.NO_COMPOUND_FILES).setReaderPooling(false)); + setMaxBufferedDeleteTerms(flushAtDelCount).setMaxBufferedDocs(1000).setRAMBufferSizeMB(IndexWriterConfig.DISABLE_AUTO_FLUSH).setMergePolicy(NoMergePolicy.INSTANCE).setReaderPooling(false)); int count = 0; while(true) { Document doc = new Document(); @@ -1112,7 +1111,7 @@ public class TestIndexWriterDelete extends LuceneTestCase { final AtomicBoolean sawAfterFlush = new AtomicBoolean(); IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())). - setRAMBufferSizeMB(0.5).setMaxBufferedDocs(-1).setMergePolicy(NoMergePolicy.NO_COMPOUND_FILES).setReaderPooling(false)) { + setRAMBufferSizeMB(0.5).setMaxBufferedDocs(-1).setMergePolicy(NoMergePolicy.INSTANCE).setReaderPooling(false)) { @Override public void doAfterFlush() { assertTrue("only " + docsInSegment.get() + " in segment", closing.get() || docsInSegment.get() >= 7); diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java index 43ab76e55fb..14d6248cdf0 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java @@ -54,8 +54,8 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexInput; import org.apache.lucene.store.IndexOutput; -import org.apache.lucene.store.MockDirectoryWrapper.FakeIOException; import org.apache.lucene.store.MockDirectoryWrapper; +import org.apache.lucene.store.MockDirectoryWrapper.FakeIOException; import org.apache.lucene.store.RAMDirectory; import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; @@ -708,9 +708,7 @@ public class TestIndexWriterExceptions extends LuceneTestCase { { final IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, analyzer).setMaxBufferedDocs(-1) - .setMergePolicy( - random().nextBoolean() ? NoMergePolicy.COMPOUND_FILES - : NoMergePolicy.NO_COMPOUND_FILES)); + .setMergePolicy(NoMergePolicy.INSTANCE)); // don't use a merge policy here they depend on the DWPThreadPool and its max thread states etc. final int finalI = i; diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java index 41ecf150a0e..9495ea721e4 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java @@ -196,7 +196,7 @@ public class TestIndexWriterMergePolicy extends LuceneTestCase { writer = new IndexWriter( dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())). - setMergePolicy(NoMergePolicy.NO_COMPOUND_FILES) + setMergePolicy(NoMergePolicy.INSTANCE) ); writer.deleteDocuments(new Term("content", "aaa")); writer.shutdown(); diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java index 1ecd5796c1c..10b6ef4c240 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMerging.java @@ -16,7 +16,6 @@ package org.apache.lucene.index; */ import java.io.IOException; -import java.util.ArrayList; import java.util.Random; import java.util.concurrent.atomic.AtomicReference; @@ -156,7 +155,7 @@ public class TestIndexWriterMerging extends LuceneTestCase ir.close(); IndexWriterConfig dontMergeConfig = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())) - .setMergePolicy(NoMergePolicy.COMPOUND_FILES); + .setMergePolicy(NoMergePolicy.INSTANCE); writer = new IndexWriter(dir, dontMergeConfig); writer.deleteDocuments(new Term("id", "0")); writer.deleteDocuments(new Term("id", "7")); @@ -219,7 +218,7 @@ public class TestIndexWriterMerging extends LuceneTestCase ir.close(); IndexWriterConfig dontMergeConfig = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())) - .setMergePolicy(NoMergePolicy.COMPOUND_FILES); + .setMergePolicy(NoMergePolicy.INSTANCE); writer = new IndexWriter(dir, dontMergeConfig); for(int i=0;i<98;i+=2) { writer.deleteDocuments(new Term("id", "" + i)); @@ -285,7 +284,7 @@ public class TestIndexWriterMerging extends LuceneTestCase ir.close(); IndexWriterConfig dontMergeConfig = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())) - .setMergePolicy(NoMergePolicy.COMPOUND_FILES); + .setMergePolicy(NoMergePolicy.INSTANCE); writer = new IndexWriter(dir, dontMergeConfig); for(int i=0;i<98;i+=2) { writer.deleteDocuments(new Term("id", "" + i)); diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java index 9841e3b4c88..394bfbb9f97 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java @@ -124,11 +124,7 @@ public class TestIndexWriterReader extends LuceneTestCase { iwc.setMaxBufferedDocs(20); } // no merging - if (random().nextBoolean()) { - iwc.setMergePolicy(NoMergePolicy.NO_COMPOUND_FILES); - } else { - iwc.setMergePolicy(NoMergePolicy.COMPOUND_FILES); - } + iwc.setMergePolicy(NoMergePolicy.INSTANCE); if (VERBOSE) { System.out.println("TEST: make index"); } @@ -238,11 +234,7 @@ public class TestIndexWriterReader extends LuceneTestCase { iwc.setMaxBufferedDocs(20); } // no merging - if (random().nextBoolean()) { - iwc.setMergePolicy(NoMergePolicy.NO_COMPOUND_FILES); - } else { - iwc.setMergePolicy(NoMergePolicy.COMPOUND_FILES); - } + iwc.setMergePolicy(NoMergePolicy.INSTANCE); IndexWriter writer = new IndexWriter(dir1, iwc); // create the index @@ -1084,7 +1076,7 @@ public class TestIndexWriterReader extends LuceneTestCase { }); IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())); - conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES); // prevent merges from getting in the way + conf.setMergePolicy(NoMergePolicy.INSTANCE); // prevent merges from getting in the way IndexWriter writer = new IndexWriter(dir, conf); // create a segment and open an NRT reader diff --git a/lucene/core/src/test/org/apache/lucene/index/TestMultiFields.java b/lucene/core/src/test/org/apache/lucene/index/TestMultiFields.java index 3a3fdde2d60..6eed2679033 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestMultiFields.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestMultiFields.java @@ -36,7 +36,7 @@ public class TestMultiFields extends LuceneTestCase { Directory dir = newDirectory(); - IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.COMPOUND_FILES)); + IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.INSTANCE)); // we can do this because we use NoMergePolicy (and dont merge to "nothing") w.setKeepFullyDeletedSegments(true); diff --git a/lucene/core/src/test/org/apache/lucene/index/TestNoMergePolicy.java b/lucene/core/src/test/org/apache/lucene/index/TestNoMergePolicy.java index 9293fc7277f..47b0384500d 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestNoMergePolicy.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestNoMergePolicy.java @@ -29,20 +29,13 @@ public class TestNoMergePolicy extends LuceneTestCase { @Test public void testNoMergePolicy() throws Exception { - MergePolicy mp = NoMergePolicy.NO_COMPOUND_FILES; + MergePolicy mp = NoMergePolicy.INSTANCE; assertNull(mp.findMerges(null, (SegmentInfos)null)); assertNull(mp.findForcedMerges(null, 0, null)); assertNull(mp.findForcedDeletesMerges(null)); - assertFalse(mp.useCompoundFile(null, null)); mp.close(); } - @Test - public void testCompoundFiles() throws Exception { - assertFalse(NoMergePolicy.NO_COMPOUND_FILES.useCompoundFile(null, null)); - assertTrue(NoMergePolicy.COMPOUND_FILES.useCompoundFile(null, null)); - } - @Test public void testFinalSingleton() throws Exception { assertTrue(Modifier.isFinal(NoMergePolicy.class.getModifiers())); diff --git a/lucene/core/src/test/org/apache/lucene/index/TestNumericDocValuesUpdates.java b/lucene/core/src/test/org/apache/lucene/index/TestNumericDocValuesUpdates.java index d84c023a42e..a594277d105 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestNumericDocValuesUpdates.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestNumericDocValuesUpdates.java @@ -127,7 +127,7 @@ public class TestNumericDocValuesUpdates extends LuceneTestCase { Directory dir = newDirectory(); IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())); conf.setMaxBufferedDocs(2); // generate few segments - conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES); // prevent merges for this test + conf.setMergePolicy(NoMergePolicy.INSTANCE); // prevent merges for this test IndexWriter writer = new IndexWriter(dir, conf); int numDocs = 10; long[] expectedValues = new long[numDocs]; @@ -212,7 +212,7 @@ public class TestNumericDocValuesUpdates extends LuceneTestCase { Directory dir = newDirectory(); IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())); conf.setMaxBufferedDocs(10); // control segment flushing - conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES); // prevent merges for this test + conf.setMergePolicy(NoMergePolicy.INSTANCE); // prevent merges for this test IndexWriter writer = new IndexWriter(dir, conf); for (int i = 0; i < 6; i++) { @@ -830,7 +830,7 @@ public class TestNumericDocValuesUpdates extends LuceneTestCase { // prevent merges, otherwise by the time updates are applied // (writer.shutdown()), the segments might have merged and that update becomes // legit. - conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES); + conf.setMergePolicy(NoMergePolicy.INSTANCE); IndexWriter writer = new IndexWriter(dir, conf); // first segment with NDV @@ -884,7 +884,7 @@ public class TestNumericDocValuesUpdates extends LuceneTestCase { // prevent merges, otherwise by the time updates are applied // (writer.shutdown()), the segments might have merged and that update becomes // legit. - conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES); + conf.setMergePolicy(NoMergePolicy.INSTANCE); IndexWriter writer = new IndexWriter(dir, conf); // first segment with NDV @@ -1152,7 +1152,7 @@ public class TestNumericDocValuesUpdates extends LuceneTestCase { public void testChangeCodec() throws Exception { Directory dir = newDirectory(); IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())); - conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES); // disable merges to simplify test assertions. + conf.setMergePolicy(NoMergePolicy.INSTANCE); // disable merges to simplify test assertions. conf.setCodec(new Lucene46Codec() { @Override public DocValuesFormat getDocValuesFormatForField(String field) { diff --git a/lucene/core/src/test/org/apache/lucene/index/TestParallelCompositeReader.java b/lucene/core/src/test/org/apache/lucene/index/TestParallelCompositeReader.java index fff6e75068c..87073f7426e 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestParallelCompositeReader.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestParallelCompositeReader.java @@ -479,7 +479,7 @@ public class TestParallelCompositeReader extends LuceneTestCase { private Directory getDir1(Random random) throws IOException { Directory dir1 = newDirectory(); IndexWriter w1 = new IndexWriter(dir1, newIndexWriterConfig(TEST_VERSION_CURRENT, - new MockAnalyzer(random)).setMergePolicy(NoMergePolicy.NO_COMPOUND_FILES)); + new MockAnalyzer(random)).setMergePolicy(NoMergePolicy.INSTANCE)); Document d1 = new Document(); d1.add(newTextField("f1", "v1", Field.Store.YES)); d1.add(newTextField("f2", "v1", Field.Store.YES)); @@ -506,7 +506,7 @@ public class TestParallelCompositeReader extends LuceneTestCase { private Directory getDir2(Random random) throws IOException { Directory dir2 = newDirectory(); IndexWriter w2 = new IndexWriter(dir2, newIndexWriterConfig(TEST_VERSION_CURRENT, - new MockAnalyzer(random)).setMergePolicy(NoMergePolicy.NO_COMPOUND_FILES)); + new MockAnalyzer(random)).setMergePolicy(NoMergePolicy.INSTANCE)); Document d1 = new Document(); d1.add(newTextField("f3", "v1", Field.Store.YES)); d1.add(newTextField("f4", "v1", Field.Store.YES)); @@ -533,7 +533,7 @@ public class TestParallelCompositeReader extends LuceneTestCase { private Directory getInvalidStructuredDir2(Random random) throws IOException { Directory dir2 = newDirectory(); IndexWriter w2 = new IndexWriter(dir2, newIndexWriterConfig(TEST_VERSION_CURRENT, - new MockAnalyzer(random)).setMergePolicy(NoMergePolicy.NO_COMPOUND_FILES)); + new MockAnalyzer(random)).setMergePolicy(NoMergePolicy.INSTANCE)); Document d1 = new Document(); d1.add(newTextField("f3", "v1", Field.Store.YES)); d1.add(newTextField("f4", "v1", Field.Store.YES)); diff --git a/lucene/core/src/test/org/apache/lucene/index/TestParallelReaderEmptyIndex.java b/lucene/core/src/test/org/apache/lucene/index/TestParallelReaderEmptyIndex.java index f40a4e3bc34..d9c4ac5a249 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestParallelReaderEmptyIndex.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestParallelReaderEmptyIndex.java @@ -104,7 +104,7 @@ public class TestParallelReaderEmptyIndex extends LuceneTestCase { iw.shutdown(); IndexWriterConfig dontMergeConfig = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())) - .setMergePolicy(NoMergePolicy.COMPOUND_FILES); + .setMergePolicy(NoMergePolicy.INSTANCE); if (VERBOSE) { System.out.println("\nTEST: make 2nd writer"); } diff --git a/lucene/core/src/test/org/apache/lucene/index/TestSizeBoundedForceMerge.java b/lucene/core/src/test/org/apache/lucene/index/TestSizeBoundedForceMerge.java index 84b851c7a4d..ee598d72d0a 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestSizeBoundedForceMerge.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestSizeBoundedForceMerge.java @@ -48,7 +48,7 @@ public class TestSizeBoundedForceMerge extends LuceneTestCase { conf.setMaxBufferedDocs(IndexWriterConfig.DISABLE_AUTO_FLUSH); conf.setRAMBufferSizeMB(IndexWriterConfig.DEFAULT_RAM_BUFFER_SIZE_MB); // prevent any merges by default. - conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES); + conf.setMergePolicy(NoMergePolicy.INSTANCE); return conf; } diff --git a/lucene/core/src/test/org/apache/lucene/search/TestControlledRealTimeReopenThread.java b/lucene/core/src/test/org/apache/lucene/search/TestControlledRealTimeReopenThread.java index a4afe731ac7..c7dd1ec696a 100644 --- a/lucene/core/src/test/org/apache/lucene/search/TestControlledRealTimeReopenThread.java +++ b/lucene/core/src/test/org/apache/lucene/search/TestControlledRealTimeReopenThread.java @@ -45,9 +45,8 @@ import org.apache.lucene.index.TrackingIndexWriter; import org.apache.lucene.store.Directory; import org.apache.lucene.store.NRTCachingDirectory; import org.apache.lucene.util.IOUtils; -import org.apache.lucene.util.LuceneTestCase.SuppressCodecs; import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.util.TestUtil; +import org.apache.lucene.util.LuceneTestCase.SuppressCodecs; import org.apache.lucene.util.ThreadInterruptedException; import org.apache.lucene.util.Version; @@ -304,7 +303,7 @@ public class TestControlledRealTimeReopenThread extends ThreadedIndexingAndSearc */ public void testThreadStarvationNoDeleteNRTReader() throws IOException, InterruptedException { IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())); - conf.setMergePolicy(random().nextBoolean() ? NoMergePolicy.COMPOUND_FILES : NoMergePolicy.NO_COMPOUND_FILES); + conf.setMergePolicy(NoMergePolicy.INSTANCE); Directory d = newDirectory(); final CountDownLatch latch = new CountDownLatch(1); final CountDownLatch signal = new CountDownLatch(1); diff --git a/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetCounts.java b/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetCounts.java index 8ad085cb953..266b81d6c29 100644 --- a/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetCounts.java +++ b/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetCounts.java @@ -651,7 +651,7 @@ public class TestTaxonomyFacetCounts extends FacetTestCase { Directory taxoDir = newDirectory(); IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())); - iwc.setMergePolicy(NoMergePolicy.COMPOUND_FILES); // prevent merges + iwc.setMergePolicy(NoMergePolicy.INSTANCE); // prevent merges IndexWriter indexWriter = new IndexWriter(indexDir, iwc); TaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir); diff --git a/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetCounts2.java b/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetCounts2.java index 0ec2456000c..750902e70c8 100644 --- a/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetCounts2.java +++ b/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetCounts2.java @@ -242,7 +242,7 @@ public class TestTaxonomyFacetCounts2 extends FacetTestCase { // 4. Segment w/ categories, but only some results IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())); - conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES); // prevent merges, so we can control the index segments + conf.setMergePolicy(NoMergePolicy.INSTANCE); // prevent merges, so we can control the index segments IndexWriter indexWriter = new IndexWriter(indexDir, conf); TaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir); diff --git a/lucene/grouping/src/test/org/apache/lucene/search/grouping/GroupFacetCollectorTest.java b/lucene/grouping/src/test/org/apache/lucene/search/grouping/GroupFacetCollectorTest.java index f583081dbc3..470a0a2928f 100644 --- a/lucene/grouping/src/test/org/apache/lucene/search/grouping/GroupFacetCollectorTest.java +++ b/lucene/grouping/src/test/org/apache/lucene/search/grouping/GroupFacetCollectorTest.java @@ -286,7 +286,7 @@ public class GroupFacetCollectorTest extends AbstractGroupingTestCase { random(), dir, newIndexWriterConfig(TEST_VERSION_CURRENT, - new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.COMPOUND_FILES)); + new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.INSTANCE)); boolean useDv = false; // Cannot assert this since we use NoMergePolicy: diff --git a/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java b/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java index cb21fd36e15..849e0d5d2f2 100644 --- a/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java +++ b/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java @@ -65,7 +65,7 @@ public class TestBlockJoin extends LuceneTestCase { public void testEmptyChildFilter() throws Exception { final Directory dir = newDirectory(); final IndexWriterConfig config = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())); - config.setMergePolicy(NoMergePolicy.NO_COMPOUND_FILES); + config.setMergePolicy(NoMergePolicy.INSTANCE); // we don't want to merge - since we rely on certain segment setup final IndexWriter w = new IndexWriter(dir, config); @@ -387,7 +387,7 @@ public class TestBlockJoin extends LuceneTestCase { random(), dir, newIndexWriterConfig(TEST_VERSION_CURRENT, - new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.COMPOUND_FILES)); + new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.INSTANCE)); // Cannot assert this since we use NoMergePolicy: w.setDoRandomForceMergeAssert(false); diff --git a/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinSorting.java b/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinSorting.java index 7c1c9a0bffd..0f9162a21b7 100644 --- a/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinSorting.java +++ b/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinSorting.java @@ -53,7 +53,7 @@ public class TestBlockJoinSorting extends LuceneTestCase { public void testNestedSorting() throws Exception { final Directory dir = newDirectory(); final RandomIndexWriter w = new RandomIndexWriter(random(), dir, newIndexWriterConfig(TEST_VERSION_CURRENT, - new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.COMPOUND_FILES)); + new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.INSTANCE)); List docs = new ArrayList<>(); Document document = new Document(); diff --git a/lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java b/lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java index 3db6c4c3d5b..190d908b969 100644 --- a/lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java +++ b/lucene/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java @@ -1,4 +1,5 @@ package org.apache.lucene.index; + /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -22,7 +23,6 @@ import org.apache.lucene.document.Field; import org.apache.lucene.store.Directory; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks; public class TestMultiPassIndexSplitter extends LuceneTestCase { IndexReader input; @@ -33,7 +33,7 @@ public class TestMultiPassIndexSplitter extends LuceneTestCase { public void setUp() throws Exception { super.setUp(); dir = newDirectory(); - IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.COMPOUND_FILES)); + IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.INSTANCE)); Document doc; for (int i = 0; i < NUM_DOCS; i++) { doc = new Document(); diff --git a/lucene/misc/src/test/org/apache/lucene/index/TestPKIndexSplitter.java b/lucene/misc/src/test/org/apache/lucene/index/TestPKIndexSplitter.java index b0b1bf90569..67c296bdb9c 100644 --- a/lucene/misc/src/test/org/apache/lucene/index/TestPKIndexSplitter.java +++ b/lucene/misc/src/test/org/apache/lucene/index/TestPKIndexSplitter.java @@ -38,7 +38,7 @@ public class TestPKIndexSplitter extends LuceneTestCase { Directory dir = newDirectory(); IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false)) - .setOpenMode(OpenMode.CREATE).setMergePolicy(NoMergePolicy.COMPOUND_FILES)); + .setOpenMode(OpenMode.CREATE).setMergePolicy(NoMergePolicy.INSTANCE)); for (int x = 0; x < 11; x++) { Document doc = createDocument(x, "1", 3, format); w.addDocument(doc); @@ -58,7 +58,7 @@ public class TestPKIndexSplitter extends LuceneTestCase { // delete some documents w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false)) - .setOpenMode(OpenMode.APPEND).setMergePolicy(NoMergePolicy.COMPOUND_FILES)); + .setOpenMode(OpenMode.APPEND).setMergePolicy(NoMergePolicy.INSTANCE)); w.deleteDocuments(midTerm); w.deleteDocuments(new Term("id", format.format(2))); w.shutdown(); diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/BaseStoredFieldsFormatTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/index/BaseStoredFieldsFormatTestCase.java index 445e1db62ab..853eea2724f 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/index/BaseStoredFieldsFormatTestCase.java +++ b/lucene/test-framework/src/java/org/apache/lucene/index/BaseStoredFieldsFormatTestCase.java @@ -651,7 +651,7 @@ public abstract class BaseStoredFieldsFormatTestCase extends BaseIndexFileFormat public void testBulkMergeWithDeletes() throws IOException { final int numDocs = atLeast(200); Directory dir = newDirectory(); - RandomIndexWriter w = new RandomIndexWriter(random(), dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.COMPOUND_FILES)); + RandomIndexWriter w = new RandomIndexWriter(random(), dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.INSTANCE)); for (int i = 0; i < numDocs; ++i) { Document doc = new Document(); doc.add(new StringField("id", Integer.toString(i), Store.YES));