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


C# SegmentReader.GetSegmentInfo方法代码示例

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


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

示例1: Release

			/// <summary> Release the segment reader (i.e. decRef it and close if there
			/// are no more references.
			/// </summary>
			/// <param name="sr">
			/// </param>
			/// <throws>  IOException </throws>
			public virtual void  Release(SegmentReader sr, bool drop)
			{
				lock (this)
				{
					
					bool pooled = readerMap.Contains(sr.GetSegmentInfo());

                    System.Diagnostics.Debug.Assert(!pooled || readerMap[sr.GetSegmentInfo()] == sr);

                    // Drop caller's ref; for an external reader (not
                    // pooled), this decRef will close it
					sr.DecRef();
					
					if (pooled && (drop || (!Enclosing_Instance.poolReaders && sr.GetRefCount() == 1)))
					{

                        // We invoke deleter.checkpoint below, so we must be
                        // sync'd on IW if there are changes:
						
						// TODO: java 5
						// assert !sr.hasChanges || Thread.holdsLock(IndexWriter.this);

                        // Discard (don't save) changes when we are dropping
                        // the reader; this is used only on the sub-readers
                        // after a successful merge.
                        sr.hasChanges &= !drop;

                        bool hasChanges = sr.hasChanges;
						
						// Drop our ref -- this will commit any pending
						// changes to the dir
                        sr.Close();

                        // We are the last ref to this reader; since we're
                        // not pooling readers, we release it:
                        readerMap.Remove(sr.GetSegmentInfo());

                        if (hasChanges)
                        {
                            // Must checkpoint w/ deleter, because this
                            // segment reader will have created new _X_N.del
                            // file.
                            enclosingInstance.deleter.Checkpoint(enclosingInstance.segmentInfos, false);
                        }
					}
				}
			}
开发者ID:Mpdreamz,项目名称:lucene.net,代码行数:53,代码来源:IndexWriter.cs

示例2: Release

            /// <summary> Release the segment reader (i.e. decRef it and close if there
            /// are no more references.
            /// </summary>
            /// <param name="sr">
            /// </param>
            /// <throws>  IOException </throws>
            public virtual void Release(SegmentReader sr, bool drop)
            {
                lock (this)
                {

                    bool pooled = readerMap.Contains(sr.GetSegmentInfo());

                    System.Diagnostics.Debug.Assert(!pooled | readerMap[sr.GetSegmentInfo()] == sr);

                    // Drop caller's ref
                    sr.DecRef();

                    if (pooled && (drop || (!Enclosing_Instance.poolReaders && sr.GetRefCount() == 1)))
                    {

                        // We are the last ref to this reader; since we're
                        // not pooling readers, we release it:
                        readerMap.Remove(sr.GetSegmentInfo());

                        // TODO: java 5
                        // assert !sr.hasChanges || Thread.holdsLock(IndexWriter.this);

                        // Drop our ref -- this will commit any pending
                        // changes to the dir
                        bool success = false;
                        try
                        {
                            sr.Close();
                            success = true;
                        }
                        finally
                        {
                            if (!success && sr.hasChanges)
                            {
                                // Abandon the changes & retry closing:
                                sr.hasChanges = false;
                                try
                                {
                                    sr.Close();
                                }
                                catch (System.Exception ignore)
                                {
                                    // Keep throwing original exception
                                }
                            }
                        }
                    }
                }
            }
开发者ID:o0111,项目名称:ruralcafe,代码行数:55,代码来源:IndexWriter.cs


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