From 7362c4ce603d81f276a83070e51bda52c3528bd7 Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Mon, 12 Oct 2020 09:15:07 +0200 Subject: [PATCH] LUCENE-6831: start removing LinkedList in favor of ArrayList or De/Queues (#1969) I'm committing it in, seems like a trivial thing. --- .gitignore | 3 +++ .../org/apache/lucene/index/DocumentsWriterFlushQueue.java | 4 ++-- .../core/src/java/org/apache/lucene/index/IndexWriter.java | 5 +++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index f120ec44aaa..31976196383 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,6 @@ build/ # Ignore the generated local settings file. gradle.properties + +# IntelliJ creates this folder, ignore. +dev-tools/missing-doclet/out/ diff --git a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushQueue.java b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushQueue.java index 132b496bcfc..b5d8d3de810 100644 --- a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushQueue.java +++ b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushQueue.java @@ -17,7 +17,7 @@ package org.apache.lucene.index; import java.io.IOException; -import java.util.LinkedList; +import java.util.ArrayDeque; import java.util.Queue; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.ReentrantLock; @@ -29,7 +29,7 @@ import org.apache.lucene.util.IOUtils; * @lucene.internal */ final class DocumentsWriterFlushQueue { - private final Queue queue = new LinkedList<>(); + private final Queue queue = new ArrayDeque<>(); // we track tickets separately since count must be present even before the ticket is // constructed ie. queue.size would not reflect it. private final AtomicInteger ticketCount = new AtomicInteger(); 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 7cc907af897..b1a53464aba 100644 --- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java +++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java @@ -18,14 +18,15 @@ package org.apache.lucene.index; import java.io.Closeable; import java.io.IOException; +import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Date; +import java.util.Deque; import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; @@ -399,7 +400,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable, private final HashSet mergingSegments = new HashSet<>(); private final MergeScheduler mergeScheduler; private final Set runningAddIndexesMerges = new HashSet<>(); - private final LinkedList pendingMerges = new LinkedList<>(); + private final Deque pendingMerges = new ArrayDeque<>(); private final Set runningMerges = new HashSet<>(); private final List mergeExceptions = new ArrayList<>(); private long mergeGen;