public override void OnInsert(DocumentsWriterFlushControl control, ThreadState state) { if (FlushOnDocCount && state.dwpt.NumDocsInRAM >= m_indexWriterConfig.MaxBufferedDocs) { // Flush this state by num docs control.SetFlushPending(state); } // flush by RAM else if (FlushOnRAM) { long limit = (long)(m_indexWriterConfig.RAMBufferSizeMB * 1024d * 1024d); long totalRam = control.ActiveBytes + control.DeleteBytesUsed; if (totalRam >= limit) { if (m_infoStream.IsEnabled("FP")) { m_infoStream.Message("FP", "flush: activeBytes=" + control.ActiveBytes + " deleteBytes=" + control.DeleteBytesUsed + " vs limit=" + limit); } MarkLargestWriterPending(control, state, totalRam); } } }
/// <summary> /// Marks the most ram consuming active <see cref="DocumentsWriterPerThread"/> flush /// pending /// </summary> protected virtual void MarkLargestWriterPending(DocumentsWriterFlushControl control, ThreadState perThreadState, long currentBytesPerThread) { control.SetFlushPending(FindLargestNonPendingWriter(control, perThreadState)); }