LUCENE-6831: start removing LinkedList in favor of ArrayList or De/Queues (#1969)

I'm committing it in, seems like a trivial thing.
This commit is contained in:
Dawid Weiss 2020-10-12 09:15:07 +02:00 committed by GitHub
parent ab83b3b7c3
commit 7362c4ce60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

3
.gitignore vendored
View File

@ -37,3 +37,6 @@ build/
# Ignore the generated local settings file. # Ignore the generated local settings file.
gradle.properties gradle.properties
# IntelliJ creates this folder, ignore.
dev-tools/missing-doclet/out/

View File

@ -17,7 +17,7 @@
package org.apache.lucene.index; package org.apache.lucene.index;
import java.io.IOException; import java.io.IOException;
import java.util.LinkedList; import java.util.ArrayDeque;
import java.util.Queue; import java.util.Queue;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
@ -29,7 +29,7 @@ import org.apache.lucene.util.IOUtils;
* @lucene.internal * @lucene.internal
*/ */
final class DocumentsWriterFlushQueue { final class DocumentsWriterFlushQueue {
private final Queue<FlushTicket> queue = new LinkedList<>(); private final Queue<FlushTicket> queue = new ArrayDeque<>();
// we track tickets separately since count must be present even before the ticket is // we track tickets separately since count must be present even before the ticket is
// constructed ie. queue.size would not reflect it. // constructed ie. queue.size would not reflect it.
private final AtomicInteger ticketCount = new AtomicInteger(); private final AtomicInteger ticketCount = new AtomicInteger();

View File

@ -18,14 +18,15 @@ package org.apache.lucene.index;
import java.io.Closeable; import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.Deque;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
@ -399,7 +400,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable,
private final HashSet<SegmentCommitInfo> mergingSegments = new HashSet<>(); private final HashSet<SegmentCommitInfo> mergingSegments = new HashSet<>();
private final MergeScheduler mergeScheduler; private final MergeScheduler mergeScheduler;
private final Set<SegmentMerger> runningAddIndexesMerges = new HashSet<>(); private final Set<SegmentMerger> runningAddIndexesMerges = new HashSet<>();
private final LinkedList<MergePolicy.OneMerge> pendingMerges = new LinkedList<>(); private final Deque<MergePolicy.OneMerge> pendingMerges = new ArrayDeque<>();
private final Set<MergePolicy.OneMerge> runningMerges = new HashSet<>(); private final Set<MergePolicy.OneMerge> runningMerges = new HashSet<>();
private final List<MergePolicy.OneMerge> mergeExceptions = new ArrayList<>(); private final List<MergePolicy.OneMerge> mergeExceptions = new ArrayList<>();
private long mergeGen; private long mergeGen;