Example usage for org.apache.lucene.index IndexWriterConfig getMaxBufferedDocs

List of usage examples for org.apache.lucene.index IndexWriterConfig getMaxBufferedDocs

Introduction

In this page you can find the example usage for org.apache.lucene.index IndexWriterConfig getMaxBufferedDocs.

Prototype

@Override
    public int getMaxBufferedDocs() 

Source Link

Usage

From source file:org.apache.solr.core.TestMergePolicyConfig.java

License:Apache License

public void testLogMergePolicyConfig() throws Exception {

    final Class<? extends LogMergePolicy> mpClass = random().nextBoolean() ? LogByteSizeMergePolicy.class
            : LogDocMergePolicy.class;

    System.setProperty("solr.test.log.merge.policy", mpClass.getName());

    initCore("solrconfig-logmergepolicy.xml", "schema-minimal.xml");
    IndexWriterConfig iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore().getLatestSchema());

    // verify some props set to -1 get lucene internal defaults
    assertEquals(-1, solrConfig.indexConfig.maxBufferedDocs);
    assertEquals(IndexWriterConfig.DISABLE_AUTO_FLUSH, iwc.getMaxBufferedDocs());
    assertEquals(-1, solrConfig.indexConfig.maxIndexingThreads);
    assertEquals(IndexWriterConfig.DEFAULT_MAX_THREAD_STATES, iwc.getMaxThreadStates());
    assertEquals(-1, solrConfig.indexConfig.ramBufferSizeMB, 0.0D);
    assertEquals(IndexWriterConfig.DEFAULT_RAM_BUFFER_SIZE_MB, iwc.getRAMBufferSizeMB(), 0.0D);

    LogMergePolicy logMP = assertAndCast(mpClass, iwc.getMergePolicy());

    // set by legacy <mergeFactor> setting
    assertEquals(11, logMP.getMergeFactor());
    // set by legacy <maxMergeDocs> setting
    assertEquals(456, logMP.getMaxMergeDocs());

}

From source file:org.apache.solr.SolrTestCaseJ4.java

License:Apache License

/** sets system properties based on 
 * {@link #newIndexWriterConfig(org.apache.lucene.util.Version, org.apache.lucene.analysis.Analyzer)}
 * //from  w w  w . j a v a  2s.co m
 * configs can use these system properties to vary the indexwriter settings
 */
public static void newRandomConfig() {
    IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));

    System.setProperty("useCompoundFile", String.valueOf(iwc.getUseCompoundFile()));

    System.setProperty("solr.tests.maxBufferedDocs", String.valueOf(iwc.getMaxBufferedDocs()));
    System.setProperty("solr.tests.ramBufferSizeMB", String.valueOf(iwc.getRAMBufferSizeMB()));
    System.setProperty("solr.tests.mergeScheduler", iwc.getMergeScheduler().getClass().getName());

    // don't ask iwc.getMaxThreadStates(), sometimes newIWC uses 
    // RandomDocumentsWriterPerThreadPool and all hell breaks loose
    int maxIndexingThreads = rarely(random()) ? _TestUtil.nextInt(random(), 5, 20) // crazy value
            : _TestUtil.nextInt(random(), 1, 4); // reasonable value
    System.setProperty("solr.tests.maxIndexingThreads", String.valueOf(maxIndexingThreads));
}