Package org.apache.lucene.index
Class DocumentsWriterPerThreadPool
java.lang.Object
org.apache.lucene.index.DocumentsWriterPerThreadPool
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<DocumentsWriterPerThread>
final class DocumentsWriterPerThreadPool
extends Object
implements Iterable<DocumentsWriterPerThread>, Closeable
DocumentsWriterPerThreadPool
controls DocumentsWriterPerThread
instances and
their thread assignments during indexing. Each DocumentsWriterPerThread
is once a
obtained from the pool exclusively used for indexing a single document or list of documents by
the obtaining thread. Each indexing thread must obtain such a DocumentsWriterPerThread
to
make progress. Depending on the DocumentsWriterPerThreadPool
implementation DocumentsWriterPerThread
assignments might differ from document to document.
Once a DocumentsWriterPerThread
is selected for flush the DocumentsWriterPerThread
will be checked out of the thread pool and won't be reused for
indexing. See checkout(DocumentsWriterPerThread)
.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private final Supplier<DocumentsWriterPerThread>
private final Set<DocumentsWriterPerThread>
private final ApproximatePriorityQueue<DocumentsWriterPerThread>
private int
-
Constructor Summary
ConstructorsConstructorDescriptionDocumentsWriterPerThreadPool
(Supplier<DocumentsWriterPerThread> dwptFactory) -
Method Summary
Modifier and TypeMethodDescription(package private) boolean
checkout
(DocumentsWriterPerThread perThread) Removes the given DWPT from the pool unless it's already been removed before.void
close()
private void
(package private) List<DocumentsWriterPerThread>
filterAndLock
(Predicate<DocumentsWriterPerThread> predicate) Filters all DWPTs the given predicate applies to and that can be checked out of the pool viacheckout(DocumentsWriterPerThread)
.(package private) DocumentsWriterPerThread
This method is used by DocumentsWriter/FlushControl to obtain a DWPT to do an indexing operation (add/updateDocument).(package private) boolean
isRegistered
(DocumentsWriterPerThread perThread) Returnstrue
if this DWPT is still part of the pooliterator()
(package private) void
(package private) void
private DocumentsWriterPerThread
Returns a new already lockedDocumentsWriterPerThread
(package private) int
size()
Returns the active number ofDocumentsWriterPerThread
instances.(package private) void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
dwpts
-
freeList
-
dwptFactory
-
takenWriterPermits
private int takenWriterPermits -
closed
private boolean closed
-
-
Constructor Details
-
DocumentsWriterPerThreadPool
DocumentsWriterPerThreadPool(Supplier<DocumentsWriterPerThread> dwptFactory)
-
-
Method Details
-
size
int size()Returns the active number ofDocumentsWriterPerThread
instances. -
lockNewWriters
void lockNewWriters() -
unlockNewWriters
void unlockNewWriters() -
newWriter
Returns a new already lockedDocumentsWriterPerThread
- Returns:
- a new
DocumentsWriterPerThread
-
getAndLock
DocumentsWriterPerThread getAndLock()This method is used by DocumentsWriter/FlushControl to obtain a DWPT to do an indexing operation (add/updateDocument). -
ensureOpen
private void ensureOpen() -
marksAsFreeAndUnlock
-
iterator
- Specified by:
iterator
in interfaceIterable<DocumentsWriterPerThread>
-
filterAndLock
Filters all DWPTs the given predicate applies to and that can be checked out of the pool viacheckout(DocumentsWriterPerThread)
. All DWPTs returned from this method are already locked andisRegistered(DocumentsWriterPerThread)
will returntrue
for all returned DWPTs -
checkout
Removes the given DWPT from the pool unless it's already been removed before.- Returns:
true
iff the given DWPT has been removed. Otherwisefalse
-
isRegistered
Returnstrue
if this DWPT is still part of the pool -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-