当前位置: 首页>>代码示例>>C#>>正文


C# MergePolicy.SetException方法代码示例

本文整理汇总了C#中Lucene.Net.Index.MergePolicy.SetException方法的典型用法代码示例。如果您正苦于以下问题:C# MergePolicy.SetException方法的具体用法?C# MergePolicy.SetException怎么用?C# MergePolicy.SetException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lucene.Net.Index.MergePolicy的用法示例。


在下文中一共展示了MergePolicy.SetException方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleMergeException

		private void  HandleMergeException(System.Exception t, MergePolicy.OneMerge merge)
		{
			
			if (infoStream != null)
			{
				Message("handleMergeException: merge=" + merge.SegString(directory) + " exc=" + t);
			}
			
			// Set the exception on the merge, so if
			// optimize() is waiting on us it sees the root
			// cause exception:
			merge.SetException(t);
			AddMergeException(merge);
			
			if (t is MergePolicy.MergeAbortedException)
			{
				// We can ignore this exception (it happens when
				// close(false) or rollback is called), unless the
				// merge involves segments from external directories,
				// in which case we must throw it so, for example, the
				// rollbackTransaction code in addIndexes* is
				// executed.
				if (merge.isExternal)
					throw (MergePolicy.MergeAbortedException) t;
			}
			else if (t is System.IO.IOException)
				throw (System.IO.IOException) t;
			else if (t is System.SystemException)
				throw (System.SystemException) t;
			else if (t is System.ApplicationException)
				throw (System.ApplicationException) t;
			// Should not get here
			else
				throw new System.SystemException(null, t);
		}
开发者ID:Mpdreamz,项目名称:lucene.net,代码行数:35,代码来源:IndexWriter.cs

示例2: Merge

		/// <summary> Merges the indicated segments, replacing them in the stack with a
		/// single segment.
		/// </summary>
		
		public /*internal*/ void  Merge(MergePolicy.OneMerge merge)
		{
			
			System.Diagnostics.Debug.Assert(merge.registerDone);
			System.Diagnostics.Debug.Assert(!merge.optimize || merge.maxNumSegmentsOptimize > 0);
			
			bool success = false;

            try
            {
                try
                {
                    try
                    {
                        if (merge.info == null)
                            MergeInit(merge);

                        if (infoStream != null)
                            Message("now merge\n  merge=" + merge.SegString(directory) + "\n  index=" + SegString());

                        MergeMiddle(merge);
                        success = true;
                    }
                    catch (MergePolicy.MergeAbortedException e)
                    {
                        merge.SetException(e);
                        AddMergeException(merge);
                        // We can ignore this exception, unless the merge
                        // involves segments from external directories, in
                        // which case we must throw it so, for example, the
                        // rollbackTransaction code in addIndexes* is
                        // executed.
                        if (merge.isExternal)
                            throw e;
                    }
                }
                finally
                {
                    lock (this)
                    {
                        try
                        {
                            MergeFinish(merge);

                            if (!success)
                            {
                                if (infoStream != null)
                                    Message("hit exception during merge");
                                AddMergeException(merge);
                                if (merge.info != null && !segmentInfos.Contains(merge.info))
                                    deleter.Refresh(merge.info.name);
                            }

                            // This merge (and, generally, any change to the
                            // segments) may now enable new merges, so we call
                            // merge policy & update pending merges.
                            if (success && !merge.IsAborted() && !closed && !closing)
                                UpdatePendingMerges(merge.maxNumSegmentsOptimize, merge.optimize);
                        }
                        finally
                        {
                            runningMerges.Remove(merge);
                            // Optimize may be waiting on the final optimize
                            // merge to finish; and finishMerges() may be
                            // waiting for all merges to finish:
                            System.Threading.Monitor.PulseAll(this);
                        }
                    }
                }
            }
            catch (OutOfMemoryException oom)
            {
                hitOOM = true;
                throw oom;
            }
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:80,代码来源:IndexWriter.cs


注:本文中的Lucene.Net.Index.MergePolicy.SetException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。