~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to lucene/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchWithCollectorTask.java

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.apache.lucene.benchmark.byTask.tasks;
2
 
/**
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
9
 
 *
10
 
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 
 *
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.
17
 
 */
18
 
 
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;
24
 
 
25
 
/**
26
 
 * Does search w/ a custom collector
27
 
 */
28
 
public class SearchWithCollectorTask extends SearchTask {
29
 
 
30
 
  protected String clnName;
31
 
 
32
 
  public SearchWithCollectorTask(PerfRunData runData) {
33
 
    super(runData);
34
 
  }
35
 
 
36
 
  @Override
37
 
  public void setup() throws Exception {
38
 
    super.setup();
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", "");
43
 
  }
44
 
 
45
 
  
46
 
 
47
 
  @Override
48
 
  public boolean withCollector() {
49
 
    return true;
50
 
  }
51
 
 
52
 
  @Override
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();
61
 
 
62
 
    } else {
63
 
      collector = super.createCollector();
64
 
    }
65
 
    return collector;
66
 
  }
67
 
 
68
 
  @Override
69
 
  public QueryMaker getQueryMaker() {
70
 
    return getRunData().getQueryMaker(this);
71
 
  }
72
 
 
73
 
  @Override
74
 
  public boolean withRetrieve() {
75
 
    return false;
76
 
  }
77
 
 
78
 
  @Override
79
 
  public boolean withSearch() {
80
 
    return true;
81
 
  }
82
 
 
83
 
  @Override
84
 
  public boolean withTraverse() {
85
 
    return false;
86
 
  }
87
 
 
88
 
  @Override
89
 
  public boolean withWarm() {
90
 
    return false;
91
 
  }
92
 
 
93
 
}