Search in sources :

Example 1 with PerfRunData

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

the class LineDocSourceTest method doIndexAndSearchTestWithRepeats.

private void doIndexAndSearchTestWithRepeats(Path file, Class<? extends LineParser> lineParserClass, int numAdds, String storedField) throws Exception {
    IndexReader reader = null;
    IndexSearcher searcher = null;
    PerfRunData runData = null;
    try {
        Properties props = new Properties();
        // LineDocSource specific settings.
        props.setProperty("docs.file", file.toAbsolutePath().toString());
        if (lineParserClass != null) {
            props.setProperty("line.parser", lineParserClass.getName());
        }
        // Indexing configuration.
        props.setProperty("analyzer", WhitespaceAnalyzer.class.getName());
        props.setProperty("content.source", LineDocSource.class.getName());
        props.setProperty("directory", "RAMDirectory");
        props.setProperty("doc.stored", "true");
        props.setProperty("doc.index.props", "true");
        // Create PerfRunData
        Config config = new Config(props);
        runData = new PerfRunData(config);
        TaskSequence tasks = new TaskSequence(runData, "testBzip2", null, false);
        tasks.addTask(new CreateIndexTask(runData));
        for (int i = 0; i < numAdds; i++) {
            tasks.addTask(new AddDocTask(runData));
        }
        tasks.addTask(new CloseIndexTask(runData));
        try {
            tasks.doLogic();
        } finally {
            tasks.close();
        }
        reader = DirectoryReader.open(runData.getDirectory());
        searcher = newSearcher(reader);
        TopDocs td = searcher.search(new TermQuery(new Term("body", "body")), 10);
        assertEquals(numAdds, td.totalHits);
        assertNotNull(td.scoreDocs[0]);
        if (storedField == null) {
            // added to all docs and satisfies field-name == value
            storedField = DocMaker.BODY_FIELD;
        }
        assertEquals("Wrong field value", storedField, searcher.doc(0).get(storedField));
    } finally {
        IOUtils.close(reader, runData);
    }
}
Also used : IndexSearcher(org.apache.lucene.search.IndexSearcher) WhitespaceAnalyzer(org.apache.lucene.analysis.core.WhitespaceAnalyzer) CloseIndexTask(org.apache.lucene.benchmark.byTask.tasks.CloseIndexTask) TermQuery(org.apache.lucene.search.TermQuery) Config(org.apache.lucene.benchmark.byTask.utils.Config) CreateIndexTask(org.apache.lucene.benchmark.byTask.tasks.CreateIndexTask) Term(org.apache.lucene.index.Term) Properties(java.util.Properties) TopDocs(org.apache.lucene.search.TopDocs) TaskSequence(org.apache.lucene.benchmark.byTask.tasks.TaskSequence) IndexReader(org.apache.lucene.index.IndexReader) PerfRunData(org.apache.lucene.benchmark.byTask.PerfRunData) AddDocTask(org.apache.lucene.benchmark.byTask.tasks.AddDocTask)

Example 2 with PerfRunData

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

the class DocMakerTest method doTestIndexProperties.

private void doTestIndexProperties(boolean setIndexProps, boolean indexPropsVal, int numExpectedResults) throws Exception {
    Properties props = new Properties();
    // Indexing configuration.
    props.setProperty("analyzer", WhitespaceAnalyzer.class.getName());
    props.setProperty("content.source", OneDocSource.class.getName());
    props.setProperty("directory", "RAMDirectory");
    if (setIndexProps) {
        props.setProperty("doc.index.props", Boolean.toString(indexPropsVal));
    }
    // Create PerfRunData
    Config config = new Config(props);
    PerfRunData runData = new PerfRunData(config);
    TaskSequence tasks = new TaskSequence(runData, getTestName(), null, false);
    tasks.addTask(new CreateIndexTask(runData));
    tasks.addTask(new AddDocTask(runData));
    tasks.addTask(new CloseIndexTask(runData));
    tasks.doLogic();
    IndexReader reader = DirectoryReader.open(runData.getDirectory());
    IndexSearcher searcher = newSearcher(reader);
    TopDocs td = searcher.search(new TermQuery(new Term("key", "value")), 10);
    assertEquals(numExpectedResults, td.totalHits);
    reader.close();
}
Also used : WhitespaceAnalyzer(org.apache.lucene.analysis.core.WhitespaceAnalyzer) CloseIndexTask(org.apache.lucene.benchmark.byTask.tasks.CloseIndexTask) IndexSearcher(org.apache.lucene.search.IndexSearcher) TermQuery(org.apache.lucene.search.TermQuery) Config(org.apache.lucene.benchmark.byTask.utils.Config) CreateIndexTask(org.apache.lucene.benchmark.byTask.tasks.CreateIndexTask) Term(org.apache.lucene.index.Term) Properties(java.util.Properties) TopDocs(org.apache.lucene.search.TopDocs) TaskSequence(org.apache.lucene.benchmark.byTask.tasks.TaskSequence) IndexReader(org.apache.lucene.index.IndexReader) PerfRunData(org.apache.lucene.benchmark.byTask.PerfRunData) AddDocTask(org.apache.lucene.benchmark.byTask.tasks.AddDocTask)

Example 3 with PerfRunData

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

the class AddIndexesTaskTest method createPerfRunData.

private PerfRunData createPerfRunData() throws Exception {
    Properties props = new Properties();
    props.setProperty("writer.version", Version.LATEST.toString());
    // don't print anything
    props.setProperty("print.props", "false");
    props.setProperty("directory", "RAMDirectory");
    props.setProperty(AddIndexesTask.ADDINDEXES_INPUT_DIR, inputDir.toAbsolutePath().toString());
    Config config = new Config(props);
    return new PerfRunData(config);
}
Also used : Config(org.apache.lucene.benchmark.byTask.utils.Config) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig) PerfRunData(org.apache.lucene.benchmark.byTask.PerfRunData) Properties(java.util.Properties)

Example 4 with PerfRunData

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

the class CommitIndexTaskTest method testNoParams.

public void testNoParams() throws Exception {
    PerfRunData runData = createPerfRunData();
    new CreateIndexTask(runData).doLogic();
    new CommitIndexTask(runData).doLogic();
    new CloseIndexTask(runData).doLogic();
}
Also used : PerfRunData(org.apache.lucene.benchmark.byTask.PerfRunData)

Example 5 with PerfRunData

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

the class CreateIndexTaskTest method testNoDeletionPolicy.

public void testNoDeletionPolicy() throws Exception {
    PerfRunData runData = createPerfRunData(null);
    runData.getConfig().set("deletion.policy", NoDeletionPolicy.class.getName());
    new CreateIndexTask(runData).doLogic();
    new CloseIndexTask(runData).doLogic();
}
Also used : NoDeletionPolicy(org.apache.lucene.index.NoDeletionPolicy) PerfRunData(org.apache.lucene.benchmark.byTask.PerfRunData)

Aggregations

PerfRunData (org.apache.lucene.benchmark.byTask.PerfRunData)40 Config (org.apache.lucene.benchmark.byTask.utils.Config)13 Path (java.nio.file.Path)12 Properties (java.util.Properties)10 BufferedReader (java.io.BufferedReader)4 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 WhitespaceAnalyzer (org.apache.lucene.analysis.core.WhitespaceAnalyzer)2 DirectoryTaxonomyWriter (org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter)2 IndexReader (org.apache.lucene.index.IndexReader)2 IndexWriter (org.apache.lucene.index.IndexWriter)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 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1