protected internal void FinishFlush(IndexWriter indexWriter, FlushedSegment newSegment, FrozenBufferedUpdates bufferedUpdates)
 {
     // Finish the flushed segment and publish it to IndexWriter
     if (newSegment == null)
     {
         Debug.Assert(bufferedUpdates != null);
         if (bufferedUpdates != null && bufferedUpdates.Any())
         {
             indexWriter.PublishFrozenUpdates(bufferedUpdates);
             if (indexWriter.infoStream.IsEnabled("DW"))
             {
                 indexWriter.infoStream.Message("DW", "flush: push buffered updates: " + bufferedUpdates);
             }
         }
     }
     else
     {
         PublishFlushedSegment(indexWriter, newSegment, bufferedUpdates);
     }
 }
            /// <summary>
            /// Publishes the flushed segment, segment private deletes (if any) and its
            /// associated global delete (if present) to IndexWriter.  The actual
            /// publishing operation is synced on IW -> BDS so that the <seealso cref="SegmentInfo"/>'s
            /// delete generation is always GlobalPacket_deleteGeneration + 1
            /// </summary>
            protected internal void PublishFlushedSegment(IndexWriter indexWriter, FlushedSegment newSegment, FrozenBufferedUpdates globalPacket)
            {
                Debug.Assert(newSegment != null);
                Debug.Assert(newSegment.SegmentInfo != null);
                FrozenBufferedUpdates segmentUpdates = newSegment.SegmentUpdates;
                //System.out.println("FLUSH: " + newSegment.segmentInfo.info.name);
                if (indexWriter.infoStream.IsEnabled("DW"))
                {
                    indexWriter.infoStream.Message("DW", "publishFlushedSegment seg-private updates=" + segmentUpdates);
                }

                if (segmentUpdates != null && indexWriter.infoStream.IsEnabled("DW"))
                {
                    indexWriter.infoStream.Message("DW", "flush: push buffered seg private updates: " + segmentUpdates);
                }
                // now publish!
                indexWriter.PublishFlushedSegment(newSegment.SegmentInfo, segmentUpdates, globalPacket);
            }
 internal virtual void AddSegment(SegmentFlushTicket ticket, FlushedSegment segment)
 {
     lock (this)
     {
         // the actual flush is done asynchronously and once done the FlushedSegment
         // is passed to the flush ticket
         ticket.Segment = segment;
     }
 }