Search in sources :

Example 11 with Config

use of org.apache.lucene.benchmark.byTask.utils.Config in project lucene-solr by apache.

the class WriteLineDocTaskTest method createPerfRunData.

private PerfRunData createPerfRunData(Path file, boolean allowEmptyDocs, String docMakerName) throws Exception {
    Properties props = new Properties();
    props.setProperty("doc.maker", docMakerName);
    props.setProperty("line.file.out", file.toAbsolutePath().toString());
    // no accidental FS dir.
    props.setProperty("directory", "RAMDirectory");
    if (allowEmptyDocs) {
        props.setProperty("sufficient.fields", ",");
    }
    if (docMakerName.equals(LegalJustDateDocMaker.class.getName())) {
        props.setProperty("line.fields", DocMaker.DATE_FIELD);
        props.setProperty("sufficient.fields", DocMaker.DATE_FIELD);
    }
    Config config = new Config(props);
    return new PerfRunData(config);
}
Also used : Config(org.apache.lucene.benchmark.byTask.utils.Config) PerfRunData(org.apache.lucene.benchmark.byTask.PerfRunData) Properties(java.util.Properties)

Example 12 with Config

use of org.apache.lucene.benchmark.byTask.utils.Config in project lucene-solr by apache.

the class SpatialFileQueryMaker method prepareQueries.

@Override
protected Query[] prepareQueries() throws Exception {
    final int maxQueries = config.get("query.file.maxQueries", 1000);
    Config srcConfig = new Config(new Properties());
    srcConfig.set("docs.file", config.get("query.file", null));
    srcConfig.set("line.parser", config.get("query.file.line.parser", null));
    srcConfig.set("content.source.forever", "false");
    List<Query> queries = new ArrayList<>();
    LineDocSource src = new LineDocSource();
    try {
        src.setConfig(srcConfig);
        src.resetInputs();
        DocData docData = new DocData();
        for (int i = 0; i < maxQueries; i++) {
            docData = src.getNextDocData(docData);
            Shape shape = SpatialDocMaker.makeShapeFromString(strategy, docData.getName(), docData.getBody());
            if (shape != null) {
                shape = shapeConverter.convert(shape);
                queries.add(makeQueryFromShape(shape));
            } else {
                //skip
                i--;
            }
        }
    } catch (NoMoreDataException e) {
    //all-done
    } finally {
        src.close();
    }
    return queries.toArray(new Query[queries.size()]);
}
Also used : Shape(org.locationtech.spatial4j.shape.Shape) Query(org.apache.lucene.search.Query) FunctionQuery(org.apache.lucene.queries.function.FunctionQuery) BooleanQuery(org.apache.lucene.search.BooleanQuery) Config(org.apache.lucene.benchmark.byTask.utils.Config) ArrayList(java.util.ArrayList) Properties(java.util.Properties)

Example 13 with Config

use of org.apache.lucene.benchmark.byTask.utils.Config in project lucene-solr by apache.

the class CreateIndexTask method doLogic.

@Override
public int doLogic() throws IOException {
    PerfRunData runData = getRunData();
    Config config = runData.getConfig();
    runData.setIndexWriter(configureWriter(config, runData, OpenMode.CREATE, null));
    return 1;
}
Also used : Config(org.apache.lucene.benchmark.byTask.utils.Config) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig) PerfRunData(org.apache.lucene.benchmark.byTask.PerfRunData)

Example 14 with Config

use of org.apache.lucene.benchmark.byTask.utils.Config in project lucene-solr by apache.

the class Sample method main.

public static void main(String[] args) throws Exception {
    Properties p = initProps();
    Config conf = new Config(p);
    PerfRunData runData = new PerfRunData(conf);
    // 1. top sequence
    // top level, not parallel
    TaskSequence top = new TaskSequence(runData, null, null, false);
    // 2. task to create the index
    CreateIndexTask create = new CreateIndexTask(runData);
    top.addTask(create);
    // 3. task seq to add 500 docs (order matters - top to bottom - add seq to top, only then add to seq)
    TaskSequence seq1 = new TaskSequence(runData, "AddDocs", top, false);
    seq1.setRepetitions(500);
    seq1.setNoChildReport();
    top.addTask(seq1);
    // 4. task to add the doc
    AddDocTask addDoc = new AddDocTask(runData);
    //addDoc.setParams("1200"); // doc size limit if supported
    // order matters 9see comment above)
    seq1.addTask(addDoc);
    // 5. task to close the index
    CloseIndexTask close = new CloseIndexTask(runData);
    top.addTask(close);
    // task to report
    RepSumByNameTask rep = new RepSumByNameTask(runData);
    top.addTask(rep);
    // print algorithm
    System.out.println(top.toString());
    // execute
    top.doLogic();
}
Also used : CloseIndexTask(org.apache.lucene.benchmark.byTask.tasks.CloseIndexTask) RepSumByNameTask(org.apache.lucene.benchmark.byTask.tasks.RepSumByNameTask) TaskSequence(org.apache.lucene.benchmark.byTask.tasks.TaskSequence) Config(org.apache.lucene.benchmark.byTask.utils.Config) CreateIndexTask(org.apache.lucene.benchmark.byTask.tasks.CreateIndexTask) PerfRunData(org.apache.lucene.benchmark.byTask.PerfRunData) Properties(java.util.Properties) AddDocTask(org.apache.lucene.benchmark.byTask.tasks.AddDocTask)

Example 15 with Config

use of org.apache.lucene.benchmark.byTask.utils.Config in project lucene-solr by apache.

the class SearchWithCollectorTask method setup.

@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", "");
}
Also used : Config(org.apache.lucene.benchmark.byTask.utils.Config) PerfRunData(org.apache.lucene.benchmark.byTask.PerfRunData)

Aggregations

Config (org.apache.lucene.benchmark.byTask.utils.Config)20 Properties (java.util.Properties)16 PerfRunData (org.apache.lucene.benchmark.byTask.PerfRunData)13 Path (java.nio.file.Path)4 WhitespaceAnalyzer (org.apache.lucene.analysis.core.WhitespaceAnalyzer)3 AddDocTask (org.apache.lucene.benchmark.byTask.tasks.AddDocTask)3 CloseIndexTask (org.apache.lucene.benchmark.byTask.tasks.CloseIndexTask)3 CreateIndexTask (org.apache.lucene.benchmark.byTask.tasks.CreateIndexTask)3 TaskSequence (org.apache.lucene.benchmark.byTask.tasks.TaskSequence)3 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)3 IndexReader (org.apache.lucene.index.IndexReader)2 Term (org.apache.lucene.index.Term)2 IndexSearcher (org.apache.lucene.search.IndexSearcher)2 TermQuery (org.apache.lucene.search.TermQuery)2 TopDocs (org.apache.lucene.search.TopDocs)2 PrintStream (java.io.PrintStream)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ContentSource (org.apache.lucene.benchmark.byTask.feeds.ContentSource)1 DocMaker (org.apache.lucene.benchmark.byTask.feeds.DocMaker)1