From a4b4c75dcfdce362eeca1117be88ca803282a820 Mon Sep 17 00:00:00 2001 From: Christine Poerschke Date: Wed, 11 Nov 2015 17:52:00 +0000 Subject: [PATCH] LUCENE-6892: various lucene.index initialCapacity tweaks git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1713903 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/CHANGES.txt | 3 +++ lucene/core/src/java/org/apache/lucene/index/CodecReader.java | 2 +- lucene/core/src/java/org/apache/lucene/index/IndexWriter.java | 4 ++-- .../core/src/java/org/apache/lucene/index/LogMergePolicy.java | 4 ++-- lucene/core/src/java/org/apache/lucene/index/MultiFields.java | 4 ++-- .../org/apache/lucene/index/SegmentDocValuesProducer.java | 2 +- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 299cbb21a58..304480681ba 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -203,6 +203,9 @@ Optimizations * LUCENE-6863: Optimized storage requirements of doc values fields when less than 1% of documents have a value. (Adrien Grand) +* LUCENE-6892: various lucene.index initialCapacity tweaks + (Christine Poerschke) + Bug Fixes * LUCENE-6817: ComplexPhraseQueryParser.ComplexPhraseQuery does not display diff --git a/lucene/core/src/java/org/apache/lucene/index/CodecReader.java b/lucene/core/src/java/org/apache/lucene/index/CodecReader.java index aad92e24fa6..c879b9ed2bf 100644 --- a/lucene/core/src/java/org/apache/lucene/index/CodecReader.java +++ b/lucene/core/src/java/org/apache/lucene/index/CodecReader.java @@ -333,7 +333,7 @@ public abstract class CodecReader extends LeafReader implements Accountable { @Override public Collection getChildResources() { ensureOpen(); - List resources = new ArrayList<>(); + final List resources = new ArrayList<>(6); // terms/postings resources.add(Accountables.namedAccountable("postings", getPostingsReader())); diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java index 523ac1821f3..22a2ffaebc3 100644 --- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java +++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java @@ -2390,7 +2390,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable { * to match with a call to {@link IOUtils#close} in a * finally clause. */ private List acquireWriteLocks(Directory... dirs) throws IOException { - List locks = new ArrayList<>(); + List locks = new ArrayList<>(dirs.length); for(int i=0;i(); + merge.readers = new ArrayList<>(sourceSegments.size()); // This is try/finally to make sure merger's readers are // closed: diff --git a/lucene/core/src/java/org/apache/lucene/index/LogMergePolicy.java b/lucene/core/src/java/org/apache/lucene/index/LogMergePolicy.java index 5102e2bb66d..a8d4ed7177e 100644 --- a/lucene/core/src/java/org/apache/lucene/index/LogMergePolicy.java +++ b/lucene/core/src/java/org/apache/lucene/index/LogMergePolicy.java @@ -461,7 +461,7 @@ public abstract class LogMergePolicy extends MergePolicy { // Compute levels, which is just log (base mergeFactor) // of the size of each segment - final List levels = new ArrayList<>(); + final List levels = new ArrayList<>(numSegments); final float norm = (float) Math.log(mergeFactor); final Collection mergingSegments = writer.getMergingSegments(); @@ -563,7 +563,7 @@ public abstract class LogMergePolicy extends MergePolicy { } else if (!anyTooLarge) { if (spec == null) spec = new MergeSpecification(); - final List mergeInfos = new ArrayList<>(); + final List mergeInfos = new ArrayList<>(end-start); for(int i=start;i fields = new ArrayList<>(); - final List slices = new ArrayList<>(); + final List fields = new ArrayList<>(leaves.size()); + final List slices = new ArrayList<>(leaves.size()); for (final LeafReaderContext ctx : leaves) { final LeafReader r = ctx.reader(); final Fields f = r.fields(); diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentDocValuesProducer.java b/lucene/core/src/java/org/apache/lucene/index/SegmentDocValuesProducer.java index 70d3e1a6903..ee0f4eae023 100644 --- a/lucene/core/src/java/org/apache/lucene/index/SegmentDocValuesProducer.java +++ b/lucene/core/src/java/org/apache/lucene/index/SegmentDocValuesProducer.java @@ -161,7 +161,7 @@ class SegmentDocValuesProducer extends DocValuesProducer { @Override public Collection getChildResources() { - List resources = new ArrayList<>(); + final List resources = new ArrayList<>(dvProducers.size()); for (Accountable producer : dvProducers) { resources.add(Accountables.namedAccountable("delegate", producer)); }