mirror of https://github.com/apache/lucene.git
SOLR-2567: change solr default to TieredMergePolicy
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1133486 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d8928bb3c7
commit
50a474b6b6
|
@ -275,6 +275,12 @@ New Features
|
|||
compared to ternary trees and jaspell and very fast lookups at runtime.
|
||||
(Dawid Weiss)
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
||||
* SOLR-2567: Solr now defaults to TieredMergePolicy. See http://s.apache.org/merging
|
||||
for more information. (rmuir)
|
||||
|
||||
Bug Fixes
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -123,7 +123,9 @@
|
|||
<!-- Expert: Merge Policy
|
||||
|
||||
The Merge Policy in Lucene controls how merging is handled by
|
||||
Lucene. The default in 2.3 is the LogByteSizeMergePolicy,
|
||||
Lucene. The default in Solr 3.3 is TieredMergePolicy.
|
||||
|
||||
The default in 2.3 was the LogByteSizeMergePolicy,
|
||||
previous versions used LogDocMergePolicy.
|
||||
|
||||
LogByteSizeMergePolicy chooses segments to merge based on
|
||||
|
@ -134,7 +136,7 @@
|
|||
constructor
|
||||
-->
|
||||
<!--
|
||||
<mergePolicy class="org.apache.lucene.index.LogByteSizeMergePolicy"/>
|
||||
<mergePolicy class="org.apache.lucene.index.TieredMergePolicy"/>
|
||||
-->
|
||||
|
||||
<!-- Expert: Merge Scheduler
|
||||
|
|
|
@ -42,7 +42,7 @@ public class SolrIndexConfig {
|
|||
public static final Logger log = LoggerFactory.getLogger(SolrIndexConfig.class);
|
||||
|
||||
public static final String defaultsName ="indexDefaults";
|
||||
public static final String DEFAULT_MERGE_POLICY_CLASSNAME = LogByteSizeMergePolicy.class.getName();
|
||||
final String defaultMergePolicyClassName;
|
||||
public static final String DEFAULT_MERGE_SCHEDULER_CLASSNAME = ConcurrentMergeScheduler.class.getName();
|
||||
static final SolrIndexConfig defaultDefaults = new SolrIndexConfig();
|
||||
|
||||
|
@ -59,6 +59,7 @@ public class SolrIndexConfig {
|
|||
termIndexInterval = IndexWriterConfig.DEFAULT_TERM_INDEX_INTERVAL;
|
||||
mergePolicyInfo = null;
|
||||
mergeSchedulerInfo = null;
|
||||
defaultMergePolicyClassName = TieredMergePolicy.class.getName();
|
||||
}
|
||||
|
||||
public final Version luceneVersion;
|
||||
|
@ -87,6 +88,7 @@ public class SolrIndexConfig {
|
|||
|
||||
luceneVersion = solrConfig.luceneMatchVersion;
|
||||
|
||||
defaultMergePolicyClassName = luceneVersion.onOrAfter(Version.LUCENE_33) ? TieredMergePolicy.class.getName() : LogByteSizeMergePolicy.class.getName();
|
||||
useCompoundFile=solrConfig.getBool(prefix+"/useCompoundFile", def.useCompoundFile);
|
||||
maxBufferedDocs=solrConfig.getInt(prefix+"/maxBufferedDocs",def.maxBufferedDocs);
|
||||
maxMergeDocs=solrConfig.getInt(prefix+"/maxMergeDocs",def.maxMergeDocs);
|
||||
|
@ -162,7 +164,7 @@ public class SolrIndexConfig {
|
|||
|
||||
private MergePolicy buildMergePolicy(IndexSchema schema) {
|
||||
MergePolicy policy;
|
||||
String mpClassName = mergePolicyInfo == null ? SolrIndexConfig.DEFAULT_MERGE_POLICY_CLASSNAME : mergePolicyInfo.className;
|
||||
String mpClassName = mergePolicyInfo == null ? defaultMergePolicyClassName : mergePolicyInfo.className;
|
||||
|
||||
try {
|
||||
policy = (MergePolicy) schema.getResourceLoader().newInstance(mpClassName, null, new Class[]{IndexWriter.class}, new Object[]{this});
|
||||
|
@ -170,9 +172,6 @@ public class SolrIndexConfig {
|
|||
policy = (MergePolicy) schema.getResourceLoader().newInstance(mpClassName);
|
||||
}
|
||||
|
||||
if (mergePolicyInfo != null)
|
||||
SolrPluginUtils.invokeSetters(policy, mergePolicyInfo.initArgs);
|
||||
|
||||
if (policy instanceof LogMergePolicy) {
|
||||
LogMergePolicy logMergePolicy = (LogMergePolicy) policy;
|
||||
|
||||
|
@ -183,10 +182,22 @@ public class SolrIndexConfig {
|
|||
|
||||
if (mergeFactor != -1)
|
||||
logMergePolicy.setMergeFactor(mergeFactor);
|
||||
} else if (policy instanceof TieredMergePolicy) {
|
||||
TieredMergePolicy tieredMergePolicy = (TieredMergePolicy) policy;
|
||||
|
||||
tieredMergePolicy.setUseCompoundFile(useCompoundFile);
|
||||
|
||||
if (mergeFactor != -1) {
|
||||
tieredMergePolicy.setMaxMergeAtOnce(mergeFactor);
|
||||
tieredMergePolicy.setSegmentsPerTier(mergeFactor);
|
||||
}
|
||||
} else {
|
||||
log.warn("Use of compound file format or mergefactor cannot be configured if merge policy is not an instance of LogMergePolicy. The configured policy's defaults will be used.");
|
||||
log.warn("Use of compound file format or mergefactor cannot be configured if merge policy is not an instance of LogMergePolicy or TieredMergePolicy. The configured policy's defaults will be used.");
|
||||
}
|
||||
|
||||
if (mergePolicyInfo != null)
|
||||
SolrPluginUtils.invokeSetters(policy, mergePolicyInfo.initArgs);
|
||||
|
||||
return policy;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" ?>
|
||||
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!-- $Id: solrconfig.xml 382610 2006-03-03 01:43:03Z yonik $
|
||||
$Source$
|
||||
$Name$
|
||||
-->
|
||||
|
||||
<config>
|
||||
<luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>
|
||||
|
||||
<indexDefaults>
|
||||
<ramBufferSizeMB>32</ramBufferSizeMB>
|
||||
<termIndexInterval>256</termIndexInterval>
|
||||
<mergeFactor>7</mergeFactor>
|
||||
<useCompoundFile>false</useCompoundFile>
|
||||
<mergePolicy class="org.apache.lucene.index.TieredMergePolicy">
|
||||
<int name="maxMergeAtOnceExplicit">19</int>
|
||||
<int name="segmentsPerTier">9</int>
|
||||
</mergePolicy>
|
||||
</indexDefaults>
|
||||
|
||||
<requestHandler name="standard" class="solr.StandardRequestHandler"></requestHandler>
|
||||
|
||||
</config>
|
|
@ -38,7 +38,7 @@
|
|||
<indexDefaults>
|
||||
<ramBufferSizeMB>32</ramBufferSizeMB>
|
||||
<termIndexInterval>256</termIndexInterval>
|
||||
<mergePolicy class="org.apache.lucene.index.LogByteSizeMergePolicy"/>
|
||||
<mergePolicy class="org.apache.lucene.index.TieredMergePolicy"/>
|
||||
<mergeScheduler class="org.apache.lucene.index.ConcurrentMergeScheduler"/>
|
||||
</indexDefaults>
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package org.apache.solr.core;
|
||||
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.TieredMergePolicy;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.handler.admin.ShowFileRequestHandler;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
|
@ -95,7 +96,7 @@ public class TestConfig extends SolrTestCaseJ4 {
|
|||
double bufferSize = solrConfig.getDouble("indexDefaults/ramBufferSizeMB");
|
||||
assertTrue(bufferSize + " does not equal: " + 32, bufferSize == 32);
|
||||
String mergePolicy = solrConfig.get("indexDefaults/mergePolicy/@class");
|
||||
assertTrue(mergePolicy + " is not equal to " + SolrIndexConfig.DEFAULT_MERGE_POLICY_CLASSNAME, mergePolicy.equals(SolrIndexConfig.DEFAULT_MERGE_POLICY_CLASSNAME) == true);
|
||||
assertEquals(TieredMergePolicy.class.getName(), mergePolicy);
|
||||
String mergeSched = solrConfig.get("indexDefaults/mergeScheduler/@class");
|
||||
assertTrue(mergeSched + " is not equal to " + SolrIndexConfig.DEFAULT_MERGE_SCHEDULER_CLASSNAME, mergeSched.equals(SolrIndexConfig.DEFAULT_MERGE_SCHEDULER_CLASSNAME) == true);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package org.apache.solr.core;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.index.MergePolicy;
|
||||
import org.apache.lucene.index.TieredMergePolicy;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
public class TestMergePolicyConfig extends SolrTestCaseJ4 {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
initCore("solrconfig-mergepolicy.xml","schema.xml");
|
||||
}
|
||||
|
||||
public void testTieredMergePolicyConfig() throws Exception {
|
||||
IndexWriterConfig iwc = solrConfig.defaultIndexConfig.toIndexWriterConfig(h.getCore().getSchema());
|
||||
MergePolicy mp = iwc.getMergePolicy();
|
||||
assertTrue(mp instanceof TieredMergePolicy);
|
||||
TieredMergePolicy tieredMP = (TieredMergePolicy) mp;
|
||||
|
||||
// mp-specific setter
|
||||
assertEquals(19, tieredMP.getMaxMergeAtOnceExplicit());
|
||||
|
||||
// make sure we apply compoundFile and mergeFactor
|
||||
assertEquals(false, tieredMP.getUseCompoundFile());
|
||||
assertEquals(7, tieredMP.getMaxMergeAtOnce());
|
||||
|
||||
// make sure we overrode segmentsPerTier (split from maxMergeAtOnce out of mergeFactor)
|
||||
assertEquals(9D, tieredMP.getSegmentsPerTier(), 0.001);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue