Skip to content

Commit 1c11b94

Browse files
authored
Serialize ReplicationRequest reshard shardcount summary as VInt instead of Int (#135648)
This should always save at least 2 bytes of 4, and almost always 3.
1 parent 62b1c80 commit 1c11b94

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

server/src/main/java/org/elasticsearch/action/support/replication/ReplicationRequest.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ public abstract class ReplicationRequest<Request extends ReplicationRequest<Requ
3838
implements
3939
IndicesRequest {
4040

41+
// superseded
4142
private static final TransportVersion INDEX_RESHARD_SHARDCOUNT_SUMMARY = TransportVersion.fromName("index_reshard_shardcount_summary");
43+
// bumped to use VInt instead of Int
44+
private static final TransportVersion INDEX_RESHARD_SHARDCOUNT_SMALL = TransportVersion.fromName("index_reshard_shardcount_small");
4245

4346
public static final TimeValue DEFAULT_TIMEOUT = TimeValue.timeValueMinutes(1);
4447

@@ -126,14 +129,16 @@ public ReplicationRequest(@Nullable ShardId shardId, int reshardSplitShardCountS
126129
index = in.readString();
127130
}
128131
routedBasedOnClusterVersion = in.readVLong();
129-
if (in.getTransportVersion().supports(INDEX_RESHARD_SHARDCOUNT_SUMMARY)) {
130-
if (thinRead) {
131-
this.reshardSplitShardCountSummary = reshardSplitShardCountSummary;
132-
} else {
132+
if (thinRead) {
133+
this.reshardSplitShardCountSummary = reshardSplitShardCountSummary;
134+
} else {
135+
if (in.getTransportVersion().supports(INDEX_RESHARD_SHARDCOUNT_SMALL)) {
136+
this.reshardSplitShardCountSummary = in.readVInt();
137+
} else if (in.getTransportVersion().supports(INDEX_RESHARD_SHARDCOUNT_SUMMARY)) {
133138
this.reshardSplitShardCountSummary = in.readInt();
139+
} else {
140+
this.reshardSplitShardCountSummary = 0;
134141
}
135-
} else {
136-
this.reshardSplitShardCountSummary = 0;
137142
}
138143
}
139144

@@ -262,7 +267,9 @@ public void writeTo(StreamOutput out) throws IOException {
262267
out.writeTimeValue(timeout);
263268
out.writeString(index);
264269
out.writeVLong(routedBasedOnClusterVersion);
265-
if (out.getTransportVersion().supports(INDEX_RESHARD_SHARDCOUNT_SUMMARY)) {
270+
if (out.getTransportVersion().supports(INDEX_RESHARD_SHARDCOUNT_SMALL)) {
271+
out.writeVInt(reshardSplitShardCountSummary);
272+
} else if (out.getTransportVersion().supports(INDEX_RESHARD_SHARDCOUNT_SUMMARY)) {
266273
out.writeInt(reshardSplitShardCountSummary);
267274
}
268275
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9181000
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
elastic_reranker_chunking_configuration,9180000
1+
index_reshard_shardcount_small,9181000

0 commit comments

Comments
 (0)