Renamed pulsing40 and Lucene40 postings format providers to pulsing and default respectively for more consistent naming in settings.

This commit is contained in:
Martijn van Groningen 2012-11-15 09:54:00 +01:00
parent 20c6085852
commit be70722de7
4 changed files with 69 additions and 9 deletions

View File

@ -0,0 +1,59 @@
/*
* Licensed to ElasticSearch and Shay Banon under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. ElasticSearch 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.elasticsearch.index.codec.postingsformat;
import org.apache.lucene.codecs.BlockTreeTermsWriter;
import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.codecs.lucene40.Lucene40PostingsFormat;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.inject.assistedinject.Assisted;
import org.elasticsearch.common.settings.Settings;
/**
* The default postingsformat, maps to {@link Lucene40PostingsFormat}.
*/
// LUCENE UPGRADE: Upgrade Lucene40PostingsFormat to next version
public class DefaultPostingsFormatProvider extends AbstractPostingsFormatProvider {
private final int minBlockSize;
private final int maxBlockSize;
private final Lucene40PostingsFormat postingsFormat;
@Inject
public DefaultPostingsFormatProvider(@Assisted String name, @Assisted Settings postingsFormatSettings) {
super(name);
this.minBlockSize = postingsFormatSettings.getAsInt("min_block_size", BlockTreeTermsWriter.DEFAULT_MIN_BLOCK_SIZE);
this.maxBlockSize = postingsFormatSettings.getAsInt("max_block_size", BlockTreeTermsWriter.DEFAULT_MAX_BLOCK_SIZE);
this.postingsFormat = new Lucene40PostingsFormat(minBlockSize, maxBlockSize);
}
public int minBlockSize() {
return minBlockSize;
}
public int maxBlockSize() {
return maxBlockSize;
}
@Override
public PostingsFormat get() {
return postingsFormat;
}
}

View File

@ -28,7 +28,8 @@ import org.elasticsearch.common.settings.Settings;
/**
*/
public class Pulsing40PostingsFormatProvider extends AbstractPostingsFormatProvider {
// LUCENE UPGRADE: Upgrade Pulsing40PostingsFormat to next version
public class PulsingPostingsFormatProvider extends AbstractPostingsFormatProvider {
private final int freqCutOff;
private final int minBlockSize;
@ -36,7 +37,7 @@ public class Pulsing40PostingsFormatProvider extends AbstractPostingsFormatProvi
private final Pulsing40PostingsFormat postingsFormat;
@Inject
public Pulsing40PostingsFormatProvider(@Assisted String name, @Assisted Settings postingsFormatSettings) {
public PulsingPostingsFormatProvider(@Assisted String name, @Assisted Settings postingsFormatSettings) {
super(name);
this.freqCutOff = postingsFormatSettings.getAsInt("freq_cut_off", 1);
this.minBlockSize = postingsFormatSettings.getAsInt("min_block_size", BlockTreeTermsWriter.DEFAULT_MIN_BLOCK_SIZE);

View File

@ -69,7 +69,7 @@ public class CodecTests extends AbstractNodesTests {
.setSettings(ImmutableSettings.settingsBuilder()
.put("number_of_shards", 1)
.put("number_of_replicas", 0)
.put("codec.postings_format.test1.type", "pulsing40")
.put("codec.postings_format.test1.type", "pulsing")
).execute().actionGet();
client.prepareIndex("test", "type1", "1").setSource("field1", "quick brown fox", "field2", "quick brown fox").execute().actionGet();

View File

@ -106,7 +106,7 @@ public class CodecTests {
.endObject().endObject().string();
Settings indexSettings = ImmutableSettings.settingsBuilder()
.put("index.codec.postings_format.my_format1.type", "lucene40")
.put("index.codec.postings_format.my_format1.type", "default")
.put("index.codec.postings_format.my_format1.min_block_size", 16)
.put("index.codec.postings_format.my_format1.max_block_size", 64)
.build();
@ -115,8 +115,8 @@ public class CodecTests {
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider(), instanceOf(PreBuiltPostingsFormatProvider.class));
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider().get(), instanceOf(Lucene40PostingsFormat.class));
assertThat(documentMapper.mappers().name("field2").mapper().postingFormatProvider(), instanceOf(Lucene40PostingsFormatProvider.class));
Lucene40PostingsFormatProvider provider = (Lucene40PostingsFormatProvider) documentMapper.mappers().name("field2").mapper().postingFormatProvider();
assertThat(documentMapper.mappers().name("field2").mapper().postingFormatProvider(), instanceOf(DefaultPostingsFormatProvider.class));
DefaultPostingsFormatProvider provider = (DefaultPostingsFormatProvider) documentMapper.mappers().name("field2").mapper().postingFormatProvider();
assertThat(provider.minBlockSize(), equalTo(16));
assertThat(provider.maxBlockSize(), equalTo(64));
}
@ -181,7 +181,7 @@ public class CodecTests {
.endObject().endObject().string();
Settings indexSettings = ImmutableSettings.settingsBuilder()
.put("index.codec.postings_format.my_format1.type", "pulsing40")
.put("index.codec.postings_format.my_format1.type", "pulsing")
.put("index.codec.postings_format.my_format1.freq_cut_off", 2)
.put("index.codec.postings_format.my_format1.min_block_size", 32)
.put("index.codec.postings_format.my_format1.max_block_size", 64)
@ -191,8 +191,8 @@ public class CodecTests {
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider(), instanceOf(PreBuiltPostingsFormatProvider.class));
assertThat(documentMapper.mappers().name("field1").mapper().postingFormatProvider().get(), instanceOf(Pulsing40PostingsFormat.class));
assertThat(documentMapper.mappers().name("field2").mapper().postingFormatProvider(), instanceOf(Pulsing40PostingsFormatProvider.class));
Pulsing40PostingsFormatProvider provider = (Pulsing40PostingsFormatProvider) documentMapper.mappers().name("field2").mapper().postingFormatProvider();
assertThat(documentMapper.mappers().name("field2").mapper().postingFormatProvider(), instanceOf(PulsingPostingsFormatProvider.class));
PulsingPostingsFormatProvider provider = (PulsingPostingsFormatProvider) documentMapper.mappers().name("field2").mapper().postingFormatProvider();
assertThat(provider.freqCutOff(), equalTo(2));
assertThat(provider.minBlockSize(), equalTo(32));
assertThat(provider.maxBlockSize(), equalTo(64));