From 66dd8290c0c7d50b8c8e4cbcecd3ccf9ff5d8997 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Mon, 20 Jun 2011 12:00:12 +0000 Subject: [PATCH] revert speedup, the wrapping causes fc insanity. the only reason this works today is that a new index is created in every setup/teardown, which also makes these tests slow... git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1137601 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/lucene/search/QueryUtils.java | 37 +++++++------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/lucene/src/test-framework/org/apache/lucene/search/QueryUtils.java b/lucene/src/test-framework/org/apache/lucene/search/QueryUtils.java index 4b13c62112f..699af49f51c 100644 --- a/lucene/src/test-framework/org/apache/lucene/search/QueryUtils.java +++ b/lucene/src/test-framework/org/apache/lucene/search/QueryUtils.java @@ -148,35 +148,23 @@ public class QueryUtils { // we can't put deleted docs before the nested reader, because // it will throw off the docIds IndexReader[] readers = new IndexReader[] { - edge < 0 ? r : emptyReaders[0], - emptyReaders[0], - new MultiReader(edge < 0 ? emptyReaders[4] : emptyReaders[0], - emptyReaders[0], - 0 == edge ? r : emptyReaders[0]), - 0 < edge ? emptyReaders[0] : emptyReaders[7], - emptyReaders[0], - new MultiReader(0 < edge ? emptyReaders[0] : emptyReaders[5], - emptyReaders[0], - 0 < edge ? r : emptyReaders[0]) + edge < 0 ? r : IndexReader.open(makeEmptyIndex(random, 0), true), + IndexReader.open(makeEmptyIndex(random, 0), true), + new MultiReader(IndexReader.open(makeEmptyIndex(random, edge < 0 ? 4 : 0), true), + IndexReader.open(makeEmptyIndex(random, 0), true), + 0 == edge ? r : IndexReader.open(makeEmptyIndex(random, 0), true)), + IndexReader.open(makeEmptyIndex(random, 0 < edge ? 0 : 7), true), + IndexReader.open(makeEmptyIndex(random, 0), true), + new MultiReader(IndexReader.open(makeEmptyIndex(random, 0 < edge ? 0 : 5), true), + IndexReader.open(makeEmptyIndex(random, 0), true), + 0 < edge ? r : IndexReader.open(makeEmptyIndex(random, 0), true)) }; IndexSearcher out = LuceneTestCase.newSearcher(new MultiReader(readers)); out.setSimilarityProvider(s.getSimilarityProvider()); return out; } - - static final IndexReader[] emptyReaders = new IndexReader[8]; - static { - try { - emptyReaders[0] = makeEmptyIndex(new Random(0), 0); - emptyReaders[4] = makeEmptyIndex(new Random(0), 4); - emptyReaders[5] = makeEmptyIndex(new Random(0), 5); - emptyReaders[7] = makeEmptyIndex(new Random(0), 7); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - private static IndexReader makeEmptyIndex(Random random, final int numDeletedDocs) + private static Directory makeEmptyIndex(Random random, final int numDeletedDocs) throws IOException { Directory d = new MockDirectoryWrapper(random, new RAMDirectory()); IndexWriter w = new IndexWriter(d, new IndexWriterConfig( @@ -200,7 +188,8 @@ public class QueryUtils { IndexReader r = IndexReader.open(d, true); Assert.assertEquals("reader has wrong number of deleted docs", numDeletedDocs, r.numDeletedDocs()); - return r; + r.close(); + return d; } /** alternate scorer skipTo(),skipTo(),next(),next(),skipTo(),skipTo(), etc