1 package org.apache.lucene.benchmark.byTask.tasks;
3 * Licensed to the Apache Software Foundation (ASF) under one or more
4 * contributor license agreements. See the NOTICE file distributed with
5 * this work for additional information regarding copyright ownership.
6 * The ASF licenses this file to You under the Apache License, Version 2.0
7 * (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import org.apache.lucene.benchmark.byTask.PerfRunData;
20 import org.apache.lucene.benchmark.byTask.feeds.QueryMaker;
21 import org.apache.lucene.benchmark.byTask.utils.Config;
22 import org.apache.lucene.search.Collector;
23 import org.apache.lucene.search.TopScoreDocCollector;
26 * Does search w/ a custom collector
28 public class SearchWithCollectorTask extends SearchTask {
30 protected String clnName;
32 public SearchWithCollectorTask(PerfRunData runData) {
37 public void setup() throws Exception {
39 //check to make sure either the doc is being stored
40 PerfRunData runData = getRunData();
41 Config config = runData.getConfig();
42 clnName = config.get("collector.class", "");
48 public boolean withCollector() {
53 protected Collector createCollector() throws Exception {
54 Collector collector = null;
55 if (clnName.equalsIgnoreCase("topScoreDocOrdered") == true) {
56 collector = TopScoreDocCollector.create(numHits(), true);
57 } else if (clnName.equalsIgnoreCase("topScoreDocUnOrdered") == true) {
58 collector = TopScoreDocCollector.create(numHits(), false);
59 } else if (clnName.length() > 0){
60 collector = Class.forName(clnName).asSubclass(Collector.class).newInstance();
63 collector = super.createCollector();
69 public QueryMaker getQueryMaker() {
70 return getRunData().getQueryMaker(this);
74 public boolean withRetrieve() {
79 public boolean withSearch() {
84 public boolean withTraverse() {
89 public boolean withWarm() {