Apache Lucene open-source search software
create fewer random DV fields in tests; reduce frequency of force merge
Michael McCandlessb658af787606
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestMixedCodecs.java b/lucene/core/src/test/org/apache/lucene/index/TestMixedCodecs.javaindex 7d6cbf9968f..533e56f734c 100644--- a/lucene/core/src/test/org/apache/lucene/index/TestMixedCodecs.java+++ b/lucene/core/src/test/org/apache/lucene/index/TestMixedCodecs.java@@ -45,6 +45,9 @@ public class TestMixedCodecs extends LuceneTestCase {int docUpto = 0;while (docUpto < NUM_DOCS) {+ if (VERBOSE) {+ System.out.println("TEST: " + docUpto + " of " + NUM_DOCS);+ }if (docsLeftInThisSegment == 0) {final IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random));if (random.nextBoolean()) {@@ -66,6 +69,10 @@ public class TestMixedCodecs extends LuceneTestCase {docsLeftInThisSegment--;}+ if (VERBOSE) {+ System.out.println("\nTEST: now delete...");+ }+// Random delete half the docs:final Set<Integer> deleted = new HashSet<Integer>();while(deleted.size() < NUM_DOCS/2) {diff --git a/lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java b/lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.javaindex c58af42b911..9ab49583242 100644--- a/lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java+++ b/lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java@@ -28,7 +28,6 @@ import org.apache.lucene.codecs.Codec;import org.apache.lucene.document.DocValuesField;import org.apache.lucene.document.Document;import org.apache.lucene.document.Field;-import org.apache.lucene.document.FieldType;import org.apache.lucene.index.IndexWriter; // javadocimport org.apache.lucene.search.Query;import org.apache.lucene.store.Directory;@@ -102,20 +101,32 @@ public class RandomIndexWriter implements Closeable {System.out.println("RIW config=" + w.getConfig());System.out.println("codec default=" + codec.getName());}- /* TODO: find some what to make that random...+ /* TODO: find some way to make this random...* This must be fixed across all fixed bytes* fields in one index. so if you open another writer* this might change if I use r.nextInt(x)* maybe we can peek at the existing files here?*/fixedBytesLength = 17;- docValuesFieldPrefix = r.nextLong();++ // NOTE: this means up to 13 * 5 unique fields (we have+ // 13 different DV types):+ docValuesFieldPrefix = r.nextInt(5);switchDoDocValues();++ // Make sure we sometimes test indices that don't get+ // any forced merges:+ doRandomForceMerge = r.nextBoolean();}private void switchDoDocValues() {// randomly enable / disable docValuesdoDocValues = LuceneTestCase.rarely(r);+ if (LuceneTestCase.VERBOSE) {+ if (doDocValues) {+ System.out.println("NOTE: RIW: turning on random DocValues fields");+ }+ }}/**@@ -175,8 +186,9 @@ public class RandomIndexWriter implements Closeable {DocValues.Type[] values = DocValues.Type.values();DocValues.Type type = values[random.nextInt(values.length)];String name = "random_" + type.name() + "" + docValuesFieldPrefix;- if ("Lucene3x".equals(codec.getName()) || doc.getField(name) != null)- return;+ if ("Lucene3x".equals(codec.getName()) || doc.getField(name) != null) {+ return;+ }final Field f;switch (type) {case BYTES_FIXED_DEREF:@@ -367,7 +379,7 @@ public class RandomIndexWriter implements Closeable {public DirectoryReader getReader(boolean applyDeletions) throws IOException {getReaderCalled = true;- if (r.nextInt(4) == 2) {+ if (r.nextInt(20) == 2) {doRandomForceMerge();}// If we are writing with PreFlexRW, force a fulldiff --git a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.javaindex 2c67aec8fd5..7489777085a 100644--- a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java+++ b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java@@ -1173,6 +1173,9 @@ public abstract class LuceneTestCase extends Assert {MockDirectoryWrapper dir = new MockDirectoryWrapper(r, maybeNRTWrap(r, impl));stores.put(dir, Thread.currentThread().getStackTrace());dir.setThrottling(TEST_THROTTLING);+ if (VERBOSE) {+ System.out.println("NOTE: LuceneTestCase.newDirectory: returning " + dir);+ }return dir;}