Example usage for org.apache.lucene.index ConcurrentMergeScheduler setDefaultMaxMergesAndThreads

List of usage examples for org.apache.lucene.index ConcurrentMergeScheduler setDefaultMaxMergesAndThreads

Introduction

In this page you can find the example usage for org.apache.lucene.index ConcurrentMergeScheduler setDefaultMaxMergesAndThreads.

Prototype

public synchronized void setDefaultMaxMergesAndThreads(boolean spins) 

Source Link

Document

Sets max merges and threads to proper defaults for rotational or non-rotational storage.

Usage

From source file:org.eclipse.dltk.internal.core.index.lucene.IndexContainer.java

License:Open Source License

private IndexWriter createWriter(Path path) throws IOException {
    Directory indexDir = new IndexDirectory(path, SimpleFSLockFactory.INSTANCE);
    purgeLocks(path);//  w w  w  .ja v a2 s .  c om
    IndexWriterConfig config = new IndexWriterConfig(new SimpleAnalyzer());
    ConcurrentMergeScheduler mergeScheduler = new ConcurrentMergeScheduler();
    mergeScheduler.setDefaultMaxMergesAndThreads(true);
    config.setMergeScheduler(mergeScheduler);
    config.setOpenMode(OpenMode.CREATE_OR_APPEND);
    config.setWriteLockTimeout(WRITE_LOCK_TIMEOUT);
    config.setCommitOnClose(false);
    return new IndexWriter(indexDir, config);
}

From source file:org.meresco.lucene.numerate.UriEnumerate.java

License:Open Source License

/**
 *
 * @param path/*  ww w.  j ava  2 s . c  o  m*/
 * @param max_cache_size
 * @param withTransactionLog allows for crash recovery, but slows down UriNumerate considerably because of file system flush.
 * @throws IOException
 */
public UriEnumerate(String path, int max_cache_size, boolean withTransactionLog) throws IOException {
    IndexWriterConfig config = new IndexWriterConfig(null);
    ConcurrentMergeScheduler ms = (ConcurrentMergeScheduler) config.getMergeScheduler();
    ms.setDefaultMaxMergesAndThreads(/* spins= */false);
    LogDocMergePolicy mp = new LogDocMergePolicy();
    mp.setMergeFactor(2);
    mp.setMinMergeDocs(max_cache_size);
    config.setMergePolicy(mp);
    config.setCodec(new Lucene60Codec() {
        @Override
        public PostingsFormat getPostingsFormatForField(String field) {
            return new BloomFilteringPostingsFormat(super.getPostingsFormatForField(field));
        }
    });
    config.setUseCompoundFile(false);
    this.writer = new IndexWriter(FSDirectory.open(FileSystems.getDefault().getPath(path)), config);
    this.next_ord = writer.numDocs() + 1;
    this.searcher = new SimpleSearcher(this.writer);
    this.cache = new Cache(max_cache_size, () -> this.commit());
    this.transactionLog = new TransactionLog(withTransactionLog ? path + "/transactionLog" : null);
    this.transactionLog.maybeRecover();
}