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
DocumentsWriterPerThread
).
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(Node, 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 |
(package 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
Used to record deletes against all prior (already written to disk) segments.
|
private InfoStream |
infoStream |
(package private) long |
maxSeqNo |
private java.util.concurrent.atomic.AtomicLong |
nextSeqNo
Generates the sequence number that IW returns to callers changing the index, showing the effective serialization of all operations.
|
private DocumentsWriterDeleteQueue.Node<?> |
tail |
Constructor and Description |
---|
DocumentsWriterDeleteQueue(InfoStream infoStream) |
DocumentsWriterDeleteQueue(InfoStream infoStream,
BufferedUpdates globalBufferedUpdates,
long generation,
long startSeqNo) |
DocumentsWriterDeleteQueue(InfoStream infoStream,
long generation,
long startSeqNo) |
Modifier and Type | Method and Description |
---|---|
(package private) long |
add(DocumentsWriterDeleteQueue.Node<?> newNode) |
(package private) long |
add(DocumentsWriterDeleteQueue.Node<?> deleteNode,
DocumentsWriterDeleteQueue.DeleteSlice slice)
invariant for document update
|
(package private) long |
addDelete(Query... queries) |
(package private) long |
addDelete(Term... terms) |
(package private) long |
addDocValuesUpdates(DocValuesUpdate... updates) |
(package private) boolean |
anyChanges() |
(package private) void |
clear() |
private boolean |
forceApplyGlobalSlice() |
(package private) FrozenBufferedUpdates |
freezeGlobalBuffer(DocumentsWriterDeleteQueue.DeleteSlice callerSlice) |
int |
getBufferedUpdatesTermsSize() |
long |
getLastSequenceNumber() |
long |
getNextSequenceNumber() |
(package private) static DocumentsWriterDeleteQueue.Node<DocValuesUpdate[]> |
newNode(DocValuesUpdate... updates) |
(package private) static DocumentsWriterDeleteQueue.Node<Term> |
newNode(Term term) |
(package private) DocumentsWriterDeleteQueue.DeleteSlice |
newSlice() |
int |
numGlobalTermDeletes() |
long |
ramBytesUsed()
Return the memory usage of this object in bytes.
|
void |
skipSequenceNumbers(long jump)
Inserts a gap in the sequence numbers.
|
java.lang.String |
toString() |
(package private) void |
tryApplyGlobalSlice() |
(package private) long |
updateSlice(DocumentsWriterDeleteQueue.DeleteSlice slice)
Negative result means there were new deletes since we last applied
|
(package private) boolean |
updateSliceNoSeqNo(DocumentsWriterDeleteQueue.DeleteSlice slice)
Just like updateSlice, but does not assign a sequence number
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getChildResources
private volatile DocumentsWriterDeleteQueue.Node<?> tail
private final DocumentsWriterDeleteQueue.DeleteSlice globalSlice
private final BufferedUpdates globalBufferedUpdates
final java.util.concurrent.locks.ReentrantLock globalBufferLock
final long generation
private final java.util.concurrent.atomic.AtomicLong nextSeqNo
private final InfoStream infoStream
long maxSeqNo
DocumentsWriterDeleteQueue(InfoStream infoStream)
DocumentsWriterDeleteQueue(InfoStream infoStream, long generation, long startSeqNo)
DocumentsWriterDeleteQueue(InfoStream infoStream, BufferedUpdates globalBufferedUpdates, long generation, long startSeqNo)
long addDelete(Query... queries)
long addDelete(Term... terms)
long addDocValuesUpdates(DocValuesUpdate... updates)
static DocumentsWriterDeleteQueue.Node<Term> newNode(Term term)
static DocumentsWriterDeleteQueue.Node<DocValuesUpdate[]> newNode(DocValuesUpdate... updates)
long add(DocumentsWriterDeleteQueue.Node<?> deleteNode, DocumentsWriterDeleteQueue.DeleteSlice slice)
long add(DocumentsWriterDeleteQueue.Node<?> newNode)
boolean anyChanges()
void tryApplyGlobalSlice()
FrozenBufferedUpdates freezeGlobalBuffer(DocumentsWriterDeleteQueue.DeleteSlice callerSlice) throws java.io.IOException
java.io.IOException
DocumentsWriterDeleteQueue.DeleteSlice newSlice()
long updateSlice(DocumentsWriterDeleteQueue.DeleteSlice slice)
boolean updateSliceNoSeqNo(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
public long getNextSequenceNumber()
public long getLastSequenceNumber()
public void skipSequenceNumbers(long jump)