Backcompat: Fix backcompat for 0.90.0.Beta1 indexes

This commit is contained in:
Robert Muir 2015-01-15 21:47:53 -05:00 committed by Ryan Ernst
parent 8e864d037e
commit 365ec15d2b
5 changed files with 17 additions and 14 deletions

View File

@ -219,7 +219,7 @@ public class Version {
public static final int V_1_4_2_ID = 1040299;
public static final Version V_1_4_2 = new Version(V_1_4_2_ID, false, org.apache.lucene.util.Version.LUCENE_4_10_2);
public static final int V_1_4_3_ID = 1040399;
public static final Version V_1_4_3 = new Version(V_1_4_3_ID, false, org.apache.lucene.util.Version.LUCENE_4_10_2);
public static final Version V_1_4_3 = new Version(V_1_4_3_ID, true, org.apache.lucene.util.Version.LUCENE_4_10_2);
public static final int V_1_5_0_ID = 1050099;
public static final Version V_1_5_0 = new Version(V_1_5_0_ID, true, org.apache.lucene.util.Version.LUCENE_4_10_3);
public static final int V_2_0_0_ID = 2000099;

View File

@ -43,7 +43,7 @@ import java.util.Map.Entry;
* @deprecated only for reading old segments
*/
@Deprecated
public final class BloomFilterPostingsFormat extends PostingsFormat {
public class BloomFilterPostingsFormat extends PostingsFormat {
public static final String BLOOM_CODEC_NAME = "XBloomFilter"; // the Lucene one is named BloomFilter
public static final int BLOOM_CODEC_VERSION = 1;
@ -83,15 +83,8 @@ public final class BloomFilterPostingsFormat extends PostingsFormat {
}
@Override
public BloomFilteredFieldsConsumer fieldsConsumer(SegmentWriteState state)
throws IOException {
if (delegatePostingsFormat == null) {
throw new UnsupportedOperationException("Error - " + getClass().getName()
+ " has been constructed without a choice of PostingsFormat");
}
return new BloomFilteredFieldsConsumer(
delegatePostingsFormat.fieldsConsumer(state), state,
delegatePostingsFormat);
public BloomFilteredFieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
throw new UnsupportedOperationException("this codec can only be used for reading");
}
@Override

View File

@ -1,2 +1,3 @@
org.elasticsearch.index.codec.postingsformat.Elasticsearch090PostingsFormat
org.elasticsearch.search.suggest.completion.Completion090PostingsFormat
org.elasticsearch.index.codec.postingsformat.BloomFilterPostingsFormat

View File

@ -55,6 +55,7 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
List<String> indexes = Arrays.asList(
/* skipping 0.90.0.Beta1...fails to load with "java.lang.IllegalArgumentException: An SPI class of type org.apache.lucene.codecs.PostingsFormat with name 'XBloomFilter' does not exist" */
"index-0.90.0.Beta1.zip",
"index-0.90.0.RC1.zip",
"index-0.90.0.RC2.zip",
"index-0.90.0.zip",
@ -110,8 +111,7 @@ public class OldIndexBackwardsCompatibilityTests extends StaticIndexBackwardComp
if (v.onOrBefore(Version.V_0_20_6)) continue;
// problematic indexes...see notes above
if (v.equals(Version.V_0_90_0_Beta1) ||
v.equals(Version.V_1_2_0)) continue;
if (v.equals(Version.V_1_2_0)) continue;
expectedVersions.add("index-" + v.toString() + ".zip");
}

View File

@ -23,10 +23,13 @@ import com.google.common.base.Predicates;
import com.google.common.collect.Iterators;
import org.apache.lucene.codecs.FieldsConsumer;
import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.index.Fields;
import org.apache.lucene.index.FilterLeafReader;
import org.apache.lucene.index.SegmentWriteState;
import org.elasticsearch.common.util.BloomFilter;
import org.elasticsearch.index.codec.postingsformat.BloomFilterPostingsFormat.BloomFilteredFieldsConsumer;
import org.elasticsearch.index.codec.postingsformat.BloomFilterPostingsFormat;
import org.elasticsearch.index.codec.postingsformat.Elasticsearch090PostingsFormat;
import org.elasticsearch.index.mapper.internal.UidFieldMapper;
@ -37,7 +40,13 @@ import java.util.Iterator;
public class Elasticsearch090RWPostingsFormat extends Elasticsearch090PostingsFormat {
@Override
public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
final BloomFilteredFieldsConsumer fieldsConsumer = bloomPostings.fieldsConsumer(state);
final PostingsFormat delegate = getDefaultWrapped();
final BloomFilteredFieldsConsumer fieldsConsumer = new BloomFilterPostingsFormat(delegate, BloomFilter.Factory.DEFAULT) {
@Override
public BloomFilteredFieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
return new BloomFilteredFieldsConsumer(delegate.fieldsConsumer(state), state,delegate);
}
}.fieldsConsumer(state);
return new FieldsConsumer() {
@Override