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