You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cp...@apache.org on 2016/10/26 13:50:21 UTC

[17/26] lucene-solr:jira/solr-8542-v2: SOLR-2212: Add a factory class corresponding to Lucene's NoMergePolicy

SOLR-2212: Add a factory class corresponding to Lucene's NoMergePolicy


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/768c7e26
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/768c7e26
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/768c7e26

Branch: refs/heads/jira/solr-8542-v2
Commit: 768c7e2648557d10f231f49a7c76eb040cbbcb0e
Parents: b8d9647
Author: Shalin Shekhar Mangar <sh...@apache.org>
Authored: Wed Oct 26 11:28:53 2016 +0530
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Wed Oct 26 11:28:53 2016 +0530

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  2 ++
 .../apache/solr/index/NoMergePolicyFactory.java | 34 ++++++++++++++++++++
 .../conf/solrconfig-nomergepolicyfactory.xml    | 32 ++++++++++++++++++
 .../apache/solr/core/TestMergePolicyConfig.java | 20 ++++++++++++
 4 files changed, 88 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/768c7e26/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 9dfed73..ba680a1 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -164,6 +164,8 @@ New Features
   SOLR_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
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/768c7e26/solr/core/src/java/org/apache/solr/index/NoMergePolicyFactory.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/index/NoMergePolicyFactory.java b/solr/core/src/java/org/apache/solr/index/NoMergePolicyFactory.java
new file mode 100644
index 0000000..66fa18e
--- /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;
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/768c7e26/solr/core/src/test-files/solr/collection1/conf/solrconfig-nomergepolicyfactory.xml
----------------------------------------------------------------------
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.xml
new file mode 100644
index 0000000..a9e3801
--- /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>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/768c7e26/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java b/solr/core/src/test/org/apache/solr/core/TestMergePolicyConfig.java
index fd13a8e..f8e232a 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()