Index: contrib/benchmark/conf/collector.alg =================================================================== --- contrib/benchmark/conf/collector.alg (revision 0) +++ contrib/benchmark/conf/collector.alg (revision 0) @@ -0,0 +1,72 @@ +#/** +# * 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. +# */ +# ------------------------------------------------------------------------------------- +# multi val params are iterated by NewRound's, added to reports, start with column name. + +# collector.class can be: +# Fully Qualified Class Name of a Collector with a empty constructor +# topDocOrdered - Creates a TopDocCollector that requires in order docs +# topDocUnordered - Like above, but allows out of order +collector.class=coll:topDocOrdered:topDocUnordered:topDocOrdered:topDocUnordered + +analyzer=org.apache.lucene.analysis.WhitespaceAnalyzer +directory=FSDirectory +#directory=RamDirectory + +doc.stored=true +doc.tokenized=true +doc.term.vector=false +log.step=100000 + +search.num.hits=1000 + +content.source=org.apache.lucene.benchmark.byTask.feeds.LongToEnglishContentSource + + +query.maker=org.apache.lucene.benchmark.byTask.feeds.LongToEnglishQueryMaker + +# task at this depth or less would print when they start +task.max.depth.log=2 + +log.queries=true +# ------------------------------------------------------------------------------------- + +{ "Rounds" + + ResetSystemErase + + { "Populate" + CreateIndex + { "MAddDocs" AddDoc } : 2000000 + Optimize + CloseIndex + } + + OpenReader + { "topDocs" SearchWithCollector > : 10000 + CloseReader + + RepSumByPref topDocs + + NewRound + +} : 4 + +RepSumByNameRound +RepSumByName +RepSumByPrefRound topDocs + Index: contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java =================================================================== --- contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java (revision 912115) +++ contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ReadTask.java (working copy) @@ -30,10 +30,12 @@ import org.apache.lucene.document.Document; import org.apache.lucene.document.Fieldable; import org.apache.lucene.index.IndexReader; +import org.apache.lucene.search.Collector; import org.apache.lucene.search.TopDocs; import org.apache.lucene.search.MultiTermQuery; import org.apache.lucene.search.TopFieldCollector; import org.apache.lucene.search.ScoreDoc; +import org.apache.lucene.search.TopScoreDocCollector; import org.apache.lucene.search.Weight; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; @@ -105,23 +107,29 @@ res++; Query q = queryMaker.makeQuery(); Sort sort = getSort(); - TopDocs hits; + TopDocs hits = null; final int numHits = numHits(); if (numHits > 0) { - if (sort != null) { - Weight w = q.weight(searcher); - TopFieldCollector collector = TopFieldCollector.create(sort, numHits, - true, withScore(), - withMaxScore(), - !w.scoresDocsOutOfOrder()); - searcher.search(w, null, collector); - hits = collector.topDocs(); + if (withCollector() == false) { + if (sort != null) { + Weight w = q.weight(searcher); + TopFieldCollector collector = TopFieldCollector.create(sort, numHits, + true, withScore(), + withMaxScore(), + !w.scoresDocsOutOfOrder()); + searcher.search(w, null, collector); + hits = collector.topDocs(); + } else { + hits = searcher.search(q, numHits); + } } else { - hits = searcher.search(q, numHits); + Collector collector = createCollector(); + searcher.search(q, null, collector); + //hits = collector.topDocs(); } final String printHitsField = getRunData().getConfig().get("print.hits.field", null); - if (printHitsField != null && printHitsField.length() > 0) { + if (hits != null && printHitsField != null && printHitsField.length() > 0) { if (q instanceof MultiTermQuery) { System.out.println("MultiTermQuery term count = " + ((MultiTermQuery) q).getTotalNumberOfTerms()); } @@ -177,6 +185,9 @@ return res; } + protected Collector createCollector() throws Exception { + return TopScoreDocCollector.create(numHits(), true); + } protected Document retrieveDoc(IndexReader ir, int id) throws IOException { @@ -192,6 +203,10 @@ * Return true if search should be performed. */ public abstract boolean withSearch(); + + public boolean withCollector(){ + return false; + } /** Index: contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchWithCollectorTask.java =================================================================== --- contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchWithCollectorTask.java (revision 0) +++ contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchWithCollectorTask.java (revision 0) @@ -0,0 +1,95 @@ +package org.apache.lucene.benchmark.byTask.tasks; +/** + * 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. + */ + +import org.apache.lucene.benchmark.byTask.PerfRunData; +import org.apache.lucene.benchmark.byTask.feeds.QueryMaker; +import org.apache.lucene.benchmark.byTask.utils.Config; +import org.apache.lucene.search.Collector; +import org.apache.lucene.search.TopScoreDocCollector; + +import java.io.IOException; + +/** + * Does search w/ a custom collector + */ +public class SearchWithCollectorTask extends SearchTask { + + protected String clnName; + + public SearchWithCollectorTask(PerfRunData runData) { + super(runData); + } + + @Override + public void setup() throws Exception { + super.setup(); + //check to make sure either the doc is being stored + PerfRunData runData = getRunData(); + Config config = runData.getConfig(); + clnName = config.get("collector.class", ""); + } + + + + @Override + public boolean withCollector() { + return true; + } + + @Override + protected Collector createCollector() throws Exception { + Collector collector = null; + if (clnName.equalsIgnoreCase("topDocOrdered") == true) { + collector = TopScoreDocCollector.create(numHits(), true); + } else if (clnName.equalsIgnoreCase("topDocUnOrdered") == true) { + collector = TopScoreDocCollector.create(numHits(), false); + } else if (clnName.equals("") == false){ + Class clazz = (Class) Class.forName(clnName); + collector = clazz.newInstance(); + } else { + collector = super.createCollector(); + } + return collector; + } + + @Override + public QueryMaker getQueryMaker() { + return getRunData().getQueryMaker(this); + } + + @Override + public boolean withRetrieve() { + return false; + } + + @Override + public boolean withSearch() { + return true; + } + + @Override + public boolean withTraverse() { + return false; + } + + @Override + public boolean withWarm() { + return false; + } + +} Property changes on: contrib\benchmark\src\java\org\apache\lucene\benchmark\byTask\tasks\SearchWithCollectorTask.java ___________________________________________________________________ Added: svn:keywords + Date Author Id Revision HeadURL Added: svn:eol-style + native Index: contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java =================================================================== --- contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java (revision 912115) +++ contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Config.java (working copy) @@ -22,20 +22,20 @@ import java.io.IOException; import java.io.Reader; import java.util.ArrayList; -import java.util.List; import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Properties; import java.util.StringTokenizer; /** * Perf run configuration properties. - *

- * Numeric property containing ":", e.g. "10:100:5" is interpreted - * as array of numeric values. It is extracted once, on first use, and + *

+ * Numeric property containing ":", e.g. "10:100:5" is interpreted + * as array of numeric values. It is extracted once, on first use, and * maintain a round number to return the appropriate value. - *

- * The config property "work.dir" tells where is the root of + *

+ * The config property "work.dir" tells where is the root of * docs data dirs and indexes dirs. It is set to either of: