Skip to content

Commit 795e07c

Browse files
Dry up some spots around map reading from StreamInput (#96853)
Mostly the keys we read are strings, lets add an overload for that to save some code and maybe help the compiler make better decisions. Also readMapOfLists an be way simplified, no point in duplicating the map reading code here just to save one capturing lambda, there's not hot code that benefits from this.
1 parent 01731ae commit 795e07c

File tree

125 files changed

+167
-186
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+167
-186
lines changed

modules/aggregations/src/main/java/org/elasticsearch/aggregations/pipeline/BucketSelectorPipelineAggregationBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public BucketSelectorPipelineAggregationBuilder(String name, Map<String, String>
4848
*/
4949
public BucketSelectorPipelineAggregationBuilder(StreamInput in) throws IOException {
5050
super(in, NAME);
51-
bucketsPathsMap = in.readMap(StreamInput::readString, StreamInput::readString);
51+
bucketsPathsMap = in.readMap(StreamInput::readString);
5252
script = new Script(in);
5353
gapPolicy = GapPolicy.readFrom(in);
5454
}

modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/GrokProcessorGetAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public static class Response extends ActionResponse implements ToXContentObject
9898

9999
Response(StreamInput in) throws IOException {
100100
super(in);
101-
grokPatterns = in.readMap(StreamInput::readString, StreamInput::readString);
101+
grokPatterns = in.readMap(StreamInput::readString);
102102
}
103103

104104
public Map<String, String> getGrokPatterns() {

modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/GeoIpTaskState.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ public static GeoIpTaskState fromXContent(XContentParser parser) throws IOExcept
6767
}
6868

6969
GeoIpTaskState(StreamInput input) throws IOException {
70-
databases = input.readImmutableMap(StreamInput::readString, in -> {
71-
long lastUpdate = in.readLong();
72-
return new Metadata(lastUpdate, in.readVInt(), in.readVInt(), in.readString(), in.readLong());
73-
});
70+
databases = input.readImmutableMap(in -> new Metadata(in.readLong(), in.readVInt(), in.readVInt(), in.readString(), in.readLong()));
7471
}
7572

7673
public GeoIpTaskState put(String name, Metadata metadata) {

server/src/main/java/org/elasticsearch/ElasticsearchException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ public ElasticsearchException(String msg, Throwable cause, Object... args) {
145145
public ElasticsearchException(StreamInput in) throws IOException {
146146
super(in.readOptionalString(), in.readException());
147147
readStackTrace(this, in);
148-
headers.putAll(in.readMapOfLists(StreamInput::readString, StreamInput::readString));
149-
metadata.putAll(in.readMapOfLists(StreamInput::readString, StreamInput::readString));
148+
headers.putAll(in.readMapOfLists(StreamInput::readString));
149+
metadata.putAll(in.readMapOfLists(StreamInput::readString));
150150
}
151151

152152
/**

server/src/main/java/org/elasticsearch/action/admin/cluster/allocation/DesiredBalanceResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static DesiredBalanceResponse from(StreamInput in) throws IOException {
6161
in.getTransportVersion().onOrAfter(CLUSTER_BALANCE_STATS_VERSION)
6262
? ClusterBalanceStats.readFrom(in)
6363
: ClusterBalanceStats.EMPTY,
64-
in.readImmutableMap(StreamInput::readString, v -> v.readImmutableMap(StreamInput::readVInt, DesiredShards::from)),
64+
in.readImmutableMap(v -> v.readImmutableMap(StreamInput::readVInt, DesiredShards::from)),
6565
in.getTransportVersion().onOrAfter(CLUSTER_INFO_VERSION) ? new ClusterInfo(in) : ClusterInfo.EMPTY
6666
);
6767
}

server/src/main/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public ClusterSearchShardsResponse(StreamInput in) throws IOException {
3030
super(in);
3131
groups = in.readArray(ClusterSearchShardsGroup::new, ClusterSearchShardsGroup[]::new);
3232
nodes = in.readArray(DiscoveryNode::new, DiscoveryNode[]::new);
33-
indicesAndFilters = in.readMap(StreamInput::readString, AliasFilter::readFrom);
33+
indicesAndFilters = in.readMap(AliasFilter::readFrom);
3434
}
3535

3636
@Override

server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/GetSnapshotsResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public GetSnapshotsResponse(
9494
public GetSnapshotsResponse(StreamInput in) throws IOException {
9595
this.snapshots = in.readImmutableList(SnapshotInfo::readFrom);
9696
if (in.getTransportVersion().onOrAfter(GetSnapshotsRequest.MULTIPLE_REPOSITORIES_SUPPORT_ADDED)) {
97-
final Map<String, ElasticsearchException> failedResponses = in.readMap(StreamInput::readString, StreamInput::readException);
97+
final Map<String, ElasticsearchException> failedResponses = in.readMap(StreamInput::readException);
9898
this.failures = Collections.unmodifiableMap(failedResponses);
9999
this.next = in.readOptionalString();
100100
} else {

server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/get/shard/GetShardSnapshotResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class GetShardSnapshotResponse extends ActionResponse {
3434
GetShardSnapshotResponse(StreamInput in) throws IOException {
3535
super(in);
3636
this.latestShardSnapshot = in.readOptionalWriteable(ShardSnapshotInfo::new);
37-
this.repositoryFailures = in.readMap(StreamInput::readString, RepositoryException::new);
37+
this.repositoryFailures = in.readMap(RepositoryException::new);
3838
}
3939

4040
@Override

server/src/main/java/org/elasticsearch/action/admin/cluster/stats/SearchUsageStats.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ public SearchUsageStats(Map<String, Long> queries, Map<String, Long> sections, l
5151
}
5252

5353
public SearchUsageStats(StreamInput in) throws IOException {
54-
this.queries = in.readMap(StreamInput::readString, StreamInput::readLong);
55-
this.sections = in.readMap(StreamInput::readString, StreamInput::readLong);
54+
this.queries = in.readMap(StreamInput::readLong);
55+
this.sections = in.readMap(StreamInput::readLong);
5656
this.totalSearchCount = in.readVLong();
5757
}
5858

server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public GetAliasesResponse(Map<String, List<AliasMetadata>> aliases, Map<String,
3232
public GetAliasesResponse(StreamInput in) throws IOException {
3333
super(in);
3434
aliases = in.readImmutableOpenMap(StreamInput::readString, i -> i.readList(AliasMetadata::new));
35-
dataStreamAliases = in.readMap(StreamInput::readString, in1 -> in1.readList(DataStreamAlias::new));
35+
dataStreamAliases = in.readMap(in1 -> in1.readList(DataStreamAlias::new));
3636
}
3737

3838
public Map<String, List<AliasMetadata>> getAliases() {

0 commit comments

Comments
 (0)