1 package org.apache.lucene.benchmark.byTask.feeds;
3 * Copyright 2005 The Apache Software Foundation
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 import org.apache.lucene.search.Query;
19 import org.apache.lucene.benchmark.byTask.utils.Config;
22 * Abstract base query maker.
23 * Each query maker should just implement the {@link #prepareQueries()} method.
25 public abstract class AbstractQueryMaker implements QueryMaker {
27 protected int qnum = 0;
28 protected Query[] queries;
29 protected Config config;
31 public void resetInputs() {
35 protected abstract Query[] prepareQueries() throws Exception;
37 public void setConfig(Config config) throws Exception {
39 queries = prepareQueries();
42 public String printQueries() {
43 String newline = System.getProperty("line.separator");
44 StringBuilder sb = new StringBuilder();
45 if (queries != null) {
46 for (int i = 0; i < queries.length; i++) {
47 sb.append(i+". "+ queries[i].getClass().getSimpleName()+" - "+queries[i].toString());
54 public Query makeQuery() throws Exception {
55 return queries[nextQnum()];
59 protected synchronized int nextQnum() {
61 qnum = (qnum+1) % queries.length;
67 * @see org.apache.lucene.benchmark.byTask.feeds.QueryMaker#makeQuery(int)
69 public Query makeQuery(int size) throws Exception {
70 throw new Exception(this+".makeQuery(int size) is not supported!");