Apache Lucene open-source search software
SOLR-2212: Add a factory class corresponding to Lucene's NoMergePolicy
Shalin Shekhar Mangar768c7e264855
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 9dfed73de81..ba680a13e55 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -164,6 +164,8 @@ New FeaturesSOLR_HOME on every node. Editing config through API is supported but affects only that one node.(janhoy)+* SOLR-2212: Add a factory class corresponding to Lucene's NoMergePolicy. (Lance Norskog, Cao Manh Dat via shalin)+Bug Fixes----------------------diff --git a/solr/core/src/java/org/apache/solr/index/NoMergePolicyFactory.java b/solr/core/src/java/org/apache/solr/index/NoMergePolicyFactory.javanew file mode 100644index 00000000000..66fa18e9746--- /dev/null+++ b/solr/core/src/java/org/apache/solr/index/NoMergePolicyFactory.java@@ -0,0 +1,34 @@+/*+ * 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.+ */++package org.apache.solr.index;++import org.apache.lucene.index.MergePolicy;+import org.apache.lucene.index.NoMergePolicy;+import org.apache.solr.core.SolrResourceLoader;+import org.apache.solr.schema.IndexSchema;++public class NoMergePolicyFactory extends SimpleMergePolicyFactory {+ public NoMergePolicyFactory(SolrResourceLoader resourceLoader, MergePolicyFactoryArgs args, IndexSchema schema) {+ super(resourceLoader, args, schema);+ }++ @Override+ protected MergePolicy getMergePolicyInstance() {+ return NoMergePolicy.INSTANCE;+ }+}diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-nomergepolicyfactory.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-nomergepolicyfactory.xmlnew file mode 100644index 00000000000..a9e38016d20--- /dev/null+++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig-nomergepolicyfactory.xml@@ -0,0 +1,32 @@+<?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.+-->++<config>+ <luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/>+ <schemaFactory class="ClassicIndexSchemaFactory"/>++ <indexConfig>+ <useCompoundFile>${useCompoundFile:false}</useCompoundFile>+ <mergePolicyFactory class="org.apache.solr.index.NoMergePolicyFactory" />+ </indexConfig>++ <requestHandler name="standard" class="solr.StandardRequestHandler"></requestHandler>++</config>diff --git a/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java b/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.javaindex fd13a8e8cc4..f8e232a8968 100644--- a/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java+++ b/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java@@ -24,6 +24,7 @@ import org.apache.lucene.index.LeafReaderContext;import org.apache.lucene.index.LogByteSizeMergePolicy;import org.apache.lucene.index.LogDocMergePolicy;import org.apache.lucene.index.LogMergePolicy;+import org.apache.lucene.index.NoMergePolicy;import org.apache.lucene.index.SegmentReader;import org.apache.lucene.index.TieredMergePolicy;import org.apache.solr.SolrTestCaseJ4;@@ -128,6 +129,25 @@ public class TestMergePolicyConfig extends SolrTestCaseJ4 {assertCompoundSegments(h.getCore(), false);}+ public void testNoMergePolicyFactoryConfig() throws Exception {+ initCore("solrconfig-nomergepolicyfactory.xml","schema-minimal.xml");+ IndexWriterConfig iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore());+ NoMergePolicy mergePolicy = assertAndCast(NoMergePolicy.class,+ iwc.getMergePolicy());++ assertCommitSomeNewDocs();++ assertCommitSomeNewDocs();+ assertNumSegments(h.getCore(), 2);++ assertU(optimize());+ assertNumSegments(h.getCore(), 2);+ deleteCore();+ initCore("solrconfig-nomergepolicyfactory.xml","schema-minimal.xml");+ iwc = solrConfig.indexConfig.toIndexWriterConfig(h.getCore());+ assertEquals(mergePolicy, iwc.getMergePolicy());+ }+public void testLogMergePolicyConfig() throws Exception {final Class<? extends LogMergePolicy> mpClass = random().nextBoolean()