You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2012/03/27 20:08:09 UTC
svn commit: r1305935 - in /lucene/dev/trunk/lucene:
core/src/test/org/apache/lucene/index/TestMixedCodecs.java
test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java
test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
Author: mikemccand
Date: Tue Mar 27 18:08:08 2012
New Revision: 1305935
URL: http://svn.apache.org/viewvc?rev=1305935&view=rev
Log:
create fewer random DV fields in tests; reduce frequency of force merge
Modified:
lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestMixedCodecs.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestMixedCodecs.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestMixedCodecs.java?rev=1305935&r1=1305934&r2=1305935&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestMixedCodecs.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestMixedCodecs.java Tue Mar 27 18:08:08 2012
@@ -45,6 +45,9 @@ public class TestMixedCodecs extends Luc
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 Luc
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) {
Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java?rev=1305935&r1=1305934&r2=1305935&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java (original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java Tue Mar 27 18:08:08 2012
@@ -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 implement
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 implement
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 implement
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
Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java?rev=1305935&r1=1305934&r2=1305935&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java Tue Mar 27 18:08:08 2012
@@ -1173,6 +1173,9 @@ public abstract class LuceneTestCase ext
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;
}