Search in sources :

Example 16 with Config

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

the class OpenIndexTask method doLogic.

@Override
public int doLogic() throws IOException {
    PerfRunData runData = getRunData();
    Config config = runData.getConfig();
    final IndexCommit ic;
    if (commitUserData != null) {
        ic = OpenReaderTask.findIndexCommit(runData.getDirectory(), commitUserData);
    } else {
        ic = null;
    }
    final IndexWriter writer = CreateIndexTask.configureWriter(config, runData, OpenMode.APPEND, ic);
    runData.setIndexWriter(writer);
    return 1;
}
Also used : IndexWriter(org.apache.lucene.index.IndexWriter) Config(org.apache.lucene.benchmark.byTask.utils.Config) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig) PerfRunData(org.apache.lucene.benchmark.byTask.PerfRunData) IndexCommit(org.apache.lucene.index.IndexCommit)

Example 17 with Config

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

the class TestPerfTasksParse method testParseExamples.

/** Test the parsing of example scripts **/
@SuppressWarnings("try")
public void testParseExamples() throws Exception {
    // hackedy-hack-hack
    boolean foundFiles = false;
    final Path examplesDir = Paths.get(ConfLoader.class.getResource(".").toURI());
    try (DirectoryStream<Path> stream = Files.newDirectoryStream(examplesDir, "*.alg")) {
        for (Path path : stream) {
            Config config = new Config(Files.newBufferedReader(path, StandardCharsets.UTF_8));
            String contentSource = config.get("content.source", null);
            if (contentSource != null) {
                Class.forName(contentSource);
            }
            config.set("work.dir", createTempDir(LuceneTestCase.getTestClass().getSimpleName()).toAbsolutePath().toString());
            config.set("content.source", MockContentSource.class.getName());
            String dir = config.get("content.source", null);
            if (dir != null) {
                Class.forName(dir);
            }
            config.set("directory", RAMDirectory.class.getName());
            if (config.get("line.file.out", null) != null) {
                config.set("line.file.out", createTempFile("linefile", ".txt").toAbsolutePath().toString());
            }
            if (config.get("query.maker", null) != null) {
                Class.forName(config.get("query.maker", null));
                config.set("query.maker", MockQueryMaker.class.getName());
            }
            PerfRunData data = new PerfRunData(config);
            try (Algorithm algo = new Algorithm(data)) {
            }
            foundFiles = true;
        }
    }
    if (!foundFiles) {
        fail("could not find any .alg files!");
    }
}
Also used : Path(java.nio.file.Path) Config(org.apache.lucene.benchmark.byTask.utils.Config) Algorithm(org.apache.lucene.benchmark.byTask.utils.Algorithm) RAMDirectory(org.apache.lucene.store.RAMDirectory)

Example 18 with Config

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

the class CommitIndexTaskTest 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");
    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 19 with Config

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

the class WriteEnwikiLineDocTaskTest method createPerfRunData.

private PerfRunData createPerfRunData(Path file, 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");
    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 20 with Config

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

the class CreateIndexTaskTest method createPerfRunData.

private PerfRunData createPerfRunData(String infoStreamValue) 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");
    if (infoStreamValue != null) {
        props.setProperty("writer.info.stream", infoStreamValue);
    }
    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)

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