本文整理汇总了C#中Lucene.Net.Index.SegmentInfos.PrepareCommit方法的典型用法代码示例。如果您正苦于以下问题:C# SegmentInfos.PrepareCommit方法的具体用法?C# SegmentInfos.PrepareCommit怎么用?C# SegmentInfos.PrepareCommit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Index.SegmentInfos
的用法示例。
在下文中一共展示了SegmentInfos.PrepareCommit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartCommit
/// <summary>
/// Walk through all files referenced by the current
/// segmentInfos and ask the Directory to sync each file,
/// if it wasn't already. If that succeeds, then we
/// prepare a new segments_N file but do not fully commit
/// it.
/// </summary>
private void StartCommit(SegmentInfos toSync)
{
Debug.Assert(TestPoint("startStartCommit"));
Debug.Assert(PendingCommit == null);
if (HitOOM)
{
throw new InvalidOperationException("this writer hit an OutOfMemoryError; cannot commit");
}
try
{
if (infoStream.IsEnabled("IW"))
{
infoStream.Message("IW", "startCommit(): start");
}
lock (this)
{
Debug.Assert(LastCommitChangeCount <= ChangeCount, "lastCommitChangeCount=" + LastCommitChangeCount + " changeCount=" + ChangeCount);
if (PendingCommitChangeCount == LastCommitChangeCount)
{
if (infoStream.IsEnabled("IW"))
{
infoStream.Message("IW", " skip startCommit(): no changes pending");
}
Deleter.DecRef(FilesToCommit);
FilesToCommit = null;
return;
}
if (infoStream.IsEnabled("IW"))
{
infoStream.Message("IW", "startCommit index=" + SegString(ToLiveInfos(toSync).Segments) + " changeCount=" + ChangeCount);
}
Debug.Assert(FilesExist(toSync));
}
Debug.Assert(TestPoint("midStartCommit"));
bool pendingCommitSet = false;
try
{
Debug.Assert(TestPoint("midStartCommit2"));
lock (this)
{
Debug.Assert(PendingCommit == null);
Debug.Assert(segmentInfos.Generation == toSync.Generation);
// Exception here means nothing is prepared
// (this method unwinds everything it did on
// an exception)
toSync.PrepareCommit(directory);
//System.out.println("DONE prepareCommit");
pendingCommitSet = true;
PendingCommit = toSync;
}
// this call can take a long time -- 10s of seconds
// or more. We do it without syncing on this:
bool success = false;
ICollection<string> filesToSync;
try
{
filesToSync = toSync.Files(directory, false);
directory.Sync(filesToSync);
success = true;
}
finally
{
if (!success)
{
pendingCommitSet = false;
PendingCommit = null;
toSync.RollbackCommit(directory);
}
}
if (infoStream.IsEnabled("IW"))
{
infoStream.Message("IW", "done all syncs: " + filesToSync);
}
Debug.Assert(TestPoint("midStartCommitSuccess"));
}
finally
{
//.........这里部分代码省略.........