Lucene.Net.Index.DocumentsWriterDeleteQueue.TryApplyGlobalSlice C# (CSharp) Method

TryApplyGlobalSlice() public method

public TryApplyGlobalSlice ( ) : void
return void
        public void TryApplyGlobalSlice()
        {
            if (GlobalBufferLock.TryLock())
            {
                /*
                 * The global buffer must be locked but we don't need to update them if
                 * there is an update going on right now. It is sufficient to apply the
                 * deletes that have been added after the current in-flight global slices
                 * tail the next time we can get the lock!
                 */
                try
                {
                    if (UpdateSlice(GlobalSlice))
                    {
                        //          System.out.println(Thread.currentThread() + ": apply globalSlice");
                        GlobalSlice.Apply(GlobalBufferedUpdates, BufferedUpdates.MAX_INT);
                    }
                }
                finally
                {
                    GlobalBufferLock.Unlock();
                }
            }
        }

Usage Example

Beispiel #1
0
        public virtual void TestClear()
        {
            DocumentsWriterDeleteQueue queue = new DocumentsWriterDeleteQueue();

            Assert.IsFalse(queue.AnyChanges());
            queue.Clear();
            Assert.IsFalse(queue.AnyChanges());
            int size               = 200 + Random.Next(500) * RANDOM_MULTIPLIER;
            int termsSinceFreeze   = 0;
            int queriesSinceFreeze = 0;

            for (int i = 0; i < size; i++)
            {
                Term term = new Term("id", "" + i);
                if (Random.Next(10) == 0)
                {
                    queue.AddDelete(new TermQuery(term));
                    queriesSinceFreeze++;
                }
                else
                {
                    queue.AddDelete(term);
                    termsSinceFreeze++;
                }
                Assert.IsTrue(queue.AnyChanges());
                if (Random.Next(10) == 0)
                {
                    queue.Clear();
                    queue.TryApplyGlobalSlice();
                    Assert.IsFalse(queue.AnyChanges());
                }
            }
        }
All Usage Examples Of Lucene.Net.Index.DocumentsWriterDeleteQueue::TryApplyGlobalSlice