mirror of https://github.com/apache/lucene.git
LUCENE-2858: fix benchmarks
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene2858@1237335 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
acefe212c1
commit
adf080e451
|
@ -37,6 +37,7 @@ import org.apache.lucene.benchmark.byTask.utils.FileUtils;
|
||||||
import org.apache.lucene.benchmark.byTask.tasks.NewAnalyzerTask;
|
import org.apache.lucene.benchmark.byTask.tasks.NewAnalyzerTask;
|
||||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||||
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
||||||
|
import org.apache.lucene.index.DirectoryReader;
|
||||||
import org.apache.lucene.index.IndexReader;
|
import org.apache.lucene.index.IndexReader;
|
||||||
import org.apache.lucene.index.IndexWriter;
|
import org.apache.lucene.index.IndexWriter;
|
||||||
import org.apache.lucene.search.IndexSearcher;
|
import org.apache.lucene.search.IndexSearcher;
|
||||||
|
@ -90,7 +91,7 @@ public class PerfRunData implements Closeable {
|
||||||
private HashMap<Class<? extends ReadTask>,QueryMaker> readTaskQueryMaker;
|
private HashMap<Class<? extends ReadTask>,QueryMaker> readTaskQueryMaker;
|
||||||
private Class<? extends QueryMaker> qmkrClass;
|
private Class<? extends QueryMaker> qmkrClass;
|
||||||
|
|
||||||
private IndexReader indexReader;
|
private DirectoryReader indexReader;
|
||||||
private IndexSearcher indexSearcher;
|
private IndexSearcher indexSearcher;
|
||||||
private IndexWriter indexWriter;
|
private IndexWriter indexWriter;
|
||||||
private Config config;
|
private Config config;
|
||||||
|
@ -288,7 +289,7 @@ public class PerfRunData implements Closeable {
|
||||||
* reference. You must call IndexReader.decRef() when
|
* reference. You must call IndexReader.decRef() when
|
||||||
* you're done.
|
* you're done.
|
||||||
*/
|
*/
|
||||||
public synchronized IndexReader getIndexReader() {
|
public synchronized DirectoryReader getIndexReader() {
|
||||||
if (indexReader != null) {
|
if (indexReader != null) {
|
||||||
indexReader.incRef();
|
indexReader.incRef();
|
||||||
}
|
}
|
||||||
|
@ -314,7 +315,7 @@ public class PerfRunData implements Closeable {
|
||||||
* the reader will remain open).
|
* the reader will remain open).
|
||||||
* @param indexReader The indexReader to set.
|
* @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) {
|
if (indexReader == this.indexReader) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.lucene.benchmark.byTask.tasks;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.lucene.benchmark.byTask.PerfRunData;
|
import org.apache.lucene.benchmark.byTask.PerfRunData;
|
||||||
|
import org.apache.lucene.index.DirectoryReader;
|
||||||
import org.apache.lucene.index.IndexReader;
|
import org.apache.lucene.index.IndexReader;
|
||||||
import org.apache.lucene.index.IndexWriter;
|
import org.apache.lucene.index.IndexWriter;
|
||||||
import org.apache.lucene.util.ArrayUtil;
|
import org.apache.lucene.util.ArrayUtil;
|
||||||
|
@ -59,7 +60,7 @@ public class NearRealtimeReaderTask extends PerfTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
long t = System.currentTimeMillis();
|
long t = System.currentTimeMillis();
|
||||||
IndexReader r = IndexReader.open(w, true);
|
DirectoryReader r = IndexReader.open(w, true);
|
||||||
runData.setIndexReader(r);
|
runData.setIndexReader(r);
|
||||||
// Transfer our reference to runData
|
// Transfer our reference to runData
|
||||||
r.decRef();
|
r.decRef();
|
||||||
|
@ -77,7 +78,7 @@ public class NearRealtimeReaderTask extends PerfTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
t = System.currentTimeMillis();
|
t = System.currentTimeMillis();
|
||||||
final IndexReader newReader = IndexReader.openIfChanged(r);
|
final DirectoryReader newReader = DirectoryReader.openIfChanged(r);
|
||||||
if (newReader != null) {
|
if (newReader != null) {
|
||||||
final int delay = (int) (System.currentTimeMillis()-t);
|
final int delay = (int) (System.currentTimeMillis()-t);
|
||||||
if (reopenTimes.length == reopenCount) {
|
if (reopenTimes.length == reopenCount) {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.lucene.benchmark.byTask.PerfRunData;
|
import org.apache.lucene.benchmark.byTask.PerfRunData;
|
||||||
|
import org.apache.lucene.index.DirectoryReader;
|
||||||
import org.apache.lucene.index.IndexCommit;
|
import org.apache.lucene.index.IndexCommit;
|
||||||
import org.apache.lucene.index.IndexReader;
|
import org.apache.lucene.index.IndexReader;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
|
@ -42,7 +43,7 @@ public class OpenReaderTask extends PerfTask {
|
||||||
@Override
|
@Override
|
||||||
public int doLogic() throws IOException {
|
public int doLogic() throws IOException {
|
||||||
Directory dir = getRunData().getDirectory();
|
Directory dir = getRunData().getDirectory();
|
||||||
IndexReader r = null;
|
DirectoryReader r = null;
|
||||||
if (commitUserData != null) {
|
if (commitUserData != null) {
|
||||||
r = IndexReader.open(OpenReaderTask.findIndexCommit(dir, commitUserData));
|
r = IndexReader.open(OpenReaderTask.findIndexCommit(dir, commitUserData));
|
||||||
} else {
|
} else {
|
||||||
|
@ -71,7 +72,7 @@ public class OpenReaderTask extends PerfTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IndexCommit findIndexCommit(Directory dir, String userData) throws IOException {
|
public static IndexCommit findIndexCommit(Directory dir, String userData) throws IOException {
|
||||||
Collection<IndexCommit> commits = IndexReader.listCommits(dir);
|
Collection<IndexCommit> commits = DirectoryReader.listCommits(dir);
|
||||||
for (final IndexCommit ic : commits) {
|
for (final IndexCommit ic : commits) {
|
||||||
Map<String,String> map = ic.getUserData();
|
Map<String,String> map = ic.getUserData();
|
||||||
String ud = null;
|
String ud = null;
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.lucene.benchmark.byTask.tasks;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.lucene.benchmark.byTask.PerfRunData;
|
import org.apache.lucene.benchmark.byTask.PerfRunData;
|
||||||
|
import org.apache.lucene.index.DirectoryReader;
|
||||||
import org.apache.lucene.index.IndexReader;
|
import org.apache.lucene.index.IndexReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,8 +34,8 @@ public class ReopenReaderTask extends PerfTask {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int doLogic() throws IOException {
|
public int doLogic() throws IOException {
|
||||||
IndexReader r = getRunData().getIndexReader();
|
DirectoryReader r = getRunData().getIndexReader();
|
||||||
IndexReader nr = IndexReader.openIfChanged(r);
|
DirectoryReader nr = DirectoryReader.openIfChanged(r);
|
||||||
if (nr != null) {
|
if (nr != null) {
|
||||||
getRunData().setIndexReader(nr);
|
getRunData().setIndexReader(nr);
|
||||||
nr.decRef();
|
nr.decRef();
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.apache.lucene.benchmark.byTask.tasks.CountingSearchTestTask;
|
||||||
import org.apache.lucene.benchmark.byTask.tasks.WriteLineDocTask;
|
import org.apache.lucene.benchmark.byTask.tasks.WriteLineDocTask;
|
||||||
import org.apache.lucene.collation.CollationKeyAnalyzer;
|
import org.apache.lucene.collation.CollationKeyAnalyzer;
|
||||||
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
|
||||||
|
import org.apache.lucene.index.DirectoryReader;
|
||||||
import org.apache.lucene.index.DocsEnum;
|
import org.apache.lucene.index.DocsEnum;
|
||||||
import org.apache.lucene.index.Fields;
|
import org.apache.lucene.index.Fields;
|
||||||
import org.apache.lucene.index.FieldsEnum;
|
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.MultiFields;
|
||||||
import org.apache.lucene.index.SegmentInfos;
|
import org.apache.lucene.index.SegmentInfos;
|
||||||
import org.apache.lucene.index.SerialMergeScheduler;
|
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.Terms;
|
||||||
import org.apache.lucene.index.TermsEnum;
|
import org.apache.lucene.index.TermsEnum;
|
||||||
import org.apache.lucene.search.FieldCache.DocTermsIndex;
|
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.
|
// 4. test specific checks after the benchmark run completed.
|
||||||
assertEquals("TestSearchTask was supposed to be called!",279,CountingSearchTestTask.numSearches);
|
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.
|
// now we should be able to open the index for write.
|
||||||
IndexWriter iw = new IndexWriter(benchmark.getRunData().getDirectory(),
|
IndexWriter iw = new IndexWriter(benchmark.getRunData().getDirectory(),
|
||||||
new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random))
|
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...
|
//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("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.
|
// 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));
|
IndexWriter iw = new IndexWriter(benchmark.getRunData().getDirectory(), new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.APPEND));
|
||||||
iw.close();
|
iw.close();
|
||||||
|
@ -224,7 +225,7 @@ public class TestPerfTasksLogic extends BenchmarkTestCase {
|
||||||
//we probably should use a different doc/query maker, but...
|
//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("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.
|
// 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));
|
IndexWriter iw = new IndexWriter(benchmark.getRunData().getDirectory(), new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.APPEND));
|
||||||
iw.close();
|
iw.close();
|
||||||
|
@ -297,7 +298,7 @@ public class TestPerfTasksLogic extends BenchmarkTestCase {
|
||||||
|
|
||||||
// 4. test specific checks after the benchmark run completed.
|
// 4. test specific checks after the benchmark run completed.
|
||||||
assertEquals("TestSearchTask was supposed to be called!",139,CountingSearchTestTask.numSearches);
|
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.
|
// 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));
|
IndexWriter iw = new IndexWriter(benchmark.getRunData().getDirectory(), new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.APPEND));
|
||||||
iw.close();
|
iw.close();
|
||||||
|
@ -332,8 +333,8 @@ public class TestPerfTasksLogic extends BenchmarkTestCase {
|
||||||
// 3. execute the algorithm (required in every "logic" test)
|
// 3. execute the algorithm (required in every "logic" test)
|
||||||
Benchmark benchmark = execBenchmark(algLines);
|
Benchmark benchmark = execBenchmark(algLines);
|
||||||
|
|
||||||
IndexReader r = IndexReader.open(benchmark.getRunData().getDirectory());
|
DirectoryReader r = IndexReader.open(benchmark.getRunData().getDirectory());
|
||||||
DocTermsIndex idx = FieldCache.DEFAULT.getTermsIndex(new SlowMultiReaderWrapper(r), "country");
|
DocTermsIndex idx = FieldCache.DEFAULT.getTermsIndex(new SlowCompositeReaderWrapper(r), "country");
|
||||||
final int maxDoc = r.maxDoc();
|
final int maxDoc = r.maxDoc();
|
||||||
assertEquals(1000, maxDoc);
|
assertEquals(1000, maxDoc);
|
||||||
BytesRef br = new BytesRef();
|
BytesRef br = new BytesRef();
|
||||||
|
|
Loading…
Reference in New Issue