diff --git a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java index 3f22c0ebe52..44ff891cc3f 100644 --- a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java +++ b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java @@ -37,6 +37,7 @@ import org.apache.lucene.benchmark.byTask.utils.FileUtils; import org.apache.lucene.benchmark.byTask.tasks.NewAnalyzerTask; import org.apache.lucene.facet.taxonomy.TaxonomyReader; import org.apache.lucene.facet.taxonomy.TaxonomyWriter; +import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.search.IndexSearcher; @@ -90,7 +91,7 @@ public class PerfRunData implements Closeable { private HashMap,QueryMaker> readTaskQueryMaker; private Class qmkrClass; - private IndexReader indexReader; + private DirectoryReader indexReader; private IndexSearcher indexSearcher; private IndexWriter indexWriter; private Config config; @@ -288,7 +289,7 @@ public class PerfRunData implements Closeable { * reference. You must call IndexReader.decRef() when * you're done. */ - public synchronized IndexReader getIndexReader() { + public synchronized DirectoryReader getIndexReader() { if (indexReader != null) { indexReader.incRef(); } @@ -314,7 +315,7 @@ public class PerfRunData implements Closeable { * the reader will remain open). * @param indexReader The indexReader to set. */ - public synchronized void setIndexReader(IndexReader indexReader) throws IOException { + public synchronized void setIndexReader(DirectoryReader indexReader) throws IOException { if (indexReader == this.indexReader) { return; } diff --git a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/NearRealtimeReaderTask.java b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/NearRealtimeReaderTask.java index b77525cc685..6606dc432ae 100644 --- a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/NearRealtimeReaderTask.java +++ b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/NearRealtimeReaderTask.java @@ -18,6 +18,7 @@ package org.apache.lucene.benchmark.byTask.tasks; */ import org.apache.lucene.benchmark.byTask.PerfRunData; +import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.util.ArrayUtil; @@ -59,7 +60,7 @@ public class NearRealtimeReaderTask extends PerfTask { } long t = System.currentTimeMillis(); - IndexReader r = IndexReader.open(w, true); + DirectoryReader r = IndexReader.open(w, true); runData.setIndexReader(r); // Transfer our reference to runData r.decRef(); @@ -77,7 +78,7 @@ public class NearRealtimeReaderTask extends PerfTask { } t = System.currentTimeMillis(); - final IndexReader newReader = IndexReader.openIfChanged(r); + final DirectoryReader newReader = DirectoryReader.openIfChanged(r); if (newReader != null) { final int delay = (int) (System.currentTimeMillis()-t); if (reopenTimes.length == reopenCount) { diff --git a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/OpenReaderTask.java b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/OpenReaderTask.java index a6206e42c19..8468ea6d1a9 100644 --- a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/OpenReaderTask.java +++ b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/OpenReaderTask.java @@ -22,6 +22,7 @@ import java.util.Collection; import java.util.Map; import org.apache.lucene.benchmark.byTask.PerfRunData; +import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexCommit; import org.apache.lucene.index.IndexReader; import org.apache.lucene.store.Directory; @@ -42,7 +43,7 @@ public class OpenReaderTask extends PerfTask { @Override public int doLogic() throws IOException { Directory dir = getRunData().getDirectory(); - IndexReader r = null; + DirectoryReader r = null; if (commitUserData != null) { r = IndexReader.open(OpenReaderTask.findIndexCommit(dir, commitUserData)); } else { @@ -71,7 +72,7 @@ public class OpenReaderTask extends PerfTask { } public static IndexCommit findIndexCommit(Directory dir, String userData) throws IOException { - Collection commits = IndexReader.listCommits(dir); + Collection commits = DirectoryReader.listCommits(dir); for (final IndexCommit ic : commits) { Map map = ic.getUserData(); String ud = null; diff --git a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReopenReaderTask.java b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReopenReaderTask.java index 4eb2a9d9765..0cd58431b4e 100644 --- a/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReopenReaderTask.java +++ b/modules/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReopenReaderTask.java @@ -20,6 +20,7 @@ package org.apache.lucene.benchmark.byTask.tasks; import java.io.IOException; import org.apache.lucene.benchmark.byTask.PerfRunData; +import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; /** @@ -33,8 +34,8 @@ public class ReopenReaderTask extends PerfTask { @Override public int doLogic() throws IOException { - IndexReader r = getRunData().getIndexReader(); - IndexReader nr = IndexReader.openIfChanged(r); + DirectoryReader r = getRunData().getIndexReader(); + DirectoryReader nr = DirectoryReader.openIfChanged(r); if (nr != null) { getRunData().setIndexReader(nr); nr.decRef(); diff --git a/modules/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java b/modules/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java index a95628dae07..7c978c63863 100755 --- a/modules/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java +++ b/modules/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java @@ -39,6 +39,7 @@ import org.apache.lucene.benchmark.byTask.tasks.CountingSearchTestTask; import org.apache.lucene.benchmark.byTask.tasks.WriteLineDocTask; import org.apache.lucene.collation.CollationKeyAnalyzer; import org.apache.lucene.facet.taxonomy.TaxonomyReader; +import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.DocsEnum; import org.apache.lucene.index.Fields; import org.apache.lucene.index.FieldsEnum; @@ -51,7 +52,7 @@ import org.apache.lucene.index.LogMergePolicy; import org.apache.lucene.index.MultiFields; import org.apache.lucene.index.SegmentInfos; import org.apache.lucene.index.SerialMergeScheduler; -import org.apache.lucene.index.SlowMultiReaderWrapper; +import org.apache.lucene.index.SlowCompositeReaderWrapper; import org.apache.lucene.index.Terms; import org.apache.lucene.index.TermsEnum; import org.apache.lucene.search.FieldCache.DocTermsIndex; @@ -97,7 +98,7 @@ public class TestPerfTasksLogic extends BenchmarkTestCase { // 4. test specific checks after the benchmark run completed. assertEquals("TestSearchTask was supposed to be called!",279,CountingSearchTestTask.numSearches); - assertTrue("Index does not exist?...!", IndexReader.indexExists(benchmark.getRunData().getDirectory())); + assertTrue("Index does not exist?...!", DirectoryReader.indexExists(benchmark.getRunData().getDirectory())); // now we should be able to open the index for write. IndexWriter iw = new IndexWriter(benchmark.getRunData().getDirectory(), new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)) @@ -185,7 +186,7 @@ public class TestPerfTasksLogic extends BenchmarkTestCase { //we probably should use a different doc/query maker, but... assertTrue("TestSearchTask was supposed to be called!", CountingHighlighterTestTask.numDocsRetrieved >= CountingHighlighterTestTask.numHighlightedResults && CountingHighlighterTestTask.numHighlightedResults > 0); - assertTrue("Index does not exist?...!", IndexReader.indexExists(benchmark.getRunData().getDirectory())); + assertTrue("Index does not exist?...!", DirectoryReader.indexExists(benchmark.getRunData().getDirectory())); // now we should be able to open the index for write. IndexWriter iw = new IndexWriter(benchmark.getRunData().getDirectory(), new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.APPEND)); iw.close(); @@ -224,7 +225,7 @@ public class TestPerfTasksLogic extends BenchmarkTestCase { //we probably should use a different doc/query maker, but... assertTrue("TestSearchTask was supposed to be called!", CountingHighlighterTestTask.numDocsRetrieved >= CountingHighlighterTestTask.numHighlightedResults && CountingHighlighterTestTask.numHighlightedResults > 0); - assertTrue("Index does not exist?...!", IndexReader.indexExists(benchmark.getRunData().getDirectory())); + assertTrue("Index does not exist?...!", DirectoryReader.indexExists(benchmark.getRunData().getDirectory())); // now we should be able to open the index for write. IndexWriter iw = new IndexWriter(benchmark.getRunData().getDirectory(), new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.APPEND)); iw.close(); @@ -297,7 +298,7 @@ public class TestPerfTasksLogic extends BenchmarkTestCase { // 4. test specific checks after the benchmark run completed. assertEquals("TestSearchTask was supposed to be called!",139,CountingSearchTestTask.numSearches); - assertTrue("Index does not exist?...!", IndexReader.indexExists(benchmark.getRunData().getDirectory())); + assertTrue("Index does not exist?...!", DirectoryReader.indexExists(benchmark.getRunData().getDirectory())); // now we should be able to open the index for write. IndexWriter iw = new IndexWriter(benchmark.getRunData().getDirectory(), new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.APPEND)); iw.close(); @@ -332,8 +333,8 @@ public class TestPerfTasksLogic extends BenchmarkTestCase { // 3. execute the algorithm (required in every "logic" test) Benchmark benchmark = execBenchmark(algLines); - IndexReader r = IndexReader.open(benchmark.getRunData().getDirectory()); - DocTermsIndex idx = FieldCache.DEFAULT.getTermsIndex(new SlowMultiReaderWrapper(r), "country"); + DirectoryReader r = IndexReader.open(benchmark.getRunData().getDirectory()); + DocTermsIndex idx = FieldCache.DEFAULT.getTermsIndex(new SlowCompositeReaderWrapper(r), "country"); final int maxDoc = r.maxDoc(); assertEquals(1000, maxDoc); BytesRef br = new BytesRef();