示例#1
0
 internal virtual void PublishFrozenUpdates(FrozenBufferedUpdates packet)
 {
     lock (this)
     {
         Debug.Assert(packet != null && packet.Any());
         lock (BufferedUpdatesStream)
         {
             BufferedUpdatesStream.Push(packet);
         }
     }
 }
示例#2
0
        /// <summary>
        /// Atomically adds the segment private delete packet and publishes the flushed
        /// segments SegmentInfo to the index writer.
        /// </summary>
        internal virtual void PublishFlushedSegment(SegmentCommitInfo newSegment, FrozenBufferedUpdates packet, FrozenBufferedUpdates globalPacket)
        {
            try
            {
                lock (this)
                {
                    // Lock order IW -> BDS
                    lock (BufferedUpdatesStream)
                    {
                        if (infoStream.IsEnabled("IW"))
                        {
                            infoStream.Message("IW", "publishFlushedSegment");
                        }

                        if (globalPacket != null && globalPacket.Any())
                        {
                            BufferedUpdatesStream.Push(globalPacket);
                        }
                        // Publishing the segment must be synched on IW -> BDS to make the sure
                        // that no merge prunes away the seg. private delete packet
                        long nextGen;
                        if (packet != null && packet.Any())
                        {
                            nextGen = BufferedUpdatesStream.Push(packet);
                        }
                        else
                        {
                            // Since we don't have a delete packet to apply we can get a new
                            // generation right away
                            nextGen = BufferedUpdatesStream.NextGen;
                        }
                        if (infoStream.IsEnabled("IW"))
                        {
                            infoStream.Message("IW", "publish sets newSegment delGen=" + nextGen + " seg=" + SegString(newSegment));
                        }
                        newSegment.BufferedDeletesGen = nextGen;
                        segmentInfos.Add(newSegment);
                        Checkpoint();
                    }
                }
            }
            finally
            {
                flushCount.IncrementAndGet();
                DoAfterFlush();
            }
        }
        public FrozenBufferedUpdates FreezeGlobalBuffer(DeleteSlice callerSlice)
        {
            GlobalBufferLock.@Lock();
            /*
             * Here we freeze the global buffer so we need to lock it, apply all
             * deletes in the queue and reset the global slice to let the GC prune the
             * queue.
             */
            Node currentTail = Tail; // take the current tail make this local any
            // Changes after this call are applied later
            // and not relevant here
            if (callerSlice != null)
            {
                // Update the callers slices so we are on the same page
                callerSlice.SliceTail = currentTail;
            }
            try
            {
                if (GlobalSlice.SliceTail != currentTail)
                {
                    GlobalSlice.SliceTail = currentTail;
                    GlobalSlice.Apply(GlobalBufferedUpdates, BufferedUpdates.MAX_INT);
                }

                FrozenBufferedUpdates packet = new FrozenBufferedUpdates(GlobalBufferedUpdates, false);
                GlobalBufferedUpdates.Clear();
                return packet;
            }
            finally
            {
                GlobalBufferLock.Unlock();
            }
        }
 internal FlushedSegment(SegmentCommitInfo segmentInfo, FieldInfos fieldInfos, BufferedUpdates segmentUpdates, MutableBits liveDocs, int delCount)
 {
     this.SegmentInfo = segmentInfo;
     this.FieldInfos = fieldInfos;
     this.SegmentUpdates = segmentUpdates != null && segmentUpdates.Any() ? new FrozenBufferedUpdates(segmentUpdates, true) : null;
     this.LiveDocs = liveDocs;
     this.DelCount = delCount;
 }
 protected internal SegmentFlushTicket(FrozenBufferedUpdates frozenDeletes)
     : base(frozenDeletes)
 {
 }
 protected internal GlobalDeletesTicket(FrozenBufferedUpdates frozenUpdates)
     : base(frozenUpdates)
 {
 }
            /// <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);
            }
 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);
     }
 }
 protected internal FlushTicket(FrozenBufferedUpdates frozenUpdates)
 {
     Debug.Assert(frozenUpdates != null);
     this.FrozenUpdates = frozenUpdates;
 }