Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

if we get MockRandomMergePolicy, which is O(N^2), use smaller index

Michael McCandlessf8795d25a5ac
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestBagOfPositions.java b/lucene/core/src/test/org/apache/lucene/index/TestBagOfPositions.java
index d62e475b34a..54b25b5efc9 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestBagOfPositions.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestBagOfPositions.java
@@ -24,6 +24,7 @@ import java.util.Random;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CountDownLatch;
+import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
@@ -47,7 +48,9 @@ public class TestBagOfPositions extends LuceneTestCase {
final int maxTermsPerDoc = _TestUtil.nextInt(random(), 10, 20);
boolean isSimpleText = "SimpleText".equals(_TestUtil.getPostingsFormat("field"));
- if (isSimpleText && (TEST_NIGHTLY || RANDOM_MULTIPLIER > 1)) {
+ IndexWriterConfig iwc = newIndexWriterConfig(random(), TEST_VERSION_CURRENT, new MockAnalyzer(random()));
+
+ if ((isSimpleText || iwc.getMergePolicy() instanceof MockRandomMergePolicy) && (TEST_NIGHTLY || RANDOM_MULTIPLIER > 1)) {
// Otherwise test can take way too long (> 2 hours)
numTerms /= 2;
}
@@ -66,7 +69,8 @@ public class TestBagOfPositions extends LuceneTestCase {
final ConcurrentLinkedQueue<String> postings = new ConcurrentLinkedQueue<String>(postingsList);
Directory dir = newFSDirectory(_TestUtil.getTempDir("bagofpositions"));
- final RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
+
+ final RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
int threadCount = _TestUtil.nextInt(random(), 1, 5);
if (VERBOSE) {
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestBagOfPostings.java b/lucene/core/src/test/org/apache/lucene/index/TestBagOfPostings.java
index 8ba54b635d6..28d058bb6a0 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestBagOfPostings.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestBagOfPostings.java
@@ -25,6 +25,7 @@ import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CountDownLatch;
+import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.store.Directory;
@@ -46,7 +47,9 @@ public class TestBagOfPostings extends LuceneTestCase {
boolean isSimpleText = "SimpleText".equals(_TestUtil.getPostingsFormat("field"));
- if (isSimpleText && (TEST_NIGHTLY || RANDOM_MULTIPLIER > 1)) {
+ IndexWriterConfig iwc = newIndexWriterConfig(random(), TEST_VERSION_CURRENT, new MockAnalyzer(random()));
+
+ if ((isSimpleText || iwc.getMergePolicy() instanceof MockRandomMergePolicy) && (TEST_NIGHTLY || RANDOM_MULTIPLIER > 1)) {
// Otherwise test can take way too long (> 2 hours)
numTerms /= 2;
}
@@ -67,7 +70,7 @@ public class TestBagOfPostings extends LuceneTestCase {
final ConcurrentLinkedQueue<String> postings = new ConcurrentLinkedQueue<String>(postingsList);
Directory dir = newFSDirectory(_TestUtil.getTempDir("bagofpostings"));
- final RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
+ final RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
int threadCount = _TestUtil.nextInt(random(), 1, 5);
if (VERBOSE) {