mirror of https://github.com/apache/lucene.git
SOLR-2212: Add a factory class corresponding to Lucene's NoMergePolicy
This commit is contained in:
parent
b8d9647307
commit
768c7e2648
|
@ -164,6 +164,8 @@ New Features
|
||||||
SOLR_HOME on every node. Editing config through API is supported but affects only that one node.
|
SOLR_HOME on every node. Editing config through API is supported but affects only that one node.
|
||||||
(janhoy)
|
(janhoy)
|
||||||
|
|
||||||
|
* SOLR-2212: Add a factory class corresponding to Lucene's NoMergePolicy. (Lance Norskog, Cao Manh Dat via shalin)
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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>
|
|
@ -24,6 +24,7 @@ import org.apache.lucene.index.LeafReaderContext;
|
||||||
import org.apache.lucene.index.LogByteSizeMergePolicy;
|
import org.apache.lucene.index.LogByteSizeMergePolicy;
|
||||||
import org.apache.lucene.index.LogDocMergePolicy;
|
import org.apache.lucene.index.LogDocMergePolicy;
|
||||||
import org.apache.lucene.index.LogMergePolicy;
|
import org.apache.lucene.index.LogMergePolicy;
|
||||||
|
import org.apache.lucene.index.NoMergePolicy;
|
||||||
import org.apache.lucene.index.SegmentReader;
|
import org.apache.lucene.index.SegmentReader;
|
||||||
import org.apache.lucene.index.TieredMergePolicy;
|
import org.apache.lucene.index.TieredMergePolicy;
|
||||||
import org.apache.solr.SolrTestCaseJ4;
|
import org.apache.solr.SolrTestCaseJ4;
|
||||||
|
@ -128,6 +129,25 @@ public class TestMergePolicyConfig extends SolrTestCaseJ4 {
|
||||||
assertCompoundSegments(h.getCore(), false);
|
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 {
|
public void testLogMergePolicyConfig() throws Exception {
|
||||||
|
|
||||||
final Class<? extends LogMergePolicy> mpClass = random().nextBoolean()
|
final Class<? extends LogMergePolicy> mpClass = random().nextBoolean()
|
||||||
|
|
Loading…
Reference in New Issue