lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject lucene-solr:branch_5x: fix test bug: use an FSDirectory when there are too many docs
Date Sun, 19 Jun 2016 10:06:51 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_5x 7f644688a -> e2f4c8e41


fix test bug: use an FSDirectory when there are too many docs


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/e2f4c8e4
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/e2f4c8e4
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/e2f4c8e4

Branch: refs/heads/branch_5x
Commit: e2f4c8e41ca6472a1e298713321e6e6a42bda526
Parents: 7f64468
Author: Mike McCandless <mikemccand@apache.org>
Authored: Sun Jun 19 06:03:29 2016 -0400
Committer: Mike McCandless <mikemccand@apache.org>
Committed: Sun Jun 19 06:06:40 2016 -0400

----------------------------------------------------------------------
 .../org/apache/lucene/search/TestBoolean2.java   | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e2f4c8e4/lucene/core/src/test/org/apache/lucene/search/TestBoolean2.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestBoolean2.java b/lucene/core/src/test/org/apache/lucene/search/TestBoolean2.java
index f4ead23..8ddadc5 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestBoolean2.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestBoolean2.java
@@ -33,6 +33,7 @@ import org.apache.lucene.index.Term;
 import org.apache.lucene.search.similarities.DefaultSimilarity;
 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 DefaultSimilarity());
 
     // 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());


Mime
View raw message