Package org.apache.lucene.index
Class DocumentsWriterPerThreadPool
- java.lang.Object
-
- org.apache.lucene.index.DocumentsWriterPerThreadPool
-
final class DocumentsWriterPerThreadPool extends java.lang.Object
DocumentsWriterPerThreadPool
controlsDocumentsWriterPerThreadPool.ThreadState
instances and their thread assignments during indexing. EachDocumentsWriterPerThreadPool.ThreadState
holds a reference to aDocumentsWriterPerThread
that is once aDocumentsWriterPerThreadPool.ThreadState
is obtained from the pool exclusively used for indexing a single document by the obtaining thread. Each indexing thread must obtain such aDocumentsWriterPerThreadPool.ThreadState
to make progress. Depending on theDocumentsWriterPerThreadPool
implementationDocumentsWriterPerThreadPool.ThreadState
assignments might differ from document to document.Once a
DocumentsWriterPerThread
is selected for flush the thread pool is reusing the flushingDocumentsWriterPerThread
s ThreadState with a newDocumentsWriterPerThread
instance.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
DocumentsWriterPerThreadPool.ThreadState
DocumentsWriterPerThreadPool.ThreadState
references and guards aDocumentsWriterPerThread
instance that is used during indexing to build a in-memory index segment.
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<DocumentsWriterPerThreadPool.ThreadState>
freeList
private int
takenThreadStatePermits
private java.util.List<DocumentsWriterPerThreadPool.ThreadState>
threadStates
-
Constructor Summary
Constructors Constructor Description DocumentsWriterPerThreadPool()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) int
getActiveThreadStateCount()
Returns the active number ofDocumentsWriterPerThreadPool.ThreadState
instances.(package private) DocumentsWriterPerThreadPool.ThreadState
getAndLock()
This method is used by DocumentsWriter/FlushControl to obtain a ThreadState to do an indexing operation (add/updateDocument).(package private) int
getMaxThreadStates()
(package private) DocumentsWriterPerThreadPool.ThreadState
getThreadState(int ord)
Returns the ith activeDocumentsWriterPerThreadPool.ThreadState
where i is the given ord.(package private) void
lockNewThreadStates()
private DocumentsWriterPerThreadPool.ThreadState
newThreadState()
Returns a newDocumentsWriterPerThreadPool.ThreadState
iff any new state is available otherwisenull
.(package private) void
recycle(DocumentsWriterPerThread dwpt)
(package private) void
release(DocumentsWriterPerThreadPool.ThreadState state)
(package private) DocumentsWriterPerThread
reset(DocumentsWriterPerThreadPool.ThreadState threadState)
(package private) void
unlockNewThreadStates()
-
-
-
Field Detail
-
threadStates
private final java.util.List<DocumentsWriterPerThreadPool.ThreadState> threadStates
-
freeList
private final java.util.List<DocumentsWriterPerThreadPool.ThreadState> freeList
-
takenThreadStatePermits
private int takenThreadStatePermits
-
-
Method Detail
-
getActiveThreadStateCount
int getActiveThreadStateCount()
Returns the active number ofDocumentsWriterPerThreadPool.ThreadState
instances.
-
lockNewThreadStates
void lockNewThreadStates()
-
unlockNewThreadStates
void unlockNewThreadStates()
-
newThreadState
private DocumentsWriterPerThreadPool.ThreadState newThreadState()
Returns a newDocumentsWriterPerThreadPool.ThreadState
iff any new state is available otherwisenull
.NOTE: the returned
DocumentsWriterPerThreadPool.ThreadState
is already locked iff non-null
.- Returns:
- a new
DocumentsWriterPerThreadPool.ThreadState
iff any new state is available otherwisenull
-
reset
DocumentsWriterPerThread reset(DocumentsWriterPerThreadPool.ThreadState threadState)
-
recycle
void recycle(DocumentsWriterPerThread dwpt)
-
getAndLock
DocumentsWriterPerThreadPool.ThreadState getAndLock()
This method is used by DocumentsWriter/FlushControl to obtain a ThreadState to do an indexing operation (add/updateDocument).
-
release
void release(DocumentsWriterPerThreadPool.ThreadState state)
-
getThreadState
DocumentsWriterPerThreadPool.ThreadState getThreadState(int ord)
Returns the ith activeDocumentsWriterPerThreadPool.ThreadState
where i is the given ord.- Parameters:
ord
- the ordinal of theDocumentsWriterPerThreadPool.ThreadState
- Returns:
- the ith active
DocumentsWriterPerThreadPool.ThreadState
where i is the given ord.
-
getMaxThreadStates
int getMaxThreadStates()
-
-