internal virtual void AddDeletes(DocumentsWriterDeleteQueue deleteQueue) { UninterruptableMonitor.Enter(this); try { IncTickets(); // first inc the ticket count - freeze opens // a window for #anyChanges to fail bool success = false; try { queue.Enqueue(new GlobalDeletesTicket(deleteQueue.FreezeGlobalBuffer(null))); success = true; } finally { if (!success) { DecTickets(); } } } finally { UninterruptableMonitor.Exit(this); } }
/// <summary> /// Prepares this DWPT for flushing. this method will freeze and return the /// <see cref="DocumentsWriterDeleteQueue"/>s global buffer and apply all pending /// deletes to this DWPT. /// </summary> internal virtual FrozenBufferedUpdates PrepareFlush() { Debug.Assert(numDocsInRAM > 0); FrozenBufferedUpdates globalUpdates = deleteQueue.FreezeGlobalBuffer(deleteSlice); /* deleteSlice can possibly be null if we have hit non-aborting exceptions during indexing and never succeeded * adding a document. */ if (deleteSlice != null) { // apply all deletes before we flush and release the delete slice deleteSlice.Apply(pendingUpdates, numDocsInRAM); Debug.Assert(deleteSlice.IsEmpty); deleteSlice.Reset(); } return(globalUpdates); }