final class DocumentsWriterDeleteQueue extends java.lang.Object implements Accountable
DocumentsWriterDeleteQueue
is a non-blocking linked pending deletes
queue. In contrast to other queue implementation we only maintain the
tail of the queue. A delete queue is always used in a context of a set of
DWPTs and a global delete pool. Each of the DWPT and the global pool need to
maintain their 'own' head of the queue (as a DeleteSlice instance per DWPT).
The difference between the DWPT and the global pool is that the DWPT starts
maintaining a head once it has added its first document since for its segments
private deletes only the deletes after that document are relevant. The global
pool instead starts maintaining the head once this instance is created by
taking the sentinel instance as its initial head.
Since each DocumentsWriterDeleteQueue.DeleteSlice
maintains its own head and the list is only
single linked the garbage collector takes care of pruning the list for us.
All nodes in the list that are still relevant should be either directly or
indirectly referenced by one of the DWPT's private DocumentsWriterDeleteQueue.DeleteSlice
or by
the global BufferedUpdates
slice.
Each DWPT as well as the global delete pool maintain their private DeleteSlice instance. In the DWPT case updating a slice is equivalent to atomically finishing the document. The slice update guarantees a "happens before" relationship to all other updates in the same indexing session. When a DWPT updates a document it:
DocumentsWriterDeleteQueue.DeleteSlice
either by calling
updateSlice(DeleteSlice)
or add(Term, DeleteSlice)
(if the
document has a delTerm)BufferedUpdates
and resets itModifier and Type | Class and Description |
---|---|
(package private) static class |
DocumentsWriterDeleteQueue.DeleteSlice |
private static class |
DocumentsWriterDeleteQueue.DocValuesUpdatesNode |
private static class |
DocumentsWriterDeleteQueue.Node<T> |
private static class |
DocumentsWriterDeleteQueue.QueryArrayNode |
private static class |
DocumentsWriterDeleteQueue.TermArrayNode |
private static class |
DocumentsWriterDeleteQueue.TermNode |
Modifier and Type | Field and Description |
---|---|
(package private) long |
generation |
private BufferedUpdates |
globalBufferedUpdates |
(package private) java.util.concurrent.locks.ReentrantLock |
globalBufferLock |
private DocumentsWriterDeleteQueue.DeleteSlice |
globalSlice |
private DocumentsWriterDeleteQueue.Node<?> |
tail |
private static java.util.concurrent.atomic.AtomicReferenceFieldUpdater<DocumentsWriterDeleteQueue,DocumentsWriterDeleteQueue.Node> |
tailUpdater |
Constructor and Description |
---|
DocumentsWriterDeleteQueue() |
DocumentsWriterDeleteQueue(BufferedUpdates globalBufferedUpdates,
long generation) |
DocumentsWriterDeleteQueue(long generation) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
add(DocumentsWriterDeleteQueue.Node<?> item) |
(package private) void |
add(Term term,
DocumentsWriterDeleteQueue.DeleteSlice slice)
invariant for document update
|
(package private) void |
addDelete(Query... queries) |
(package private) void |
addDelete(Term... terms) |
(package private) void |
addDocValuesUpdates(DocValuesUpdate... updates) |
(package private) boolean |
anyChanges() |
(package private) void |
clear() |
private boolean |
forceApplyGlobalSlice() |
(package private) FrozenBufferedUpdates |
freezeGlobalBuffer(DocumentsWriterDeleteQueue.DeleteSlice callerSlice) |
int |
getBufferedUpdatesTermsSize() |
(package private) DocumentsWriterDeleteQueue.DeleteSlice |
newSlice() |
int |
numGlobalTermDeletes() |
long |
ramBytesUsed()
Return the memory usage of this object in bytes.
|
java.lang.String |
toString() |
(package private) void |
tryApplyGlobalSlice() |
(package private) boolean |
updateSlice(DocumentsWriterDeleteQueue.DeleteSlice slice) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getChildResources
private volatile DocumentsWriterDeleteQueue.Node<?> tail
private static final java.util.concurrent.atomic.AtomicReferenceFieldUpdater<DocumentsWriterDeleteQueue,DocumentsWriterDeleteQueue.Node> tailUpdater
private final DocumentsWriterDeleteQueue.DeleteSlice globalSlice
private final BufferedUpdates globalBufferedUpdates
final java.util.concurrent.locks.ReentrantLock globalBufferLock
final long generation
DocumentsWriterDeleteQueue()
DocumentsWriterDeleteQueue(long generation)
DocumentsWriterDeleteQueue(BufferedUpdates globalBufferedUpdates, long generation)
void addDelete(Query... queries)
void addDelete(Term... terms)
void addDocValuesUpdates(DocValuesUpdate... updates)
void add(Term term, DocumentsWriterDeleteQueue.DeleteSlice slice)
void add(DocumentsWriterDeleteQueue.Node<?> item)
boolean anyChanges()
void tryApplyGlobalSlice()
FrozenBufferedUpdates freezeGlobalBuffer(DocumentsWriterDeleteQueue.DeleteSlice callerSlice)
DocumentsWriterDeleteQueue.DeleteSlice newSlice()
boolean updateSlice(DocumentsWriterDeleteQueue.DeleteSlice slice)
public int numGlobalTermDeletes()
void clear()
private boolean forceApplyGlobalSlice()
public int getBufferedUpdatesTermsSize()
public long ramBytesUsed()
Accountable
ramBytesUsed
in interface Accountable
public java.lang.String toString()
toString
in class java.lang.Object