From f703f234145d88339cfb87f5629fa031d58360c3 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Sat, 14 May 2011 12:45:20 +0000 Subject: [PATCH] LUCENE-1076: default is TieredMP if version >= 3.2 git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1103094 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/index/IndexWriterConfig.java | 19 ++++++++++++++----- .../lucene/index/TestIndexWriterConfig.java | 3 --- .../java/org/apache/solr/core/SolrConfig.java | 3 +-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lucene/src/java/org/apache/lucene/index/IndexWriterConfig.java b/lucene/src/java/org/apache/lucene/index/IndexWriterConfig.java index 742043dd5cb..ec7597560a6 100644 --- a/lucene/src/java/org/apache/lucene/index/IndexWriterConfig.java +++ b/lucene/src/java/org/apache/lucene/index/IndexWriterConfig.java @@ -133,10 +133,15 @@ public final class IndexWriterConfig implements Cloneable { /** * Creates a new config that with defaults that match the specified - * {@link Version} as well as the default {@link Analyzer}. {@link Version} is - * a placeholder for future changes. The default settings are relevant to 3.1 - * and before. In the future, if different settings will apply to different - * versions, they will be documented here. + * {@link Version} as well as the default {@link + * Analyzer}. If matchVersion is >= {@link + * Version#LUCENE_32}, {@link TieredMergePolicy} is used + * for merging; else {@link LogByteSizeMergePolicy}. + * Note that {@link TieredMergePolicy} is free to select + * non-contiguous merges, which means docIDs may not + * remain montonic over time. If this is a problem you + * should switch to {@link LogByteSizeMergePolicy} or + * {@link LogDocMergePolicy}. */ public IndexWriterConfig(Version matchVersion, Analyzer analyzer) { this.matchVersion = matchVersion; @@ -154,7 +159,11 @@ public final class IndexWriterConfig implements Cloneable { indexingChain = DocumentsWriterPerThread.defaultIndexingChain; mergedSegmentWarmer = null; codecProvider = CodecProvider.getDefault(); - mergePolicy = new TieredMergePolicy(); + if (matchVersion.onOrAfter(Version.LUCENE_32)) { + mergePolicy = new TieredMergePolicy(); + } else { + mergePolicy = new LogByteSizeMergePolicy(); + } readerPooling = DEFAULT_READER_POOLING; indexerThreadPool = new ThreadAffinityDocumentsWriterThreadPool(); readerTermsIndexDivisor = DEFAULT_READER_TERMS_INDEX_DIVISOR; diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriterConfig.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriterConfig.java index 689a6ad0911..d501694602b 100644 --- a/lucene/src/test/org/apache/lucene/index/TestIndexWriterConfig.java +++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriterConfig.java @@ -71,9 +71,6 @@ public class TestIndexWriterConfig extends LuceneTestCase { assertEquals(ThreadAffinityDocumentsWriterThreadPool.class, conf.getIndexerThreadPool().getClass()); assertNull(conf.getFlushPolicy()); assertEquals(IndexWriterConfig.DEFAULT_RAM_PER_THREAD_HARD_LIMIT_MB, conf.getRAMPerThreadHardLimitMB()); - - - // Sanity check - validate that all getters are covered. Set getters = new HashSet(); getters.add("getAnalyzer"); diff --git a/solr/src/java/org/apache/solr/core/SolrConfig.java b/solr/src/java/org/apache/solr/core/SolrConfig.java index 84d8491d9bf..9d079b8eb2d 100644 --- a/solr/src/java/org/apache/solr/core/SolrConfig.java +++ b/solr/src/java/org/apache/solr/core/SolrConfig.java @@ -57,7 +57,6 @@ import java.util.regex.Pattern; import java.util.regex.Matcher; import java.io.FileFilter; import java.io.IOException; -import java.io.InputStream; /** @@ -130,12 +129,12 @@ public class SolrConfig extends Config { throws ParserConfigurationException, IOException, SAXException { super(loader, name, is, "/config/"); initLibs(); + luceneMatchVersion = getLuceneVersion("luceneMatchVersion"); defaultIndexConfig = new SolrIndexConfig(this, null, null); mainIndexConfig = new SolrIndexConfig(this, "mainIndex", defaultIndexConfig); reopenReaders = getBool("mainIndex/reopenReaders", true); booleanQueryMaxClauseCount = getInt("query/maxBooleanClauses", BooleanQuery.getMaxClauseCount()); - luceneMatchVersion = getLuceneVersion("luceneMatchVersion"); log.info("Using Lucene MatchVersion: " + luceneMatchVersion); filtOptEnabled = getBool("query/boolTofilterOptimizer/@enabled", false);