Merge() private method

Merges the indicated segments, replacing them in the stack with a single segment.
private Merge ( MergePolicy merge ) : void
merge MergePolicy
return void
Example #1
0
 public override void Merge(IndexWriter writer, MergeTrigger trigger, bool newMergesFound)
 {
     UninterruptableMonitor.Enter(this);
     try
     {
         while (true)
         {
             MergePolicy.OneMerge merge = writer.NextMerge();
             if (merge == null)
             {
                 break;
             }
             for (int i = 0; i < merge.Segments.Count; i++)
             {
                 if (Debugging.AssertsEnabled)
                 {
                     Debugging.Assert(merge.Segments[i].Info.DocCount < 20);
                 }
             }
             writer.Merge(merge);
         }
     }
     finally
     {
         UninterruptableMonitor.Exit(this);
     }
 }
Example #2
0
 public override void Merge(IndexWriter writer, MergeTrigger trigger, bool newMergesFound)
 {
     MergePolicy.OneMerge merge = null;
     while ((merge = writer.NextMerge()) != null)
     {
         if (VERBOSE)
         {
             Console.WriteLine("executing merge " + merge.SegString(writer.Directory));
         }
         writer.Merge(merge);
     }
 }
		/// <summary>Just do the merges in sequence. We do this
		/// "synchronized" so that even if the application is using
		/// multiple threads, only one merge may run at a time. 
		/// </summary>
		public override void  Merge(IndexWriter writer)
		{
			lock (this)
			{
				
				while (true)
				{
					MergePolicy.OneMerge merge = writer.GetNextMerge();
					if (merge == null)
						break;
					writer.Merge(merge);
				}
			}
		}
 /// <summary>Just do the merges in sequence. We do this
 /// "synchronized" so that even if the application is using
 /// multiple threads, only one merge may run at a time.
 /// </summary>
 public override void  Merge(IndexWriter writer)
 {
     lock (this)
     {
         while (true)
         {
             MergePolicy.OneMerge merge = writer.GetNextMerge();
             if (merge == null)
             {
                 break;
             }
             writer.Merge(merge);
         }
     }
 }
Example #5
0
 /// <summary>
 /// Just do the merges in sequence. We do this
 /// "synchronized" so that even if the application is using
 /// multiple threads, only one merge may run at a time.
 /// </summary>
 public override void Merge(IndexWriter writer, MergeTrigger trigger, bool newMergesFound) // LUCENENET NOTE: This was internal in the original, but the base class is public so there isn't much choice here
 {
     lock (this)
     {
         while (true)
         {
             MergePolicy.OneMerge merge = writer.NextMerge();
             if (merge == null)
             {
                 break;
             }
             writer.Merge(merge);
         }
     }
 }
 public override void Merge(IndexWriter writer, MergeTrigger trigger, bool newMergesFound)
 {
     lock (this)
     {
         while (true)
         {
             MergePolicy.OneMerge merge = writer.NextMerge();
             if (merge == null)
             {
                 break;
             }
             for (int i = 0; i < merge.Segments.Count; i++)
             {
                 Debug.Assert(merge.Segments[i].Info.DocCount < 20);
             }
             writer.Merge(merge);
         }
     }
 }
Example #7
0
 public override void Merge(IndexWriter writer, MergeTrigger trigger, bool newMergesFound) // LUCENENET NOTE: This was internal in the original, but the base class is public so there isn't much choice here
 {
     UninterruptableMonitor.Enter(this);
     try
     {
         while (true)
         {
             MergePolicy.OneMerge merge = writer.NextMerge();
             if (merge is null)
             {
                 break;
             }
             writer.Merge(merge);
         }
     }
     finally
     {
         UninterruptableMonitor.Exit(this);
     }
 }
 public override void Merge(IndexWriter writer, MergeTrigger trigger, bool newMergesFound)
 {
     lock (this)
     {
         while (true)
         {
             MergePolicy.OneMerge merge = writer.NextMerge;
             if (merge == null)
             {
                 break;
             }
             for (int i = 0; i < merge.Segments.Count; i++)
             {
                 Debug.Assert(merge.Segments[i].Info.DocCount < 20);
             }
             writer.Merge(merge);
         }
     }
 }
 protected virtual void DoMerge(MergePolicy.OneMerge merge)
 {
     m_writer.Merge(merge);
 }
Example #10
0
            override public void  Run()
            {
                // First time through the while loop we do the merge
                // that we were started with:
                MergePolicy.OneMerge merge = this.startMerge;

                try
                {
                    Enclosing_Instance.Message("  merge thread: start");

                    while (true)
                    {
                        SetRunningMerge(merge);
                        writer.Merge(merge);

                        // Subsequent times through the loop we do any new
                        // merge that writer says is necessary:
                        merge = writer.GetNextMerge();
                        if (merge != null)
                        {
                            writer.MergeInit(merge);
                            Enclosing_Instance.Message("  merge thread: do another merge " + merge.SegString(Enclosing_Instance.dir));
                        }
                        else
                        {
                            break;
                        }
                    }

                    Enclosing_Instance.Message("  merge thread: done");
                }
                catch (System.Exception exc)
                {
                    if (merge != null)
                    {
                        merge.SetException(exc);
                        writer.AddMergeException(merge);
                    }

                    // Ignore the exception if it was due to abort:
                    if (!(exc is MergePolicy.MergeAbortedException))
                    {
                        lock (Enclosing_Instance)
                        {
                            Enclosing_Instance.exceptions.Add(exc);
                        }

                        if (!Enclosing_Instance.suppressExceptions)
                        {
                            // suppressExceptions is normally only set during
                            // testing.
                            Lucene.Net.Index.ConcurrentMergeScheduler.anyExceptions = true;
                            throw new MergePolicy.MergeException(exc);
                        }
                    }
                }
                finally
                {
                    lock (Enclosing_Instance)
                    {
                        Enclosing_Instance.mergeThreads.Remove(this);
                        System.Threading.Monitor.PulseAll(Enclosing_Instance);
                    }
                }
            }
Example #11
0
        public override void  Merge(IndexWriter writer)
        {
            this.writer = writer;

            InitMergeThreadPriority();

            dir = writer.GetDirectory();

            // First, quickly run through the newly proposed merges
            // and add any orthogonal merges (ie a merge not
            // involving segments already pending to be merged) to
            // the queue.  If we are way behind on merging, many of
            // these newly proposed merges will likely already be
            // registered.

            Message("now merge");
            Message("  index: " + writer.SegString());

            // Iterate, pulling from the IndexWriter's queue of
            // pending merges, until its empty:
            while (true)
            {
                // TODO: we could be careful about which merges to do in
                // the BG (eg maybe the "biggest" ones) vs FG, which
                // merges to do first (the easiest ones?), etc.

                MergePolicy.OneMerge merge = writer.GetNextMerge();
                if (merge == null)
                {
                    Message("  no more merges pending; now return");
                    return;
                }

                // We do this w/ the primary thread to keep
                // deterministic assignment of segment names
                writer.MergeInit(merge);

                Message("  consider merge " + merge.SegString(dir));

                if (merge.isExternal)
                {
                    Message("    merge involves segments from an external directory; now run in foreground");
                }
                else
                {
                    lock (this)
                    {
                        if (MergeThreadCount() < maxThreadCount)
                        {
                            // OK to spawn a new merge thread to handle this
                            // merge:
                            MergeThread merger = new MergeThread(this, writer, merge);
                            mergeThreads.Add(merger);
                            Message("    launch new thread [" + merger.Name + "]");
                            merger.SetThreadPriority(mergeThreadPriority);
                            merger.IsBackground = true;
                            merger.Start();
                            continue;
                        }
                        else
                        {
                            Message("    too many merge threads running; run merge in foreground");
                        }
                    }
                }

                // Too many merge threads already running, so we do
                // this in the foreground of the calling thread
                writer.Merge(merge);
            }
        }
Example #12
0
            private void Run(CancellationToken cancellationToken)
            {
                // First time through the while loop we do the merge
                // that we were started with:
                MergePolicy.OneMerge merge = _startingMerge;

                try
                {
                    if (_isLoggingEnabled)
                    {
                        _logger.Message(COMPONENT_NAME, "  merge thread: start");
                    }

                    while (true && !cancellationToken.IsCancellationRequested)
                    {
                        RunningMerge = merge;
                        _writer.Merge(merge);

                        // Subsequent times through the loop we do any new
                        // merge that writer says is necessary:
                        merge = _writer.NextMerge();

                        // Notify here in case any threads were stalled;
                        // they will notice that the pending merge has
                        // been pulled and possibly resume:
                        _resetEvent.Set();

                        if (merge != null)
                        {
                            if (_isLoggingEnabled)
                            {
                                _logger.Message(COMPONENT_NAME, "  merge thread: do another merge " + _writer.SegString(merge.Segments));
                            }
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (_isLoggingEnabled)
                    {
                        _logger.Message(COMPONENT_NAME, "  merge thread: done");
                    }
                }
                catch (Exception exc)
                {
                    // Ignore the exception if it was due to abort:
                    if (!(exc is MergePolicy.MergeAbortedException))
                    {
                        //System.out.println(Thread.currentThread().getName() + ": CMS: exc");
                        //exc.printStackTrace(System.out)
                        _exceptionHandler(exc);
                    }
                }
                finally
                {
                    _isDone = true;

                    if (MergeThreadCompleted != null)
                    {
                        MergeThreadCompleted(this, EventArgs.Empty);
                    }
                }
            }
			public override void  Merge(IndexWriter writer)
			{
				lock (this)
				{
					
					while (true)
					{
						MergePolicy.OneMerge merge = writer.GetNextMerge();
						if (merge == null)
							break;
						for (int i = 0; i < merge.Segments_ForNUnitTest.Count; i++)
							System.Diagnostics.Debug.Assert(merge.Segments_ForNUnitTest.Info(i).docCount < 20);
						writer.Merge(merge);
					}
				}
			}
 /// <summary>Does the actual merge, by calling {@link IndexWriter#merge} </summary>
 protected internal virtual void  DoMerge(MergePolicy.OneMerge merge)
 {
     writer.Merge(merge);
 }
Example #15
0
			public override /*virtual*/ void  Merge(IndexWriter writer)
			{
				lock (this)
				{
					
					while (true)
					{
						MergePolicy.OneMerge merge = writer.GetNextMerge();
						if (merge == null)
							break;
						for (int i = 0; i < merge.segments_ForNUnit.Count; i++)
							; // {{}} assert merge.segments.Info(i).docCount < 20;
						writer.Merge(merge);
					}
				}
			}
		public override void  Merge(IndexWriter writer)
		{
			
			this.writer = writer;
			
			InitMergeThreadPriority();
			
			dir = writer.GetDirectory();
			
			// First, quickly run through the newly proposed merges
			// and add any orthogonal merges (ie a merge not
			// involving segments already pending to be merged) to
			// the queue.  If we are way behind on merging, many of
			// these newly proposed merges will likely already be
			// registered.
			
			Message("now merge");
			Message("  index: " + writer.SegString());
			
			// Iterate, pulling from the IndexWriter's queue of
			// pending merges, until its empty:
			while (true)
			{
				
				// TODO: we could be careful about which merges to do in
				// the BG (eg maybe the "biggest" ones) vs FG, which
				// merges to do first (the easiest ones?), etc.
				
				MergePolicy.OneMerge merge = writer.GetNextMerge();
				if (merge == null)
				{
					Message("  no more merges pending; now return");
					return ;
				}
				
				// We do this w/ the primary thread to keep
				// deterministic assignment of segment names
				writer.MergeInit(merge);
				
				Message("  consider merge " + merge.SegString(dir));
				
				if (merge.isExternal)
				{
					Message("    merge involves segments from an external directory; now run in foreground");
				}
				else
				{
					lock (this)
					{
						if (MergeThreadCount() < maxThreadCount)
						{
							// OK to spawn a new merge thread to handle this
							// merge:
							MergeThread merger = new MergeThread(this, writer, merge);
							mergeThreads.Add(merger);
							Message("    launch new thread [" + merger.Name + "]");
							merger.SetThreadPriority(mergeThreadPriority);
							merger.IsBackground = true;
							merger.Start();
							continue;
						}
						else
							Message("    too many merge threads running; run merge in foreground");
					}
				}
				
				// Too many merge threads already running, so we do
				// this in the foreground of the calling thread
				writer.Merge(merge);
			}
		}