|
| 1 | +/* |
| 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 3 | + * or more contributor license agreements. Licensed under the Elastic License |
| 4 | + * 2.0; you may not use this file except in compliance with the Elastic License |
| 5 | + * 2.0. |
| 6 | + */ |
| 7 | + |
| 8 | +package org.elasticsearch.xpack.lucene.bwc.codecs.lucene87; |
| 9 | + |
| 10 | +import org.apache.lucene.backward_codecs.lucene50.Lucene50CompoundFormat; |
| 11 | +import org.apache.lucene.backward_codecs.lucene50.Lucene50LiveDocsFormat; |
| 12 | +import org.apache.lucene.backward_codecs.lucene50.Lucene50TermVectorsFormat; |
| 13 | +import org.apache.lucene.backward_codecs.lucene60.Lucene60FieldInfosFormat; |
| 14 | +import org.apache.lucene.backward_codecs.lucene80.Lucene80DocValuesFormat; |
| 15 | +import org.apache.lucene.backward_codecs.lucene80.Lucene80NormsFormat; |
| 16 | +import org.apache.lucene.backward_codecs.lucene84.Lucene84PostingsFormat; |
| 17 | +import org.apache.lucene.backward_codecs.lucene86.Lucene86PointsFormat; |
| 18 | +import org.apache.lucene.backward_codecs.lucene86.Lucene86SegmentInfoFormat; |
| 19 | +import org.apache.lucene.backward_codecs.lucene87.Lucene87StoredFieldsFormat; |
| 20 | +import org.apache.lucene.codecs.CompoundFormat; |
| 21 | +import org.apache.lucene.codecs.DocValuesFormat; |
| 22 | +import org.apache.lucene.codecs.FieldInfosFormat; |
| 23 | +import org.apache.lucene.codecs.KnnVectorsFormat; |
| 24 | +import org.apache.lucene.codecs.LiveDocsFormat; |
| 25 | +import org.apache.lucene.codecs.NormsFormat; |
| 26 | +import org.apache.lucene.codecs.PointsFormat; |
| 27 | +import org.apache.lucene.codecs.PostingsFormat; |
| 28 | +import org.apache.lucene.codecs.SegmentInfoFormat; |
| 29 | +import org.apache.lucene.codecs.StoredFieldsFormat; |
| 30 | +import org.apache.lucene.codecs.TermVectorsFormat; |
| 31 | +import org.apache.lucene.codecs.perfield.PerFieldDocValuesFormat; |
| 32 | +import org.apache.lucene.codecs.perfield.PerFieldPostingsFormat; |
| 33 | +import org.elasticsearch.xpack.lucene.bwc.codecs.BWCCodec; |
| 34 | + |
| 35 | +public class BWCLucene87Codec extends BWCCodec { |
| 36 | + |
| 37 | + private final TermVectorsFormat vectorsFormat = new Lucene50TermVectorsFormat(); |
| 38 | + private final FieldInfosFormat fieldInfosFormat = wrap(new Lucene60FieldInfosFormat()); |
| 39 | + private final SegmentInfoFormat segmentInfosFormat = wrap(new Lucene86SegmentInfoFormat()); |
| 40 | + private final LiveDocsFormat liveDocsFormat = new Lucene50LiveDocsFormat(); |
| 41 | + private final CompoundFormat compoundFormat = new Lucene50CompoundFormat(); |
| 42 | + private final PointsFormat pointsFormat = new Lucene86PointsFormat(); |
| 43 | + private final PostingsFormat defaultFormat; |
| 44 | + |
| 45 | + private final PostingsFormat postingsFormat = new PerFieldPostingsFormat() { |
| 46 | + @Override |
| 47 | + public PostingsFormat getPostingsFormatForField(String field) { |
| 48 | + return BWCLucene87Codec.this.getPostingsFormatForField(field); |
| 49 | + } |
| 50 | + }; |
| 51 | + |
| 52 | + private final DocValuesFormat docValuesFormat = new PerFieldDocValuesFormat() { |
| 53 | + @Override |
| 54 | + public DocValuesFormat getDocValuesFormatForField(String field) { |
| 55 | + return BWCLucene87Codec.this.getDocValuesFormatForField(field); |
| 56 | + } |
| 57 | + }; |
| 58 | + |
| 59 | + private final StoredFieldsFormat storedFieldsFormat; |
| 60 | + |
| 61 | + /** Instantiates a new codec. */ |
| 62 | + public BWCLucene87Codec() { |
| 63 | + super("BWCLucene87Codec"); |
| 64 | + this.storedFieldsFormat = new Lucene87StoredFieldsFormat(Lucene87StoredFieldsFormat.Mode.BEST_COMPRESSION); |
| 65 | + this.defaultFormat = new Lucene84PostingsFormat(); |
| 66 | + this.defaultDVFormat = new Lucene80DocValuesFormat(Lucene80DocValuesFormat.Mode.BEST_COMPRESSION); |
| 67 | + } |
| 68 | + |
| 69 | + @Override |
| 70 | + public StoredFieldsFormat storedFieldsFormat() { |
| 71 | + return storedFieldsFormat; |
| 72 | + } |
| 73 | + |
| 74 | + @Override |
| 75 | + public TermVectorsFormat termVectorsFormat() { |
| 76 | + return vectorsFormat; |
| 77 | + } |
| 78 | + |
| 79 | + @Override |
| 80 | + public PostingsFormat postingsFormat() { |
| 81 | + return postingsFormat; |
| 82 | + } |
| 83 | + |
| 84 | + @Override |
| 85 | + public final FieldInfosFormat fieldInfosFormat() { |
| 86 | + return fieldInfosFormat; |
| 87 | + } |
| 88 | + |
| 89 | + @Override |
| 90 | + public SegmentInfoFormat segmentInfoFormat() { |
| 91 | + return segmentInfosFormat; |
| 92 | + } |
| 93 | + |
| 94 | + @Override |
| 95 | + public final LiveDocsFormat liveDocsFormat() { |
| 96 | + return liveDocsFormat; |
| 97 | + } |
| 98 | + |
| 99 | + @Override |
| 100 | + public CompoundFormat compoundFormat() { |
| 101 | + return compoundFormat; |
| 102 | + } |
| 103 | + |
| 104 | + @Override |
| 105 | + public PointsFormat pointsFormat() { |
| 106 | + return pointsFormat; |
| 107 | + } |
| 108 | + |
| 109 | + @Override |
| 110 | + public final KnnVectorsFormat knnVectorsFormat() { |
| 111 | + return KnnVectorsFormat.EMPTY; |
| 112 | + } |
| 113 | + |
| 114 | + /** |
| 115 | + * Returns the postings format that should be used for writing new segments of <code>field</code>. |
| 116 | + * |
| 117 | + * <p>The default implementation always returns "Lucene84". |
| 118 | + * |
| 119 | + * <p><b>WARNING:</b> if you subclass, you are responsible for index backwards compatibility: |
| 120 | + * future version of Lucene are only guaranteed to be able to read the default implementation. |
| 121 | + */ |
| 122 | + public PostingsFormat getPostingsFormatForField(String field) { |
| 123 | + return defaultFormat; |
| 124 | + } |
| 125 | + |
| 126 | + /** |
| 127 | + * Returns the docvalues format that should be used for writing new segments of <code>field</code> |
| 128 | + * . |
| 129 | + * |
| 130 | + * <p>The default implementation always returns "Lucene80". |
| 131 | + * |
| 132 | + * <p><b>WARNING:</b> if you subclass, you are responsible for index backwards compatibility: |
| 133 | + * future version of Lucene are only guaranteed to be able to read the default implementation. |
| 134 | + */ |
| 135 | + public DocValuesFormat getDocValuesFormatForField(String field) { |
| 136 | + return defaultDVFormat; |
| 137 | + } |
| 138 | + |
| 139 | + @Override |
| 140 | + public final DocValuesFormat docValuesFormat() { |
| 141 | + return docValuesFormat; |
| 142 | + } |
| 143 | + |
| 144 | + private final DocValuesFormat defaultDVFormat; |
| 145 | + |
| 146 | + private final NormsFormat normsFormat = new Lucene80NormsFormat(); |
| 147 | + |
| 148 | + @Override |
| 149 | + public NormsFormat normsFormat() { |
| 150 | + return normsFormat; |
| 151 | + } |
| 152 | + |
| 153 | +} |
0 commit comments