lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1133486 - in /lucene/dev/trunk/solr: ./ example/solr/conf/ src/java/org/apache/solr/update/ src/test-files/solr/conf/ src/test/org/apache/solr/core/
Date Wed, 08 Jun 2011 17:59:54 GMT
Author: rmuir
Date: Wed Jun  8 17:59:53 2011
New Revision: 1133486

URL: http://svn.apache.org/viewvc?rev=1133486&view=rev
Log:
SOLR-2567: change solr default to TieredMergePolicy

Added:
    lucene/dev/trunk/solr/src/test-files/solr/conf/solrconfig-mergepolicy.xml   (with props)
    lucene/dev/trunk/solr/src/test/org/apache/solr/core/TestMergePolicyConfig.java   (with
props)
Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/example/solr/conf/solrconfig.xml
    lucene/dev/trunk/solr/src/java/org/apache/solr/update/SolrIndexConfig.java
    lucene/dev/trunk/solr/src/test-files/solr/conf/solrconfig-termindex.xml
    lucene/dev/trunk/solr/src/test/org/apache/solr/core/TestConfig.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1133486&r1=1133485&r2=1133486&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Wed Jun  8 17:59:53 2011
@@ -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
 ----------------------
 

Modified: lucene/dev/trunk/solr/example/solr/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/solr/conf/solrconfig.xml?rev=1133486&r1=1133485&r2=1133486&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/solr/conf/solrconfig.xml (original)
+++ lucene/dev/trunk/solr/example/solr/conf/solrconfig.xml Wed Jun  8 17:59:53 2011
@@ -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

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/update/SolrIndexConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/update/SolrIndexConfig.java?rev=1133486&r1=1133485&r2=1133486&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/update/SolrIndexConfig.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/update/SolrIndexConfig.java Wed Jun  8
17:59:53 2011
@@ -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;
   }
 

Added: lucene/dev/trunk/solr/src/test-files/solr/conf/solrconfig-mergepolicy.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test-files/solr/conf/solrconfig-mergepolicy.xml?rev=1133486&view=auto
==============================================================================
--- lucene/dev/trunk/solr/src/test-files/solr/conf/solrconfig-mergepolicy.xml (added)
+++ lucene/dev/trunk/solr/src/test-files/solr/conf/solrconfig-mergepolicy.xml Wed Jun  8 17:59:53
2011
@@ -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>

Modified: lucene/dev/trunk/solr/src/test-files/solr/conf/solrconfig-termindex.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test-files/solr/conf/solrconfig-termindex.xml?rev=1133486&r1=1133485&r2=1133486&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test-files/solr/conf/solrconfig-termindex.xml (original)
+++ lucene/dev/trunk/solr/src/test-files/solr/conf/solrconfig-termindex.xml Wed Jun  8 17:59:53
2011
@@ -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>
 

Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/core/TestConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/core/TestConfig.java?rev=1133486&r1=1133485&r2=1133486&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/core/TestConfig.java (original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/core/TestConfig.java Wed Jun  8 17:59:53
2011
@@ -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 SolrTest
     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);
   }

Added: lucene/dev/trunk/solr/src/test/org/apache/solr/core/TestMergePolicyConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/core/TestMergePolicyConfig.java?rev=1133486&view=auto
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/core/TestMergePolicyConfig.java (added)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/core/TestMergePolicyConfig.java Wed Jun
 8 17:59:53 2011
@@ -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);
+  }
+}



Mime
View raw message