mirror of https://github.com/apache/lucene.git
fix test bug: use an FSDirectory when there are too many docs
This commit is contained in:
parent
940aedf26b
commit
a5c43b415f
|
@ -33,6 +33,7 @@ import org.apache.lucene.index.Term;
|
|||
import org.apache.lucene.search.similarities.ClassicSimilarity;
|
||||
import org.apache.lucene.search.similarities.Similarity;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.IOContext;
|
||||
import org.apache.lucene.store.MockDirectoryWrapper;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.TestUtil;
|
||||
|
@ -69,7 +70,12 @@ public class TestBoolean2 extends LuceneTestCase {
|
|||
NUM_FILLER_DOCS = random().nextBoolean() ? 0 : BooleanScorer.SIZE;
|
||||
PRE_FILLER_DOCS = TestUtil.nextInt(random(), 0, (NUM_FILLER_DOCS / 2));
|
||||
|
||||
directory = newDirectory();
|
||||
if (NUM_FILLER_DOCS * PRE_FILLER_DOCS > 100000) {
|
||||
directory = newFSDirectory(createTempDir());
|
||||
} else {
|
||||
directory = newDirectory();
|
||||
}
|
||||
|
||||
RandomIndexWriter writer= new RandomIndexWriter(random(), directory, newIndexWriterConfig(new MockAnalyzer(random())).setMergePolicy(newLogMergePolicy()));
|
||||
|
||||
Document doc = new Document();
|
||||
|
@ -92,7 +98,16 @@ public class TestBoolean2 extends LuceneTestCase {
|
|||
searcher.setSimilarity(new ClassicSimilarity());
|
||||
|
||||
// make a copy of our index using a single segment
|
||||
singleSegmentDirectory = new MockDirectoryWrapper(random(), TestUtil.ramCopyOf(directory));
|
||||
if (NUM_FILLER_DOCS * PRE_FILLER_DOCS > 100000) {
|
||||
singleSegmentDirectory = newFSDirectory(createTempDir());
|
||||
} else {
|
||||
singleSegmentDirectory = newDirectory();
|
||||
}
|
||||
|
||||
for (String fileName : directory.listAll()) {
|
||||
singleSegmentDirectory.copyFrom(directory, fileName, fileName, IOContext.DEFAULT);
|
||||
}
|
||||
|
||||
IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
|
||||
// we need docID order to be preserved:
|
||||
iwc.setMergePolicy(newLogMergePolicy());
|
||||
|
|
Loading…
Reference in New Issue