Search in sources :

Example 6 with Config

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

the class DocMakerTest method createTestNormsDocument.

private Document createTestNormsDocument(boolean setNormsProp, boolean normsPropVal, boolean setBodyNormsProp, boolean bodyNormsVal) throws Exception {
    Properties props = new Properties();
    // Indexing configuration.
    props.setProperty("analyzer", WhitespaceAnalyzer.class.getName());
    props.setProperty("directory", "RAMDirectory");
    if (setNormsProp) {
        props.setProperty("doc.tokenized.norms", Boolean.toString(normsPropVal));
    }
    if (setBodyNormsProp) {
        props.setProperty("doc.body.tokenized.norms", Boolean.toString(bodyNormsVal));
    }
    // Create PerfRunData
    Config config = new Config(props);
    DocMaker dm = new DocMaker();
    dm.setConfig(config, new OneDocSource());
    return dm.makeDocument();
}
Also used : WhitespaceAnalyzer(org.apache.lucene.analysis.core.WhitespaceAnalyzer) Config(org.apache.lucene.benchmark.byTask.utils.Config) Properties(java.util.Properties)

Example 7 with Config

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

the class TrecContentSourceTest method testTrecFeedDirAllTypes.

/** 
   * Open a trec content source over a directory with files of all trec path types and all
   * supported formats - bzip, gzip, txt. 
   */
public void testTrecFeedDirAllTypes() throws Exception {
    Path dataDir = createTempDir("trecFeedAllTypes");
    TestUtil.unzip(getDataInputStream("trecdocs.zip"), dataDir);
    TrecContentSource tcs = new TrecContentSource();
    Properties props = new Properties();
    props.setProperty("print.props", "false");
    props.setProperty("content.source.verbose", "false");
    props.setProperty("content.source.excludeIteration", "true");
    props.setProperty("docs.dir", dataDir.toRealPath().toString().replace('\\', '/'));
    props.setProperty("trec.doc.parser", TrecParserByPath.class.getName());
    props.setProperty("content.source.forever", "false");
    tcs.setConfig(new Config(props));
    tcs.resetInputs();
    DocData dd = new DocData();
    int n = 0;
    boolean gotExpectedException = false;
    HashSet<ParsePathType> unseenTypes = new HashSet<>(Arrays.asList(ParsePathType.values()));
    try {
        while (n < 100) {
            // arbiterary limit to prevent looping forever in case of test failure
            dd = tcs.getNextDocData(dd);
            ++n;
            assertNotNull("doc data " + n + " should not be null!", dd);
            unseenTypes.remove(tcs.currPathType);
            switch(tcs.currPathType) {
                case GOV2:
                    assertDocData(dd, "TEST-000", "TEST-000 title", "TEST-000 text", tcs.parseDate("Sun, 11 Jan 2009 08:00:00 GMT"));
                    break;
                case FBIS:
                    assertDocData(dd, "TEST-001", "TEST-001 Title", "TEST-001 text", tcs.parseDate("1 January 1991"));
                    break;
                case FR94:
                    // no title extraction in this source for now
                    assertDocData(dd, "TEST-002", null, "DEPARTMENT OF SOMETHING", tcs.parseDate("February 3, 1994"));
                    break;
                case FT:
                    assertDocData(dd, "TEST-003", "Test-003 title", "Some pub text", tcs.parseDate("980424"));
                    break;
                case LATIMES:
                    assertDocData(dd, "TEST-004", "Test-004 Title", "Some paragraph", tcs.parseDate("January 17, 1997, Sunday"));
                    break;
                default:
                    assertTrue("Should never get here!", false);
            }
        }
    } catch (NoMoreDataException e) {
        gotExpectedException = true;
    }
    assertTrue("Should have gotten NoMoreDataException!", gotExpectedException);
    assertEquals("Wrong number of documents created by source!", 5, n);
    assertTrue("Did not see all types!", unseenTypes.isEmpty());
}
Also used : Path(java.nio.file.Path) Config(org.apache.lucene.benchmark.byTask.utils.Config) ParsePathType(org.apache.lucene.benchmark.byTask.feeds.TrecDocParser.ParsePathType) Properties(java.util.Properties) HashSet(java.util.HashSet)

Example 8 with Config

use of org.apache.lucene.benchmark.byTask.utils.Config 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 9 with Config

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

the class PerfTaskTest method createPerfRunData.

private PerfRunData createPerfRunData(boolean setLogStep, int logStepVal, boolean setTaskLogStep, int taskLogStepVal) throws Exception {
    Properties props = new Properties();
    if (setLogStep) {
        props.setProperty("log.step", Integer.toString(logStepVal));
    }
    if (setTaskLogStep) {
        props.setProperty("log.step.MyPerf", Integer.toString(taskLogStepVal));
    }
    // 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 10 with Config

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

the class SearchWithSortTaskTest method testSetParams_docField.

public void testSetParams_docField() throws Exception {
    SearchWithSortTask task = new SearchWithSortTask(new PerfRunData(new Config(new Properties())));
    task.setParams("doc");
    assertEquals(SortField.Type.DOC, task.getSort().getSort()[0].getType());
}
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