Skip to content

Commit 6071c76

Browse files
authored
Migrate indices package to TransportVersion (#93077)
This migrates org.elasticsearch.index and org.elasticsearch.indices to use TransportVersion
1 parent b15098a commit 6071c76

33 files changed

+122
-109
lines changed

modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalRequest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
package org.elasticsearch.index.rankeval;
1010

11-
import org.elasticsearch.Version;
11+
import org.elasticsearch.TransportVersion;
1212
import org.elasticsearch.action.ActionRequest;
1313
import org.elasticsearch.action.ActionRequestValidationException;
1414
import org.elasticsearch.action.IndicesRequest;
@@ -45,7 +45,7 @@ public RankEvalRequest(RankEvalSpec rankingEvaluationSpec, String[] indices) {
4545
rankingEvaluationSpec = new RankEvalSpec(in);
4646
indices = in.readStringArray();
4747
indicesOptions = IndicesOptions.readIndicesOptions(in);
48-
if (in.getVersion().onOrAfter(Version.V_7_6_0)) {
48+
if (in.getTransportVersion().onOrAfter(TransportVersion.V_7_6_0)) {
4949
searchType = SearchType.fromId(in.readByte());
5050
}
5151
}
@@ -126,7 +126,7 @@ public void writeTo(StreamOutput out) throws IOException {
126126
rankingEvaluationSpec.writeTo(out);
127127
out.writeStringArray(indices);
128128
indicesOptions.writeIndicesOptions(out);
129-
if (out.getVersion().onOrAfter(Version.V_7_6_0)) {
129+
if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_6_0)) {
130130
out.writeByte(searchType.id());
131131
}
132132
}

server/src/main/java/org/elasticsearch/cluster/ClusterInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public ClusterInfo(StreamInput in) throws IOException {
9797
} else {
9898
this.dataPath = in.readImmutableMap(nested -> NodeAndShard.from(new ShardRouting(nested)), StreamInput::readString);
9999
}
100-
if (in.getVersion().onOrAfter(StoreStats.RESERVED_BYTES_VERSION)) {
100+
if (in.getTransportVersion().onOrAfter(StoreStats.RESERVED_BYTES_VERSION)) {
101101
this.reservedSpace = in.readImmutableMap(NodeAndPath::new, ReservedSpace::new);
102102
} else {
103103
this.reservedSpace = Map.of();
@@ -117,7 +117,7 @@ public void writeTo(StreamOutput out) throws IOException {
117117
} else {
118118
out.writeMap(this.dataPath, (o, k) -> createFakeShardRoutingFromNodeAndShard(k).writeTo(o), StreamOutput::writeString);
119119
}
120-
if (out.getVersion().onOrAfter(StoreStats.RESERVED_BYTES_VERSION)) {
120+
if (out.getTransportVersion().onOrAfter(StoreStats.RESERVED_BYTES_VERSION)) {
121121
out.writeMap(this.reservedSpace);
122122
}
123123
}

server/src/main/java/org/elasticsearch/index/engine/Segment.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import org.apache.lucene.search.SortedNumericSortField;
1515
import org.apache.lucene.search.SortedSetSelector;
1616
import org.apache.lucene.search.SortedSetSortField;
17-
import org.elasticsearch.Version;
17+
import org.elasticsearch.TransportVersion;
1818
import org.elasticsearch.common.io.stream.StreamInput;
1919
import org.elasticsearch.common.io.stream.StreamOutput;
2020
import org.elasticsearch.common.io.stream.Writeable;
@@ -52,7 +52,7 @@ public Segment(StreamInput in) throws IOException {
5252
version = Lucene.parseVersionLenient(in.readOptionalString(), null);
5353
compound = in.readOptionalBoolean();
5454
mergeId = in.readOptionalString();
55-
if (in.getVersion().before(Version.V_8_0_0)) {
55+
if (in.getTransportVersion().before(TransportVersion.V_8_0_0)) {
5656
in.readLong(); // memoryInBytes
5757
}
5858
if (in.readBoolean()) {
@@ -159,7 +159,7 @@ public void writeTo(StreamOutput out) throws IOException {
159159
out.writeOptionalString(version.toString());
160160
out.writeOptionalBoolean(compound);
161161
out.writeOptionalString(mergeId);
162-
if (out.getVersion().before(Version.V_8_0_0)) {
162+
if (out.getTransportVersion().before(TransportVersion.V_8_0_0)) {
163163
out.writeLong(0); // memoryInBytes
164164
}
165165

@@ -252,7 +252,7 @@ private static void writeSegmentSort(StreamOutput out, Sort sort) throws IOExcep
252252
o.writeBoolean(((SortedNumericSortField) field).getSelector() == SortedNumericSelector.Type.MAX);
253253
o.writeBoolean(field.getReverse());
254254
} else if (field.getType().equals(SortField.Type.STRING)) {
255-
if (o.getVersion().before(Version.V_8_5_0)) {
255+
if (o.getTransportVersion().before(TransportVersion.V_8_5_0)) {
256256
// The closest supported version before 8.5.0 was SortedSet fields, so we mimic that
257257
o.writeByte(SORT_STRING_SET);
258258
o.writeOptionalBoolean(field.getMissingValue() == null ? null : field.getMissingValue() == SortField.STRING_FIRST);

server/src/main/java/org/elasticsearch/index/engine/SegmentsStats.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
package org.elasticsearch.index.engine;
1010

11-
import org.elasticsearch.Version;
11+
import org.elasticsearch.TransportVersion;
1212
import org.elasticsearch.common.Strings;
1313
import org.elasticsearch.common.io.stream.StreamInput;
1414
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -39,7 +39,7 @@ public SegmentsStats() {
3939

4040
public SegmentsStats(StreamInput in) throws IOException {
4141
count = in.readVLong();
42-
if (in.getVersion().before(Version.V_8_0_0)) {
42+
if (in.getTransportVersion().before(TransportVersion.V_8_0_0)) {
4343
in.readLong(); // memoryInBytes
4444
in.readLong(); // termsMemoryInBytes
4545
in.readLong(); // storedFieldsMemoryInBytes
@@ -220,7 +220,7 @@ static final class Fields {
220220
@Override
221221
public void writeTo(StreamOutput out) throws IOException {
222222
out.writeVLong(count);
223-
if (out.getVersion().before(Version.V_8_0_0)) {
223+
if (out.getTransportVersion().before(TransportVersion.V_8_0_0)) {
224224
out.writeLong(0L); // memoryInBytes
225225
out.writeLong(0L); // termsMemoryInBytes
226226
out.writeLong(0L); // storedFieldsMemoryInBytes
@@ -250,7 +250,7 @@ public static class FileStats implements Writeable, ToXContentFragment {
250250
private final long max;
251251

252252
FileStats(StreamInput in) throws IOException {
253-
if (in.getVersion().onOrAfter(Version.V_7_13_0)) {
253+
if (in.getTransportVersion().onOrAfter(TransportVersion.V_7_13_0)) {
254254
this.ext = in.readString();
255255
this.total = in.readVLong();
256256
this.count = in.readVLong();
@@ -295,7 +295,7 @@ public long getMax() {
295295

296296
@Override
297297
public void writeTo(StreamOutput out) throws IOException {
298-
if (out.getVersion().onOrAfter(Version.V_7_13_0)) {
298+
if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_13_0)) {
299299
out.writeString(ext);
300300
out.writeVLong(total);
301301
out.writeVLong(count);

server/src/main/java/org/elasticsearch/index/get/GetResult.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
package org.elasticsearch.index.get;
1010

1111
import org.elasticsearch.ElasticsearchParseException;
12-
import org.elasticsearch.Version;
12+
import org.elasticsearch.TransportVersion;
1313
import org.elasticsearch.common.Strings;
1414
import org.elasticsearch.common.bytes.BytesReference;
1515
import org.elasticsearch.common.compress.CompressorFactory;
@@ -66,7 +66,7 @@ public class GetResult implements Writeable, Iterable<DocumentField>, ToXContent
6666

6767
public GetResult(StreamInput in) throws IOException {
6868
index = in.readString();
69-
if (in.getVersion().before(Version.V_8_0_0)) {
69+
if (in.getTransportVersion().before(TransportVersion.V_8_0_0)) {
7070
in.readOptionalString();
7171
}
7272
id = in.readString();
@@ -386,7 +386,7 @@ public static GetResult fromXContent(XContentParser parser) throws IOException {
386386
@Override
387387
public void writeTo(StreamOutput out) throws IOException {
388388
out.writeString(index);
389-
if (out.getVersion().before(Version.V_8_0_0)) {
389+
if (out.getTransportVersion().before(TransportVersion.V_8_0_0)) {
390390
out.writeOptionalString(MapperService.SINGLE_MAPPING_NAME);
391391
}
392392
out.writeString(id);

server/src/main/java/org/elasticsearch/index/query/AbstractGeometryQueryBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.apache.lucene.search.MatchNoDocsQuery;
1212
import org.apache.lucene.search.Query;
1313
import org.apache.lucene.util.SetOnce;
14-
import org.elasticsearch.Version;
14+
import org.elasticsearch.TransportVersion;
1515
import org.elasticsearch.action.ActionListener;
1616
import org.elasticsearch.action.get.GetRequest;
1717
import org.elasticsearch.client.internal.Client;
@@ -141,7 +141,7 @@ protected AbstractGeometryQueryBuilder(StreamInput in) throws IOException {
141141
} else {
142142
shape = null;
143143
indexedShapeId = in.readOptionalString();
144-
if (in.getVersion().before(Version.V_8_0_0)) {
144+
if (in.getTransportVersion().before(TransportVersion.V_8_0_0)) {
145145
String type = in.readOptionalString();
146146
assert MapperService.SINGLE_MAPPING_NAME.equals(type) : "Expected type [_doc], got [" + type + "]";
147147
}
@@ -166,7 +166,7 @@ protected void doWriteTo(StreamOutput out) throws IOException {
166166
GeometryIO.writeGeometry(out, shape);
167167
} else {
168168
out.writeOptionalString(indexedShapeId);
169-
if (out.getVersion().before(Version.V_8_0_0)) {
169+
if (out.getTransportVersion().before(TransportVersion.V_8_0_0)) {
170170
out.writeOptionalString(MapperService.SINGLE_MAPPING_NAME);
171171
}
172172
out.writeOptionalString(indexedShapeIndex);

server/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.apache.lucene.search.MatchNoDocsQuery;
1212
import org.apache.lucene.search.Query;
1313
import org.elasticsearch.ElasticsearchParseException;
14+
import org.elasticsearch.TransportVersion;
1415
import org.elasticsearch.Version;
1516
import org.elasticsearch.common.Numbers;
1617
import org.elasticsearch.common.ParsingException;
@@ -76,7 +77,7 @@ public GeoBoundingBoxQueryBuilder(StreamInput in) throws IOException {
7677
super(in);
7778
fieldName = in.readString();
7879
geoBoundingBox = new GeoBoundingBox(in);
79-
if (in.getVersion().before(Version.V_8_0_0)) {
80+
if (in.getTransportVersion().before(TransportVersion.V_8_0_0)) {
8081
in.readVInt(); // ignore value
8182
}
8283
validationMethod = GeoValidationMethod.readFromStream(in);
@@ -87,7 +88,7 @@ public GeoBoundingBoxQueryBuilder(StreamInput in) throws IOException {
8788
protected void doWriteTo(StreamOutput out) throws IOException {
8889
out.writeString(fieldName);
8990
geoBoundingBox.writeTo(out);
90-
if (out.getVersion().before(Version.V_8_0_0)) {
91+
if (out.getTransportVersion().before(TransportVersion.V_8_0_0)) {
9192
out.writeVInt(0);
9293
}
9394
validationMethod.writeTo(out);

server/src/main/java/org/elasticsearch/index/query/IdsQueryBuilder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
package org.elasticsearch.index.query;
1010

1111
import org.apache.lucene.search.Query;
12+
import org.elasticsearch.TransportVersion;
1213
import org.elasticsearch.Version;
1314
import org.elasticsearch.common.ParsingException;
1415
import org.elasticsearch.common.Strings;
@@ -53,7 +54,7 @@ public IdsQueryBuilder() {
5354
*/
5455
public IdsQueryBuilder(StreamInput in) throws IOException {
5556
super(in);
56-
if (in.getVersion().before(Version.V_8_0_0)) {
57+
if (in.getTransportVersion().before(TransportVersion.V_8_0_0)) {
5758
// types no longer relevant so ignore
5859
String[] types = in.readStringArray();
5960
if (types.length > 0) {
@@ -65,7 +66,7 @@ public IdsQueryBuilder(StreamInput in) throws IOException {
6566

6667
@Override
6768
protected void doWriteTo(StreamOutput out) throws IOException {
68-
if (out.getVersion().before(Version.V_8_0_0)) {
69+
if (out.getTransportVersion().before(TransportVersion.V_8_0_0)) {
6970
// types not supported so send an empty array to previous versions
7071
out.writeStringArray(Strings.EMPTY_ARRAY);
7172
}

server/src/main/java/org/elasticsearch/index/query/InnerHitBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
package org.elasticsearch.index.query;
99

10-
import org.elasticsearch.Version;
10+
import org.elasticsearch.TransportVersion;
1111
import org.elasticsearch.common.ParsingException;
1212
import org.elasticsearch.common.Strings;
1313
import org.elasticsearch.common.io.stream.StreamInput;
@@ -189,7 +189,7 @@ public InnerHitBuilder(StreamInput in) throws IOException {
189189
highlightBuilder = in.readOptionalWriteable(HighlightBuilder::new);
190190
this.innerCollapseBuilder = in.readOptionalWriteable(CollapseBuilder::new);
191191

192-
if (in.getVersion().onOrAfter(Version.V_7_10_0)) {
192+
if (in.getTransportVersion().onOrAfter(TransportVersion.V_7_10_0)) {
193193
if (in.readBoolean()) {
194194
fetchFields = in.readList(FieldAndFormat::new);
195195
}
@@ -229,7 +229,7 @@ public void writeTo(StreamOutput out) throws IOException {
229229
out.writeOptionalWriteable(highlightBuilder);
230230
out.writeOptionalWriteable(innerCollapseBuilder);
231231

232-
if (out.getVersion().onOrAfter(Version.V_7_10_0)) {
232+
if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_10_0)) {
233233
out.writeBoolean(fetchFields != null);
234234
if (fetchFields != null) {
235235
out.writeList(fetchFields);

server/src/main/java/org/elasticsearch/index/query/IntervalsSourceProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import org.apache.lucene.queries.intervals.Intervals;
1414
import org.apache.lucene.queries.intervals.IntervalsSource;
1515
import org.apache.lucene.util.BytesRef;
16-
import org.elasticsearch.Version;
16+
import org.elasticsearch.TransportVersion;
1717
import org.elasticsearch.common.ParsingException;
1818
import org.elasticsearch.common.io.stream.NamedWriteable;
1919
import org.elasticsearch.common.io.stream.StreamInput;
@@ -120,7 +120,7 @@ public Match(StreamInput in) throws IOException {
120120
this.ordered = in.readBoolean();
121121
this.analyzer = in.readOptionalString();
122122
this.filter = in.readOptionalWriteable(IntervalFilter::new);
123-
if (in.getVersion().onOrAfter(Version.V_7_2_0)) {
123+
if (in.getTransportVersion().onOrAfter(TransportVersion.V_7_2_0)) {
124124
this.useField = in.readOptionalString();
125125
} else {
126126
this.useField = null;
@@ -204,7 +204,7 @@ public void writeTo(StreamOutput out) throws IOException {
204204
out.writeBoolean(ordered);
205205
out.writeOptionalString(analyzer);
206206
out.writeOptionalWriteable(filter);
207-
if (out.getVersion().onOrAfter(Version.V_7_2_0)) {
207+
if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_2_0)) {
208208
out.writeOptionalString(useField);
209209
}
210210
}

0 commit comments

Comments
 (0)