Clear() public method

public Clear ( ) : void
return void
Ejemplo n.º 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());
                }
            }
        }
Ejemplo n.º 2
0
 internal void Abort(IndexWriter writer)
 {
     UninterruptableMonitor.Enter(this);
     try
     {
         if (Debugging.AssertsEnabled)
         {
             Debugging.Assert(!UninterruptableMonitor.IsEntered(writer), "IndexWriter lock should never be hold when aborting");
         }
         bool success = false;
         JCG.HashSet <string> newFilesSet = new JCG.HashSet <string>();
         try
         {
             deleteQueue.Clear();
             if (infoStream.IsEnabled("DW"))
             {
                 infoStream.Message("DW", "abort");
             }
             int limit = perThreadPool.NumThreadStatesActive;
             for (int i = 0; i < limit; i++)
             {
                 ThreadState perThread = perThreadPool.GetThreadState(i);
                 perThread.@Lock();
                 try
                 {
                     AbortThreadState(perThread, newFilesSet);
                 }
                 finally
                 {
                     perThread.Unlock();
                 }
             }
             flushControl.AbortPendingFlushes(newFilesSet);
             PutEvent(new DeleteNewFilesEvent(newFilesSet));
             flushControl.WaitForFlush();
             success = true;
         }
         finally
         {
             if (infoStream.IsEnabled("DW"))
             {
                 infoStream.Message("DW", "done abort; abortedFiles=" + string.Format(J2N.Text.StringFormatter.InvariantCulture, "{0}", newFilesSet) + " success=" + success);
             }
         }
     }
     finally
     {
         UninterruptableMonitor.Exit(this);
     }
 }
 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());
         }
     }
 }
Ejemplo n.º 4
0
 internal void Abort(IndexWriter writer)
 {
     lock (this)
     {
         //Debug.Assert(!Thread.HoldsLock(writer), "IndexWriter lock should never be hold when aborting");
         bool             success     = false;
         HashSet <string> newFilesSet = new HashSet <string>();
         try
         {
             deleteQueue.Clear();
             if (infoStream.IsEnabled("DW"))
             {
                 infoStream.Message("DW", "abort");
             }
             int limit = perThreadPool.NumThreadStatesActive;
             for (int i = 0; i < limit; i++)
             {
                 ThreadState perThread = perThreadPool.GetThreadState(i);
                 perThread.@Lock();
                 try
                 {
                     AbortThreadState(perThread, newFilesSet);
                 }
                 finally
                 {
                     perThread.Unlock();
                 }
             }
             flushControl.AbortPendingFlushes(newFilesSet);
             PutEvent(new DeleteNewFilesEvent(newFilesSet));
             flushControl.WaitForFlush();
             success = true;
         }
         finally
         {
             if (infoStream.IsEnabled("DW"))
             {
                 infoStream.Message("DW", "done abort; abortedFiles=" + Arrays.ToString(newFilesSet) + " success=" + success);
             }
         }
     }
 }