create fewer random DV fields in tests; reduce frequency of force merge

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1305935 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2012-03-27 18:08:08 +00:00
parent 6a1a25868b
commit b658af7876
3 changed files with 28 additions and 6 deletions

View File

@ -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) {

View File

@ -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; // javadoc
import 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 docValues
doDocValues = 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)
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 full

View File

@ -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;
}