From be70722de7754bf61dd87e7811222c84f9b32207 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Thu, 15 Nov 2012 09:54:00 +0100 Subject: [PATCH] Renamed pulsing40 and Lucene40 postings format providers to pulsing and default respectively for more consistent naming in settings. --- .../DefaultPostingsFormatProvider.java | 59 +++++++++++++++++++ ...ava => PulsingPostingsFormatProvider.java} | 5 +- .../test/integration/codecs/CodecTests.java | 2 +- .../test/unit/index/codec/CodecTests.java | 12 ++-- 4 files changed, 69 insertions(+), 9 deletions(-) create mode 100644 src/main/java/org/elasticsearch/index/codec/postingsformat/DefaultPostingsFormatProvider.java rename src/main/java/org/elasticsearch/index/codec/postingsformat/{Pulsing40PostingsFormatProvider.java => PulsingPostingsFormatProvider.java} (89%) diff --git a/src/main/java/org/elasticsearch/index/codec/postingsformat/DefaultPostingsFormatProvider.java b/src/main/java/org/elasticsearch/index/codec/postingsformat/DefaultPostingsFormatProvider.java new file mode 100644 index 00000000000..5ec926a4c6d --- /dev/null +++ b/src/main/java/org/elasticsearch/index/codec/postingsformat/DefaultPostingsFormatProvider.java @@ -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; + } +} diff --git a/src/main/java/org/elasticsearch/index/codec/postingsformat/Pulsing40PostingsFormatProvider.java b/src/main/java/org/elasticsearch/index/codec/postingsformat/PulsingPostingsFormatProvider.java similarity index 89% rename from src/main/java/org/elasticsearch/index/codec/postingsformat/Pulsing40PostingsFormatProvider.java rename to src/main/java/org/elasticsearch/index/codec/postingsformat/PulsingPostingsFormatProvider.java index cb638d4bd83..bb212703ef3 100644 --- a/src/main/java/org/elasticsearch/index/codec/postingsformat/Pulsing40PostingsFormatProvider.java +++ b/src/main/java/org/elasticsearch/index/codec/postingsformat/PulsingPostingsFormatProvider.java @@ -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); diff --git a/src/test/java/org/elasticsearch/test/integration/codecs/CodecTests.java b/src/test/java/org/elasticsearch/test/integration/codecs/CodecTests.java index 5d8759863d0..17abef3c47e 100644 --- a/src/test/java/org/elasticsearch/test/integration/codecs/CodecTests.java +++ b/src/test/java/org/elasticsearch/test/integration/codecs/CodecTests.java @@ -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(); diff --git a/src/test/java/org/elasticsearch/test/unit/index/codec/CodecTests.java b/src/test/java/org/elasticsearch/test/unit/index/codec/CodecTests.java index f3c0c714c18..a49fa7846dc 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/codec/CodecTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/codec/CodecTests.java @@ -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));