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

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

Introduction

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

Prototype

@Override
    public double getRAMBufferSizeMB() 

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)}
 * /* ww w.  j a v  a2 s .c  om*/
 * 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));
}

From source file:org.neo4j.index.impl.lucene.legacy.LuceneBatchInserterIndex.java

License:Open Source License

private IndexWriter instantiateWriter(File folder) {
    Directory dir = null;/*from   w ww.j  a va2 s.c om*/
    try {
        dir = LuceneDataSource.getDirectory(folder, identifier);
        IndexWriterConfig writerConfig = new IndexWriterConfig(type.analyzer);
        writerConfig.setRAMBufferSizeMB(determineGoodBufferSize(writerConfig.getRAMBufferSizeMB()));
        return new IndexWriter(dir, writerConfig);
    } catch (IOException e) {
        IOUtils.closeAllSilently(dir);
        throw new RuntimeException(e);
    }
}

From source file:org.neo4j.index.impl.lucene.LuceneBatchInserterIndex.java

License:Open Source License

private IndexWriter instantiateWriter(File directory) {
    try {//www  .  j a v  a  2  s.  c  o m
        IndexWriterConfig writerConfig = new IndexWriterConfig(LUCENE_VERSION, type.analyzer);
        writerConfig.setRAMBufferSizeMB(determineGoodBufferSize(writerConfig.getRAMBufferSizeMB()));
        IndexWriter writer = new IndexWriter(getDirectory(directory, identifier), writerConfig);
        return writer;
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

From source file:util.lucenceFunction.java

public static void settingIndexer(String indexPath, String filname, Long course_id, int am_id, int st_am_id,
        int safv_id) {
    Directory directory = null;/* ww  w .  jav  a  2  s .c o m*/
    IndexWriter writer = null;
    try {
        String studentAmPath = indexPath;
        directory = FSDirectory.open(new File(studentAmPath + course_id + "/" + am_id));
        IndexWriterConfig iw = new IndexWriterConfig(Version.LUCENE_47, new ThaiAnalyzer(Version.LUCENE_47));
        writer = new IndexWriter(directory, iw.setRAMBufferSizeMB(iw.getRAMBufferSizeMB()));
        String filename = filname;
        String fileExtension = filename.substring(filename.lastIndexOf(".") + 1);
        String st = "";
        if (fileExtension.equalsIgnoreCase("docx")) {
            st = DocumentFunction.readDocxFile(studentAmPath + filename);
        } else if (fileExtension.equalsIgnoreCase("doc")) {
            st = DocumentFunction.readDocFile(studentAmPath + filename);
        } else if (fileExtension.equalsIgnoreCase("xls")) {
            st = DocumentFunction.readXlsFile(studentAmPath + filename);
        } else if (fileExtension.equalsIgnoreCase("xlsx")) {
            st = DocumentFunction.readXlsxFile(studentAmPath + filename);
        } else if (fileExtension.equalsIgnoreCase("pdf")) {
            st = DocumentFunction.readPdfFile(studentAmPath + filename);
        }
        //            System.out.println(saf.getSt_am_id()+"--\n"+st);
        Document doc = new Document();
        Field f1 = new Field("student_assignment", st, Field.Store.YES, Field.Index.ANALYZED);
        Field f2 = new Field("st_am_id", st_am_id + "", Field.Store.YES, Field.Index.ANALYZED);
        Field f3 = new Field("safv_id", safv_id + "", Field.Store.YES, Field.Index.ANALYZED);
        doc.add(f1);
        doc.add(f2);
        doc.add(f3);
        writer.addDocument(doc);
        writer.close();

    } catch (IOException ex) {
        Logger.getLogger(TestDriver.class.getName()).log(Level.SEVERE, null, ex);
    }
}