Apache Lucene open-source search software
LUCENE-3768: fix typos in .alg files and test that all .alg files can be parsed
Robert Muira5a0fd421ea9
diff --git a/dev-tools/eclipse/dot.classpath b/dev-tools/eclipse/dot.classpathindex 3ef063c8a99..796e0f9a646 100644--- a/dev-tools/eclipse/dot.classpath+++ b/dev-tools/eclipse/dot.classpath@@ -41,6 +41,7 @@<classpathentry kind="src" path="modules/analysis/uima/src/test"/><classpathentry kind="src" path="modules/benchmark/src/java"/><classpathentry kind="src" path="modules/benchmark/src/test"/>+ <classpathentry excluding="src" including="conf/**" kind="src" path="modules/benchmark"/><classpathentry kind="src" path="modules/facet/src/java"/><classpathentry kind="src" path="modules/facet/src/examples"/><classpathentry kind="src" path="modules/facet/src/test"/>diff --git a/modules/benchmark/CHANGES.txt b/modules/benchmark/CHANGES.txtindex 3bc4e5e133d..2defd593ed1 100644--- a/modules/benchmark/CHANGES.txt+++ b/modules/benchmark/CHANGES.txt@@ -5,6 +5,10 @@ The Benchmark contrib package contains code for benchmarking Lucene in a varietyFor more information on past and future Lucene versions, please see:http://s.apache.org/luceneversions+2/15/2011+ LUCENE-3768: fix typos in .alg files, and add test that all .alg files in conf/+ can be parsed. (Sami Siren via Robert Muir)+10/07/2011LUCENE-3262: Facet benchmarking - Benchmark tasks and sources were added for indexingwith facets, demonstrated in facets.alg. (Gilad Barkai, Doron Cohen)diff --git a/modules/benchmark/build.xml b/modules/benchmark/build.xmlindex 8b917814f71..e1f3f8324cf 100644--- a/modules/benchmark/build.xml+++ b/modules/benchmark/build.xml@@ -261,4 +261,11 @@<m2-deploy-with-pom-template pom.xml="lib/lucene-xercesImpl-pom.xml.template"jar.file="lib/xercesImpl-2.9.1-patched-XERCESJ-1257.jar" /></target>++ <target name="compile-test" depends="contrib-build.compile-test">+ <!-- copy .alg files as resources for testing -->+ <copy todir="${build.dir}/classes/test/conf">+ <fileset dir="conf"/>+ </copy>+ </target></project>diff --git a/modules/benchmark/conf/analyzer.alg b/modules/benchmark/conf/analyzer.algindex 9795fcc528c..698a5843f28 100644--- a/modules/benchmark/conf/analyzer.alg+++ b/modules/benchmark/conf/analyzer.alg@@ -55,7 +55,7 @@ log.queries=true{ "Populate"CreateIndex{ "MAddDocs" AddDoc > : 2000- ForcMerge(1)+ ForceMerge(1)CloseIndex}diff --git a/modules/benchmark/conf/collector-small.alg b/modules/benchmark/conf/collector-small.algindex 490039f7d5e..e4801ff9d65 100644--- a/modules/benchmark/conf/collector-small.alg+++ b/modules/benchmark/conf/collector-small.alg@@ -52,7 +52,7 @@ log.queries=true{ "Populate"CreateIndex{ "MAddDocs" AddDoc } : 200000- ForcMerge(1)+ ForceMerge(1)CloseIndex}diff --git a/modules/benchmark/conf/collector.alg b/modules/benchmark/conf/collector.algindex 2baf000657f..237f33b0f06 100644--- a/modules/benchmark/conf/collector.alg+++ b/modules/benchmark/conf/collector.alg@@ -52,7 +52,7 @@ log.queries=true{ "Populate"CreateIndex{ "MAddDocs" AddDoc } : 2000000- ForcMerge(1)+ ForceMerge(1)CloseIndex}diff --git a/modules/benchmark/conf/facets.alg b/modules/benchmark/conf/facets.algindex c757d5710ce..63e7cac7374 100644--- a/modules/benchmark/conf/facets.alg+++ b/modules/benchmark/conf/facets.alg@@ -52,7 +52,7 @@ task.max.depth.log=2-CreateIndex-CreateTaxonomyIndex{ "MAddDocs" AddFacetedDoc > : *- -ForcMerge(1)+ -ForceMerge(1)-CloseIndex-CloseTaxonomyIndex}diff --git a/modules/benchmark/conf/highlight-profile.alg b/modules/benchmark/conf/highlight-profile.algindex 3d56cc78d65..b62644cde31 100644--- a/modules/benchmark/conf/highlight-profile.alg+++ b/modules/benchmark/conf/highlight-profile.alg@@ -44,7 +44,7 @@ log.queries=true{ "Populate"CreateIndex{ "MAddDocs" AddDoc } : 20000- ForcMerge(1)+ ForceMerge(1)CloseIndex}{ "Rounds"diff --git a/modules/benchmark/conf/highlight-vs-vector-highlight.alg b/modules/benchmark/conf/highlight-vs-vector-highlight.algindex 61835381695..cc4382d8185 100644--- a/modules/benchmark/conf/highlight-vs-vector-highlight.alg+++ b/modules/benchmark/conf/highlight-vs-vector-highlight.alg@@ -48,7 +48,7 @@ log.queries=true{ "Populate"CreateIndex{ "MAddDocs" AddDoc } : 20000- ForcMerge(1)+ ForceMerge(1)CloseIndex}{diff --git a/modules/benchmark/conf/indexing-flush-by-RAM-multithreaded.alg b/modules/benchmark/conf/indexing-flush-by-RAM-multithreaded.algindex feb1f5ae85b..253b4517543 100644--- a/modules/benchmark/conf/indexing-flush-by-RAM-multithreaded.alg+++ b/modules/benchmark/conf/indexing-flush-by-RAM-multithreaded.alg@@ -54,7 +54,7 @@ log.queries=true{ "Populate"CreateIndex[{ "MAddDocs" AddDoc } : 5000] : 4- ForcMerge(1)+ ForceMerge(1)CloseIndex}diff --git a/modules/benchmark/conf/indexing-flush-by-RAM.alg b/modules/benchmark/conf/indexing-flush-by-RAM.algindex d4346685050..1f4169df52e 100644--- a/modules/benchmark/conf/indexing-flush-by-RAM.alg+++ b/modules/benchmark/conf/indexing-flush-by-RAM.alg@@ -54,7 +54,7 @@ log.queries=true{ "Populate"CreateIndex{ "MAddDocs" AddDoc } : 20000- ForcMerge(1)+ ForceMerge(1)CloseIndex}diff --git a/modules/benchmark/conf/indexing-multithreaded.alg b/modules/benchmark/conf/indexing-multithreaded.algindex 86e820be765..2385022540e 100644--- a/modules/benchmark/conf/indexing-multithreaded.alg+++ b/modules/benchmark/conf/indexing-multithreaded.alg@@ -54,7 +54,7 @@ log.queries=true{ "Populate"CreateIndex[{ "MAddDocs" AddDoc } : 5000] : 4- ForcMerge(1)+ ForceMerge(1)CommitIndex(commit1)CloseIndex}diff --git a/modules/benchmark/conf/indexing.alg b/modules/benchmark/conf/indexing.algindex b97195bb1f5..f546b8b4a99 100644--- a/modules/benchmark/conf/indexing.alg+++ b/modules/benchmark/conf/indexing.alg@@ -54,7 +54,7 @@ log.queries=true{ "Populate"CreateIndex{ "MAddDocs" AddDoc } : 20000- ForcMerge(1)+ ForceMerge(1)CloseIndex}diff --git a/modules/benchmark/conf/micro-standard-flush-by-ram.alg b/modules/benchmark/conf/micro-standard-flush-by-ram.algindex 63e25b5e0c8..f503081668a 100644--- a/modules/benchmark/conf/micro-standard-flush-by-ram.alg+++ b/modules/benchmark/conf/micro-standard-flush-by-ram.alg@@ -53,7 +53,7 @@ log.queries=true{ "Populate"CreateIndex{ "MAddDocs" AddDoc > : 2000- ForcMerge(1)+ ForceMerge(1)CloseIndex}diff --git a/modules/benchmark/conf/micro-standard.alg b/modules/benchmark/conf/micro-standard.algindex b3bbb45d617..bcd6ebd6084 100644--- a/modules/benchmark/conf/micro-standard.alg+++ b/modules/benchmark/conf/micro-standard.alg@@ -52,7 +52,7 @@ log.queries=true{ "Populate"-CreateIndex{ "MAddDocs" AddDoc > : 2000- -ForcMerge(1)+ -ForceMerge(1)-CloseIndex}diff --git a/modules/benchmark/conf/sample.alg b/modules/benchmark/conf/sample.algindex 2ce800e9d3f..74b5d441126 100644--- a/modules/benchmark/conf/sample.alg+++ b/modules/benchmark/conf/sample.alg@@ -62,7 +62,7 @@ log.queries=false{ "PopulateShort"CreateIndex{ AddDoc(4000) > : 20000- ForcMerge(1)+ ForceMerge(1)CloseIndex>@@ -71,7 +71,7 @@ log.queries=false{ "PopulateLong"CreateIndex{ AddDoc(8000) > : 10000- ForcMerge(1)+ ForceMerge(1)CloseIndex>diff --git a/modules/benchmark/conf/sloppy-phrase.alg b/modules/benchmark/conf/sloppy-phrase.algindex 0fc2a91cea6..bbdbed86512 100644--- a/modules/benchmark/conf/sloppy-phrase.alg+++ b/modules/benchmark/conf/sloppy-phrase.alg@@ -52,7 +52,7 @@ ResetSystemErase{ "Populate"CreateIndex{ "MAddDocs" AddDoc(2000) > : 20000- ForcMerge(1)+ ForceMerge(1)CloseIndex}diff --git a/modules/benchmark/conf/sort-standard.alg b/modules/benchmark/conf/sort-standard.algindex 0097fa8c17c..7a25574d320 100644--- a/modules/benchmark/conf/sort-standard.alg+++ b/modules/benchmark/conf/sort-standard.alg@@ -50,7 +50,7 @@ log.queries=true{ "Populate"-CreateIndex{ "MAddDocs" AddDoc(100) > : 500000- -ForcMerge(1)+ -ForceMerge(1)-CloseIndex}diff --git a/modules/benchmark/conf/standard-flush-by-RAM.alg b/modules/benchmark/conf/standard-flush-by-RAM.algindex 73a1023b1b7..cd1ebe82be4 100644--- a/modules/benchmark/conf/standard-flush-by-RAM.alg+++ b/modules/benchmark/conf/standard-flush-by-RAM.alg@@ -53,7 +53,7 @@ log.queries=true{ "Populate"CreateIndex{ "MAddDocs" AddDoc } : 20000- ForcMerge(1)+ ForceMerge(1)CloseIndex}diff --git a/modules/benchmark/conf/standard-highlights-notv.alg b/modules/benchmark/conf/standard-highlights-notv.algindex 25c4afe8a8e..040e1ef1370 100644--- a/modules/benchmark/conf/standard-highlights-notv.alg+++ b/modules/benchmark/conf/standard-highlights-notv.alg@@ -44,7 +44,7 @@ log.queries=true{ "Populate"CreateIndex{ "MAddDocs" AddDoc } : 20000- ForcMerge(1)+ ForceMerge(1)CloseIndex}{ "Rounds"diff --git a/modules/benchmark/conf/standard-highlights-tv.alg b/modules/benchmark/conf/standard-highlights-tv.algindex 8aab1f88f9d..3cd18b8df84 100644--- a/modules/benchmark/conf/standard-highlights-tv.alg+++ b/modules/benchmark/conf/standard-highlights-tv.alg@@ -44,7 +44,7 @@ log.queries=true{ "Populate"CreateIndex{ "MAddDocs" AddDoc } : 20000- ForcMerge(1)+ ForceMerge(1)CloseIndex}{ "Rounds"diff --git a/modules/benchmark/conf/standard.alg b/modules/benchmark/conf/standard.algindex 6a9038f7b02..1fcc8e1a171 100644--- a/modules/benchmark/conf/standard.alg+++ b/modules/benchmark/conf/standard.alg@@ -53,7 +53,7 @@ log.queries=true{ "Populate"CreateIndex{ "MAddDocs" AddDoc } : 20000- ForcMerge(1)+ ForceMerge(1)CloseIndex}diff --git a/modules/benchmark/conf/vector-highlight-profile.alg b/modules/benchmark/conf/vector-highlight-profile.algindex e7acc47287c..4348783b50a 100644--- a/modules/benchmark/conf/vector-highlight-profile.alg+++ b/modules/benchmark/conf/vector-highlight-profile.alg@@ -44,7 +44,7 @@ log.queries=true{ "Populate"CreateIndex{ "MAddDocs" AddDoc } : 20000- ForcMerge(1)+ ForceMerge(1)CloseIndex}{ "Rounds"diff --git a/modules/benchmark/src/test/conf/ConfLoader.java b/modules/benchmark/src/test/conf/ConfLoader.javanew file mode 100644index 00000000000..ac0b42faad7--- /dev/null+++ b/modules/benchmark/src/test/conf/ConfLoader.java@@ -0,0 +1,22 @@+package conf;++/**+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++public class ConfLoader {+ // don't mind me, I load .alg files+}diff --git a/modules/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksParse.java b/modules/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksParse.javaindex bc4bc9045dc..ba129c293d8 100755--- a/modules/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksParse.java+++ b/modules/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksParse.java@@ -17,14 +17,27 @@package org.apache.lucene.benchmark.byTask;+import java.io.File;+import java.io.FileFilter;+import java.io.FileReader;+import java.io.IOException;import java.io.StringReader;import java.util.ArrayList;+import org.apache.lucene.benchmark.byTask.feeds.AbstractQueryMaker;+import org.apache.lucene.benchmark.byTask.feeds.ContentSource;+import org.apache.lucene.benchmark.byTask.feeds.DocData;+import org.apache.lucene.benchmark.byTask.feeds.NoMoreDataException;import org.apache.lucene.benchmark.byTask.tasks.PerfTask;import org.apache.lucene.benchmark.byTask.tasks.TaskSequence;import org.apache.lucene.benchmark.byTask.utils.Algorithm;+import org.apache.lucene.benchmark.byTask.utils.Config;+import org.apache.lucene.search.Query;+import org.apache.lucene.store.RAMDirectory;import org.apache.lucene.util.LuceneTestCase;+import conf.ConfLoader;+/** Test very simply that perf tasks are parses as expected. */public class TestPerfTasksParse extends LuceneTestCase {@@ -76,5 +89,57 @@ public class TestPerfTasksParse extends LuceneTestCase {assertTrue("Task "+taskStr+" was not found in "+alg.toString(),foundAdd);}}++ public static class MockContentSource extends ContentSource {+ public DocData getNextDocData(DocData docData)+ throws NoMoreDataException, IOException {+ return docData;+ }+ public void close() throws IOException { }+ }++ public static class MockQueryMaker extends AbstractQueryMaker {+ protected Query[] prepareQueries() throws Exception {+ return new Query[0];+ }+ }++ /** Test the parsing of example scripts **/+ public void testParseExamples() throws Exception {+ // hackedy-hack-hack+ boolean foundFiles = false;+ final File examplesDir = new File(ConfLoader.class.getResource(".").toURI());+ for (File algFile : examplesDir.listFiles(new FileFilter() {+ public boolean accept(File pathname) { return pathname.isFile() && pathname.getName().endsWith(".alg"); }+ })) {+ try {+ Config config = new Config(new FileReader(algFile));+ String contentSource = config.get("content.source", null);+ if (contentSource != null) { Class.forName(contentSource); }+ config.set("work.dir", new File(TEMP_DIR,"work").getAbsolutePath());+ config.set("content.source", MockContentSource.class.getName());+ String dir = config.get("content.source", null);+ if (dir != null) { Class.forName(dir); }+ config.set("directory", RAMDirectory.class.getName());+ if (config.get("line.file.out", null) != null) {+ config.set("line.file.out", new File(TEMP_DIR,"o.txt").getAbsolutePath());+ }+ if (config.get("query.maker", null) != null) {+ Class.forName(config.get("query.maker", null));+ config.set("query.maker", MockQueryMaker.class.getName());+ }+ PerfRunData data = new PerfRunData(config);+ new Algorithm(data);+ } catch (Throwable t) {+ t.printStackTrace();+ fail("Could not parse sample file: " + algFile + " reason:"+ + t.getClass() + ":" + t.getMessage());+ }+ foundFiles = true;+ }+ if (!foundFiles) {+ fail("could not find any .alg files!");+ }+ }}