mirror of https://github.com/apache/lucene.git
Add support for LongToEnglish doc/query maker
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@898055 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0ad2f181aa
commit
36beb9e059
|
@ -104,6 +104,7 @@
|
|||
<path id="classpath">
|
||||
<pathelement path="${common.dir}/build/classes/java"/>
|
||||
<pathelement path="${common.dir}/build/classes/demo"/>
|
||||
<pathelement path="${common.dir}/build/classes/test"/>
|
||||
<pathelement path="${common.dir}/build/contrib/highlighter/classes/java"/>
|
||||
<pathelement path="${common.dir}/build/contrib/memory/classes/java"/>
|
||||
<pathelement path="${common.dir}/build/contrib/fast-vector-highlighter/classes/java"/>
|
||||
|
@ -120,7 +121,7 @@
|
|||
<property name="task.alg" location="conf/micro-standard.alg"/>
|
||||
<property name="task.mem" value="140M"/>
|
||||
|
||||
<target name="run-task" depends="compile,check-files,get-files"
|
||||
<target name="run-task" depends="compile-test,check-files,get-files"
|
||||
description="Run compound penalty perf test (optional: -Dtask.alg=your-algorithm-file -Dtask.mem=java-max-mem)">
|
||||
<echo>Working Directory: ${working.dir}</echo>
|
||||
<java classname="org.apache.lucene.benchmark.byTask.Benchmark" maxmemory="${task.mem}" fork="true">
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package org.apache.lucene.benchmark.byTask.feeds;
|
||||
|
||||
import org.apache.lucene.util.English;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
**/
|
||||
public class LongToEnglishContentSource extends ContentSource{
|
||||
private long counter = Long.MIN_VALUE + 10;
|
||||
|
||||
public void close() throws IOException {
|
||||
|
||||
}
|
||||
//TODO: reduce/clean up synchonization
|
||||
public synchronized DocData getNextDocData(DocData docData) throws NoMoreDataException, IOException {
|
||||
docData.clear();
|
||||
docData.setBody(English.longToEnglish(counter));
|
||||
docData.setName("doc_" + String.valueOf(counter));
|
||||
docData.setTitle("title_" + String.valueOf(counter));
|
||||
docData.setDate(new Date());
|
||||
if (counter == Long.MAX_VALUE){
|
||||
counter = Long.MIN_VALUE + 10;//loop around
|
||||
}
|
||||
counter++;
|
||||
return docData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetInputs() throws IOException {
|
||||
counter = Long.MIN_VALUE + 10;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package org.apache.lucene.benchmark.byTask.feeds;
|
||||
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.standard.StandardAnalyzer;
|
||||
import org.apache.lucene.benchmark.byTask.tasks.NewAnalyzerTask;
|
||||
import org.apache.lucene.benchmark.byTask.utils.Config;
|
||||
import org.apache.lucene.queryParser.QueryParser;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.util.English;
|
||||
import org.apache.lucene.util.Version;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
**/
|
||||
public class LongToEnglishQueryMaker implements QueryMaker {
|
||||
long counter = Long.MIN_VALUE + 10;
|
||||
protected QueryParser parser;
|
||||
|
||||
public Query makeQuery(int size) throws Exception {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public synchronized Query makeQuery() throws Exception {
|
||||
|
||||
return parser.parse("" + English.longToEnglish(getNextCounter()) + "");
|
||||
}
|
||||
|
||||
private synchronized long getNextCounter() {
|
||||
if (counter == Long.MAX_VALUE){
|
||||
counter = Long.MIN_VALUE + 10;
|
||||
}
|
||||
return counter++;
|
||||
}
|
||||
|
||||
public void setConfig(Config config) throws Exception {
|
||||
Analyzer anlzr = NewAnalyzerTask.createAnalyzer(config.get("analyzer", StandardAnalyzer.class.getName()));
|
||||
parser = new QueryParser(Version.LUCENE_CURRENT, DocMaker.BODY_FIELD, anlzr);
|
||||
}
|
||||
|
||||
public void resetInputs() {
|
||||
counter = Long.MIN_VALUE + 10;
|
||||
}
|
||||
|
||||
public String printQueries() {
|
||||
return "LongToEnglish: [" + Long.MIN_VALUE + " TO " + counter + "]";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue