diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 333213d51dd..b27707531f6 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -527,6 +527,8 @@ Other Changes * SOLR-8549: Solr start script checks for cores which have failed to load as well before attempting to create a core with the same name (Varun Thacker) +* SOLR-8555: SearchGroupShardResponseProcessor (initialCapacity) tweaks (Christine Poerschke) + ================== 5.4.1 ================== Bug Fixes diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.java b/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.java index ce83a00db71..07e854c3ebc 100644 --- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.java +++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.java @@ -51,14 +51,14 @@ public class SearchGroupShardResponseProcessor implements ShardResponseProcessor public void process(ResponseBuilder rb, ShardRequest shardRequest) { SortSpec ss = rb.getSortSpec(); Sort groupSort = rb.getGroupingSpec().getGroupSort(); - String[] fields = rb.getGroupingSpec().getFields(); + final String[] fields = rb.getGroupingSpec().getFields(); Sort sortWithinGroup = rb.getGroupingSpec().getSortWithinGroup(); if (sortWithinGroup == null) { // TODO prevent it from being null in the first place sortWithinGroup = Sort.RELEVANCE; } - Map>>> commandSearchGroups = new HashMap<>(); - Map, Set>> tempSearchGroupToShards = new HashMap<>(); + final Map>>> commandSearchGroups = new HashMap<>(fields.length, 1.0f); + final Map, Set>> tempSearchGroupToShards = new HashMap<>(fields.length, 1.0f); for (String field : fields) { commandSearchGroups.put(field, new ArrayList>>(shardRequest.responses.size())); tempSearchGroupToShards.put(field, new HashMap, Set>()); @@ -74,13 +74,13 @@ public class SearchGroupShardResponseProcessor implements ShardResponseProcessor NamedList shardInfo = null; if (rb.req.getParams().getBool(ShardParams.SHARDS_INFO, false)) { - shardInfo = new SimpleOrderedMap<>(); + shardInfo = new SimpleOrderedMap<>(shardRequest.responses.size()); rb.rsp.getValues().add(ShardParams.SHARDS_INFO + ".firstPhase", shardInfo); } for (ShardResponse srsp : shardRequest.responses) { if (shardInfo != null) { - SimpleOrderedMap nl = new SimpleOrderedMap<>(); + SimpleOrderedMap nl = new SimpleOrderedMap<>(4); if (srsp.getException() != null) { Throwable t = srsp.getException();