From 9899cbd031dc3fc37a384b1f9e2b379e90a9a3a6 Mon Sep 17 00:00:00 2001 From: Noble Paul Date: Wed, 25 Jan 2017 07:08:25 +1030 Subject: [PATCH] SOLR-10026: JavaBinCodec should initialize maps and namedLists with known capacity --- .../java/org/apache/solr/common/util/JavaBinCodec.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java b/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java index 3e054d7cce9..7e0cac67660 100644 --- a/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java +++ b/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java @@ -189,7 +189,7 @@ public class JavaBinCodec implements PushWriter { public SimpleOrderedMap readOrderedMap(DataInputInputStream dis) throws IOException { int sz = readSize(dis); - SimpleOrderedMap nl = new SimpleOrderedMap<>(); + SimpleOrderedMap nl = new SimpleOrderedMap<>(sz); for (int i = 0; i < sz; i++) { String name = (String) readVal(dis); Object val = readVal(dis); @@ -200,7 +200,7 @@ public class JavaBinCodec implements PushWriter { public NamedList readNamedList(DataInputInputStream dis) throws IOException { int sz = readSize(dis); - NamedList nl = new NamedList<>(); + NamedList nl = new NamedList<>(sz); for (int i = 0; i < sz; i++) { String name = (String) readVal(dis); Object val = readVal(dis); @@ -512,7 +512,7 @@ public class JavaBinCodec implements PushWriter { public SolrDocument readSolrDocument(DataInputInputStream dis) throws IOException { tagByte = dis.readByte(); int size = readSize(dis); - SolrDocument doc = new SolrDocument(); + SolrDocument doc = new SolrDocument(new LinkedHashMap<>(size)); for (int i = 0; i < size; i++) { String fieldName; Object obj = readVal(dis); // could be a field name, or a child document @@ -555,7 +555,7 @@ public class JavaBinCodec implements PushWriter { public SolrInputDocument readSolrInputDocument(DataInputInputStream dis) throws IOException { int sz = readVInt(dis); float docBoost = (Float)readVal(dis); - SolrInputDocument sdoc = new SolrInputDocument(); + SolrInputDocument sdoc = new SolrInputDocument(new LinkedHashMap<>(sz)); sdoc.setDocumentBoost(docBoost); for (int i = 0; i < sz; i++) { float boost = 1.0f; @@ -610,7 +610,7 @@ public class JavaBinCodec implements PushWriter { public Map readMap(DataInputInputStream dis) throws IOException { int sz = readVInt(dis); - Map m = new LinkedHashMap<>(); + Map m = new LinkedHashMap<>(sz); for (int i = 0; i < sz; i++) { Object key = readVal(dis); Object val = readVal(dis);