本文整理汇总了C#中Lucene.Net.Index.SegmentInfos.RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:C# SegmentInfos.RemoveAt方法的具体用法?C# SegmentInfos.RemoveAt怎么用?C# SegmentInfos.RemoveAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Index.SegmentInfos
的用法示例。
在下文中一共展示了SegmentInfos.RemoveAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MergeSegments
/// <summary> Merges the named range of segments, replacing them in the stack with a
/// single segment.
/// </summary>
private int MergeSegments(SegmentInfos sourceSegments, int minSegment, int end)
{
// We may be called solely because there are deletes
// pending, in which case doMerge is false:
bool doMerge = end > 0;
System.String mergedName = NewSegmentName();
SegmentMerger merger = null;
System.Collections.ArrayList segmentsToDelete = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
System.String segmentsInfosFileName = segmentInfos.GetCurrentSegmentFileName();
System.String nextSegmentsFileName = segmentInfos.GetNextSegmentFileName();
SegmentInfo newSegment = null;
int mergedDocCount = 0;
// This is try/finally to make sure merger's readers are closed:
try
{
if (doMerge)
{
if (infoStream != null)
infoStream.Write("merging segments");
merger = new SegmentMerger(this, mergedName);
for (int i = minSegment; i < end; i++)
{
SegmentInfo si = sourceSegments.Info(i);
if (infoStream != null)
infoStream.Write(" " + si.name + " (" + si.docCount + " docs)");
IndexReader reader = SegmentReader.Get(si); // no need to
// set deleter
// (yet)
merger.Add(reader);
if ((reader.Directory() == this.directory) || (reader.Directory() == this.ramDirectory))
segmentsToDelete.Add(reader); // queue segment
// for deletion
}
}
SegmentInfos rollback = null;
bool success = false;
// This is try/finally to rollback our internal state
// if we hit exception when doing the merge:
try
{
if (doMerge)
{
mergedDocCount = merger.Merge();
if (infoStream != null)
{
infoStream.WriteLine(" into " + mergedName + " (" + mergedDocCount + " docs)");
}
newSegment = new SegmentInfo(mergedName, mergedDocCount, directory, false, true);
}
if (!inTransaction && (sourceSegments != ramSegmentInfos || bufferedDeleteTerms.Count > 0))
{
// Now save the SegmentInfo instances that
// we are replacing:
rollback = (SegmentInfos) segmentInfos.Clone();
}
if (doMerge)
{
if (sourceSegments == ramSegmentInfos)
{
segmentInfos.Add(newSegment);
}
else
{
for (int i = end - 1; i > minSegment; i--)
// remove old infos & add new
sourceSegments.RemoveAt(i);
segmentInfos[minSegment] = newSegment;
}
}
if (sourceSegments == ramSegmentInfos)
{
// Should not be necessary: no prior commit should
// have left pending files, so just defensive:
deleter.ClearPendingFiles();
MaybeApplyDeletes(doMerge);
DoAfterFlush();
}
if (!inTransaction)
{
//.........这里部分代码省略.........