Apache Lucene open-source search software
SOLR-8555: SearchGroupShardResponseProcessor (initialCapacity) tweaks
Christine Poerschked804cc620d06
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 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 tocreate a core with the same name (Varun Thacker)+* SOLR-8555: SearchGroupShardResponseProcessor (initialCapacity) tweaks (Christine Poerschke)+================== 5.4.1 ==================Bug Fixesdiff --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.javaindex 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 ShardResponseProcessorpublic 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 placesortWithinGroup = Sort.RELEVANCE;}- Map<String, List<Collection<SearchGroup<BytesRef>>>> commandSearchGroups = new HashMap<>();- Map<String, Map<SearchGroup<BytesRef>, Set<String>>> tempSearchGroupToShards = new HashMap<>();+ final Map<String, List<Collection<SearchGroup<BytesRef>>>> commandSearchGroups = new HashMap<>(fields.length, 1.0f);+ final Map<String, Map<SearchGroup<BytesRef>, Set<String>>> tempSearchGroupToShards = new HashMap<>(fields.length, 1.0f);for (String field : fields) {commandSearchGroups.put(field, new ArrayList<Collection<SearchGroup<BytesRef>>>(shardRequest.responses.size()));tempSearchGroupToShards.put(field, new HashMap<SearchGroup<BytesRef>, Set<String>>());@@ -74,13 +74,13 @@ public class SearchGroupShardResponseProcessor implements ShardResponseProcessorNamedList<Object> 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<Object> nl = new SimpleOrderedMap<>();+ SimpleOrderedMap<Object> nl = new SimpleOrderedMap<>(4);if (srsp.getException() != null) {Throwable t = srsp.getException();