Apache Solr open-source search software
LUCENE-5825: new benchmark codec.postingsFormat option
David Wayne Smiley430c264afa76
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex b34944a36d8..887e91f45b0 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -125,6 +125,9 @@ New FeaturesMcCandless)* LUCENE-5835: TermValComparator can sort missing values last. (Adrien Grand)++* LUCENE-5825: Benchmark module can use custom postings format, e.g.:+ codec.postingsFormat=Memory (Varun Shenoy, David Smiley)API Changesdiff --git a/lucene/benchmark/build.xml b/lucene/benchmark/build.xmlindex 48ab5d3120c..41ed978dc67 100644--- a/lucene/benchmark/build.xml+++ b/lucene/benchmark/build.xml@@ -173,6 +173,7 @@<pathelement path="${facet.jar}"/><pathelement path="${spatial.jar}"/><pathelement path="${queries.jar}"/>+ <pathelement path="${codecs.jar}"/><path refid="base.classpath"/><fileset dir="lib"/></path>@@ -274,7 +275,7 @@<echo>Benchmark output in JIRA table format is in file: ${shingle.jira.output.file}</echo></target>- <target name="init" depends="module-build.init,jar-memory,jar-highlighter,jar-analyzers-common,jar-queryparser,jar-facet,jar-spatial"/>+ <target name="init" depends="module-build.init,jar-memory,jar-highlighter,jar-analyzers-common,jar-queryparser,jar-facet,jar-spatial,jar-codecs"/><target name="compile-test" depends="copy-alg-files-for-testing,module-build.compile-test"/><target name="copy-alg-files-for-testing" description="copy .alg files as resources for testing">diff --git a/lucene/benchmark/conf/spatial.alg b/lucene/benchmark/conf/spatial.algindex 11aaeaa0a76..0c95ade0f67 100644--- a/lucene/benchmark/conf/spatial.alg+++ b/lucene/benchmark/conf/spatial.alg@@ -29,12 +29,14 @@ doc.maker=org.apache.lucene.benchmark.byTask.feeds.SpatialDocMaker#spatial.worldBounds=...# Spatial Grid: (PrefixTree) see SpatialPrefixTreeFactory.makeSPT#spatial.prefixTree=geohash (or quad)+spatial.prefixTree=quad#spatial.maxLevels=11#spatial.maxDistErr (in degrees) to compute maxLevels -- defaults to 1 meter's worth# RecursivePrefixTreeStrategy:spatial.docPointsOnly=true#spatial.distErrPct=.25#spatial.prefixGridScanLevel=-4+#codec.postingsFormat=Memory or (Direct)### Source & Doccontent.source=org.apache.lucene.benchmark.byTask.feeds.LineDocSourcediff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/package.html b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/package.htmlindex 09112840d69..dc9412fa6e4 100644--- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/package.html+++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/package.html@@ -587,6 +587,7 @@ Here is a list of currently defined properties:</li><li>max.buffered</li><li>directory</li><li>ram.flush.mb+ </li><li>codec.postingsFormat (eg Direct) Note: no codec should be specified through default.codec</li></ul></li>diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.javaindex ce746be2781..37e38bc8ddc 100644--- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.java+++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.java@@ -20,6 +20,8 @@ package org.apache.lucene.benchmark.byTask.tasks;import org.apache.lucene.benchmark.byTask.PerfRunData;import org.apache.lucene.benchmark.byTask.utils.Config;import org.apache.lucene.codecs.Codec;+import org.apache.lucene.codecs.PostingsFormat;+import org.apache.lucene.codecs.lucene49.Lucene49Codec;import org.apache.lucene.index.ConcurrentMergeScheduler;import org.apache.lucene.index.IndexCommit;import org.apache.lucene.index.IndexDeletionPolicy;@@ -135,6 +137,21 @@ public class CreateIndexTask extends PerfTask {}}+ final String postingsFormat = config.get("codec.postingsFormat",null);+ if (defaultCodec == null && postingsFormat != null) {+ try {+ final PostingsFormat postingsFormatChosen = PostingsFormat.forName(postingsFormat);+ iwConf.setCodec(new Lucene49Codec(){+ @Override+ public PostingsFormat getPostingsFormatForField(String field) {+ return postingsFormatChosen;+ }+ });+ } catch (Exception e) {+ throw new RuntimeException("Couldn't instantiate Postings Format: " + postingsFormat, e);+ }+ }+final String mergePolicy = config.get("merge.policy","org.apache.lucene.index.LogByteSizeMergePolicy");boolean isCompound = config.get("compound", true);